• Pdf from Notesdocument

    By Sreeni amrutur 2 decades ago

    Can this be tweaked so that a pdf can be created from an existing NotesDocument backend object?

    • Create PDF from Notes Document

      By Santhosh RM Sequeira 2 decades ago

      Hi



      Require help.



      I have written a Java code in lotus notes using itext which will generate a PDF file. I want the full lotus notes document (text, richtext, images,etc) to be moved/exported/printed to PDF file using a program or code. In other words move the lotus notes documents directly to PDF at one stretch.



      Appreciate a response and support at the earliest… Thanks..



      appended is the code which have written



      ———————————————————————————————————————————————————————–

      import lotus.domino.*;

      import java.io.FileOutputStream;

      import com.lowagie.text.PageSize;

      import com.lowagie.text.Paragraph;

      import com.lowagie.text.Chapter;

      import com.lowagie.text.Font;

      import com.lowagie.text.List;

      import com.lowagie.text.Table;

      import com.lowagie.text.Document;

      import com.lowagie.text.DocumentException;

      import com.lowagie.text.pdf.PdfWriter;

      import lotus.domino.RichTextItem;

      import com.lowagie.text.Image;



      public class JavaAgent extends AgentBase {

        public void NotesMain() {<br/>
              try {<br/>
                    Session session = getSession();<br/>
                    AgentContext agentContext = session.getAgentContext();<br/>
                   //create document's object<br/>
       <br/>
                     Document document = new Document();<br/>
      


                    try {<br/>
      

      //create a document

                          PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(&quot;c:\\PDFInlotus1.pdf&quot;));<br/>
                      document.addAuthor(&quot;Santhosh&quot;); <br/>
                      document.addSubject(&quot;Testing files.&quot;); <br/>
      




                         //open doc for r/w<br/>
      <br/>
                    document.open();<br/>
      


                  DocumentCollection dc = agentContext.getUnprocessedDocuments();<br/>
                  lotus.domino.Document doc = dc.getFirstDocument();<br/>
      



      // adding content to the document

                  document.add(new Paragraph(doc.getItemValueString(&quot;Text&quot;)));<br/>
                 //adding richtext field<br/>
                      document.add(new Paragraph (doc.getItemValueString(&quot;Additional_richText&quot;)));                <br/>
                 // adding the full notes document - need help here<br/>
                          document.add(doc);<br/>
              <br/>
      

      // To insert image

              Image imgLogoImage = Image.getInstance(&quot;c:/image.jpg&quot;);<br/>
                   document.add(imgLogoImage);<br/>
      


                                          <br/>
                    doc = dc.getNextDocument(); }<br/>
                                  <br/>
                  catch (DocumentException de) {<br/>
                                System.err.println(de.getMessage());<br/>
                          }<br/>
      


                          document.close();<br/>
      


              } catch(Exception e) {<br/>
                    e.printStackTrace();<br/>
              }<br/>
        }<br/>
      

      }



      ———————————————————————————————————————————————————————–