1 2 Previous Next 25 Replies Latest reply: Feb 26, 2013 3:35 AM by 847456 RSS

    OOTB PDF generation

    673066
      We are looking for a way to use the ootb pdf generation in Oracle BPM10.3 to create an attachment in a pdf file type from a business object.
      Anybody have any insights to this?
        • 1. Re: OOTB PDF generation
          Daniel Atwood
          Hi,

          There is no OOTB PDF generation capability in Oracle BPM, but (guessing you know this) the iText Java library works very well for this.

          You'd need to:

          1. Write a little Java class that accepts a hash table as an incoming parameter and uses the values received to create and populate a PDF. This class calls methods in the iText library (http://www.lowagie.com/iText/) that populate the PDF document with the values it's passed.
          2. Jar the class and expose this and the iText "iText-2.1.7.jar" file as an External Resource in Oracle BPM.
          3. In a method in Oracle BPM, set the values in a hash table from the values in your BPM Object and call the Java method you wrote using the hash table as an incoming parameter.

          Rather than creating a PDF from scratch each time, you can also start with an Adobe AcroForm. You'd use this as a template and fill the form's bookmarked fields in using the fields sent in from the hash table.

          Once the PDF has been created, you'd use the Catalog's Fuego.Attachment.create() method to attach the file to the instance.

          Hope this helps,
          Dan
          • 2. Re: OOTB PDF generation
            719471
            Dan and others,
            Do you have a sample code of the little Java class that accepts a hash table as an incoming parameter and uses the values received to create and populate a PDF. This class calls methods in the iText library (http://www.lowagie.com/iText/) that populate the PDF document with the values it's passed?
            • 3. Re: OOTB PDF generation
              Daniel Atwood
              Are you on Oracle BPM 10g or are you on 11g?

              Dan
              • 4. Re: OOTB PDF generation
                719471
                Oracle BPM 10G

                Does Oracle BPM 11G already have such an API or Method?

                Edited by: user8766631 on May 9, 2011 12:42 PM
                • 5. Re: OOTB PDF generation
                  719471
                  Anybody on this?
                  • 6. Re: OOTB PDF generation
                    Daniel Atwood
                    There is nothing that works OOTB. You can try putting a "Print" button on the presentation and set its action property to "print" but the file generated looks really bad.

                    I use the iText Java API on projects. I wrote a Java helper class that I call from a BPM Object method that generates a PDF automatically and populates it with information gathered in the process. Input arguments into this helper class are a hashmap (information that I want displayed in the PDF), the name and location of an existing PDF template (the file I insert the text into) and the output PDF file's name and location.

                    I also use this to automatically add barcodes to existing PDF documents.

                    http://www.avioconsulting.com/blog/datwood/2011/05/12/generating-pdfs-oracle-bpm-process

                    Dan
                    • 7. Re: OOTB PDF generation
                      719471
                      Do you have any sample code on how to do this?

                      I understand that we have to create a Java class but what methods of the itext lib should we use to generate a PDF out of that?

                      Any sample process would be really helpful?
                      • 8. Re: OOTB PDF generation
                        Daniel Atwood
                        Yes - here's the link to the source: http://www.avioconsulting.com/blog/datwood/2011/05/12/generating-pdfs-oracle-bpm-process

                        Click the link (Jacket.java) at the bottom of the post.

                        Dan
                        • 9. Re: OOTB PDF generation
                          719471
                          Hi Dan,
                          I have certain questions on this:-

                          1) What happens when we don't want to create a templateFile. How do we create a PDF then?

                          2) What happens when there are repeatable fields in a group inside the templateFile which are completed at runtime. For e.g. we have a field which calculates total cost by adding all added costs to the table. Now these added costs can be a total 5 different costs or even 10 different costs. How do we accept this and set it as form field in the PDF as an array of costs?

                          3) If we indeed are using this templateFile, where do we place it which deploying our code onto the server and what would be the access path to it? Will it be on Weblogic or physically located on the server or where?


                          4) Finally how do we get the contents in Binary format of this generated pdf file because the method Fuego.Lib.Attachment.create(contents : null, name : targetFile, description : "test"); accepts contents only in Binary format? xmpMetaData of the PDFStamper although in Binary format is ready only? So we cannot put it in the contents field of Fuego.Lib.Attachment.create(contents : null, name : targetFile, description : "test"); ?

                          So what should we put?

                          Even mailAttachments.extend(source : null, fileName : "test.pdf") requires source as Binary Contents. How we do this?
                          • 10. Re: OOTB PDF generation
                            Daniel Atwood
                            1) What happens when we don't want to create a templateFile. How do we create a PDF then?
                            2) What happens when there are repeatable fields in a group inside the templateFile which are completed at runtime. For e.g. we have a field which calculates total cost by adding all added costs to the table. Now these added costs can be a total 5 different costs or even 10 different costs. How do we accept this and set it as form field in the PDF as an array of costs?
                            Again, there is no OOTB solution and what I described is just one approach. Whenever possible, I'll use a template file. It's quick - the code's already written to support this. As you point out, it's not the answer for everything. You can build PDF files without a template (again using iText as the PDF API is just one approach that will work). This will mean some Java development on your end to write the code necessary to build them from scratch.
                            3) If we indeed are using this templateFile, where do we place it which deploying our code onto the server and what would be the access path to it? Will it be on Weblogic or physically located on the server or where
                            4) Finally how do we get the contents in Binary format of this generated pdf file because the method Fuego.Lib.Attachment.create(contents : null, name : targetFile, description : "test"); accepts contents only in Binary format? xmpMetaData of the PDFStamper although in Binary format is ready only? So we cannot put it in the contents field of Fuego.Lib.Attachment.create(contents : null, name : targetFile, description : "test"); ?

                            So what should we put?

                            Even mailAttachments.extend(source : null, fileName : "test.pdf") requires source as Binary Contents. How we do this??
                            One approach is to put the binary for the PDF files in a database. If you have a content management system, use that to store the files.

                            Dan
                            • 11. Re: OOTB PDF generation
                              719471
                              Do you have any examples on this?


                              Also I created a table in word with two columns and one row. I Saved it As a PDF file . In column I put customerName and the other column was blank.

                              I then used this as a template file and used your code to pass arguments to form.setField("customerName"), making the value to be "testName" for the key "customerName".

                              The target PDF file was created but it did not show the value for the key customerName in the PDF document.

                              How do we make it show that value for every key?

                              Does it have to be a table?

                              Or how do specify the key in the template PDF document so that it can be identified by the code?

                              Is it a table or some other way?
                              • 12. Re: OOTB PDF generation
                                Daniel Atwood
                                Here's sample logic to invoke it (this assumes that you have defined two fields labeled "customerName" and "customerNameLabel"):
                                hashMap as Any[String]
                                 
                                hashMap["customerName"] = clientCase.clientName 
                                hashMap["customerNameLabel"] = "Customer Name"
                                
                                docName as String
                                docDirectory as String
                                
                                docName = "Test document.pdf"
                                docDirectory = "c:/temp/"
                                
                                generate(Integration.Jacket.Jacket, templateFile : docDirectory + docName, 
                                                    targetFile : docDirectory + "Generated_" + clientCase.clientName + "_" + docName, 
                                                    hashMap : hashMap)
                                end
                                This logic assumes that you put the PDF in the c:\temp directory and that you have a variable named "clientCase" that is a BPM Object and this BPM Object has a "clientName" attribute. This variable needs to be populated with text before this logic is invoked.

                                I uploaded a PDF template file that this could use. It has the two fields "customerName" and "customerNameLabel". Go to this link to download this template PDF http://www.4shared.com/document/irDl_Pgx/Test_document.html

                                Dan
                                • 13. Re: OOTB PDF generation
                                  719471
                                  Thanks Dan..
                                  • 14. Re: OOTB PDF generation
                                    719471
                                    Hi Dan,
                                    What did you use to create the sample PDF document?

                                    Did you create it in word and then saved it as a PDF document?

                                    If so, how did you create the two fields?

                                    "customerName" and "customerNameLabel" in the PDF document?

                                    Are both these text fields?
                                    1 2 Previous Next