Visual Builder

Get Involved. Join the Conversation.

Topic

    Shakila Murugan
    How to Generate PDF in Oracle VBCS?
    Topic posted September 8, 2019 by Shakila MuruganBronze Medal: 1,250+ Points, tagged Action Flows, Business Objects, Custom Code, JET, UI 
    111 Views, 13 Comments
    Title:
    How to Generate PDF in Oracle VBCS?
    Content:
    Hi Team
     
    I need to generate PDF file in VBCS.
     
    I have tried that in Oracle JET. In JET i have added library in main.js file
     
     'pdfmake': 'libs/Pdf/pdfmake',
        'vfs_fonts': 'libs/Pdf/vfs_fonts',
     
    and also extra 3 js files in src folder.
    It's worked fine in JET.
     
    Is this approach will work in VBCS?
    Is there any feature to add library in VBCS?
    Is there any other option available in VBCS to generate PDF? or i need to add pdfmaker library in vbcs to achieve this?
     
    Help me to solve this.
     
    Thanks
    Shakila Murugan
    Version:
    19.1.3

    Comment

     

    • Duncan Mills

      Yes it should be pretty similar

      1. Import the js files you need under the resources folder of your Visual Builder app. 
      2. Set up the requireJS paths for pdfmake and vfs_fonts in the app-flow.json to point to the location under resources where you put the files 
      3. Then to use the code you can create a function in your AppModule / PageModule.js files having included the imports to the define block of the same just like you would in a JET module js file. 

       

    • Shay Shmeltzer

      The basics of importing JS into your app is shown here:

      https://blogs.oracle.com/vbcs/3-tips-for-using-imported-javascript-with-visual-builder

       

      • Shakila Murugan

        Hi Team,

        Thanks for your response. Its working fine for me, but i need one more requirement. Does this way support arabic contents? In pdf file how to add arabic content ?

        FYI: I have generated PDF file using js.

        Thanks & Regards

    • Duncan Mills

      That's a question for the creators of the library you are using. In JavaScript you are generally working in Unicode so I don't see any problems but there could be issues about the font selection to use in the PDF which is out of scope of this forum

    • Vignesh Viswanathan

      Hi,

      I am also given the requirement of pdf generation using pdfmake.js.

      I have written a method like this,

      PageModule.prototype.pdfMethodDownload = function() {
             pdfmake.fonts = {
               Roboto: {
                 normal: 'Roboto-Regular.ttf',
                 bold: 'Roboto-Regular.ttf',
                 italics: 'Roboto-Regular.ttf',
                 bolditalics: 'Roboto-Regular.ttf'
               },
               DroidKufi: {
                 normal: 'DroidKufi-Regular.ttf',
                 bold: 'DroidKufi-Regular.ttf',
                 italics: 'DroidKufi-Regular.ttf',
                 bolditalics: 'DroidKufi-Regular.ttf'
               }
             };
             var docDefinition = {
               content: [{
                   text: 'اختبار',
                   font: 'DroidKufi'
                 },
                 {
                   text: 'test',
                   font: 'Roboto'
                 }
               ]
             };
             var pedf = pdfmake.createPdf(docDefinition);
             pdfmake.createPdf(docDefinition).open();
           };
      and i have added library like this in index.html for arabic
      <script type="text/javascript" src="resources/pdfMake/fonts/DroidKufi-Regular.ttf"></script>
      <script type="text/javascript" src="resources/pdfMake/fonts/Roboto-Regular.ttf"></script>
       
      for the first time its working fine,when i reload the page, i am repeatedly facing the issue like this(attached below).
      what is the virtual file system? Do i need to add any other library?
       
      Help me to solve this.
      Thanks,
      Vignesh
    • Duncan Mills

      That message that has bubbled up from the pdfmake it's just being reported by Visual Builder

    • Duncan Mills

      Yes, but  it's a problem in and reported by the PDFMake library - i.e. you'll have to do some research on the relevant help sources for that library to work out what is going wrong and therefore what you have to do to fix it.