• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

VVPDF - vvPDdf.addHTML

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VVPDF - vvPDdf.addHTML

    I see this is part of the vvPdf service program, but unfortunately not documented nor any examples..

    can this be used ?

    we would like to create a document with F.e a header doc that consists of a logo (on the left , a title center, and a date on the right alignment

    but cannot seem to make this work with the supplied pdf-procedures..

    is this the correct way or is there another way to create pdf's directly from within RPG.


  • #2
    Hi Thierry,

    The addHTML procedure might work for what you're trying to do. It was a bit of an experiment, hence not documented (yet). But you should be able to use it provided you add [ROOT_PATH]java/cnxpdf.jar to your Portal Admin > Settings > Java CLASSPATH setting.

    We'll add an example program for vvPDF_addHTML to the next build. Here's what it will look like:
    Code:
          /copy qcpylesrc,vvHspec                                                  
         ** --------------------------------------------------------------        
         **         Copyright (C) 2008-2019 CNX Corporation                        
         ** --------------------------------------------------------------        
         **     Object ID: EXPDF04                                                
         **       Version: V5.2                                                    
         **   Description: Valence Examples - PDF - using addHTML procedure        
         ** --------------------------------------------------------------        
         **--------------------------------------------                            
         **  d specs                                                              
         **--------------------------------------------                            
         d pdfDoc          s                   like(document)                      
         d html1           s          65535a   varying                            
         d html2           s          65535a   varying                            
         d htmlfld         s             40a                                      
    
          /define includePDF                                                      
          /copy qcpylesrc,vvDspec                                                  
         **--------------------------------------------                            
         **  program start                                                        
         **--------------------------------------------                            
          /free                                                                    
           // specify the full name and path of the PDF document you wish to create
           vvPDF.path=vvUtility_getValenceSetting('PDF_PATH')+'pdfSample.pdf';                      
    
           // create the PDF document object                                                        
           pdfDoc = vvPdf_newDocument(vvPDF);                                                        
    
           // create a sample html string.                                                          
           html1 = '<html><body><h1>Example Heading<h1></body>/html>';                            
    
           // pass the PDF document and the html string to render the html inside the PDF document.  
           vvPdf_addHTML(pdfDoc: html1);                                                            
    
           // create a variable to be added to the html string.                                      
           htmlfld = '555 Main St.';                                                                
           html2 = '<html><body><h1>Address is: ' + htmlfld +                                        
                   '</h1></body></html>';                                                            
    
           // pass the PDF document and the html string to render the additional html in the document.
           vvPdf_addHTML(pdfDoc: html2);                                                            
    
           // close the document                                                                    
           vvPdf_closeDocument(pdfDoc);                                                              
    
           vvOut.download='Y';        
           vvOut.file='expdf04.pdf';                                
           vvOut_file(vvUtility_getValenceSetting('PDF_PATH')+      
                      'pdfSample.pdf':vvOut);                        
    
           *inlr=*on;
    Let us know how it works out!
    Last edited by robert.swanson; 06-15-2019, 06:05 AM.

    Comment

    Working...
    X