ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Merge 2 PDFs on IFS

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

  • Merge 2 PDFs on IFS

    Hello,

    is there iSeries command or a good way to combine 2 PDFs on IFS into one PDF file?
    use open() API possible? or other way any idea would be appreciated. thanks
    (no PC tools here, clients like to generate 2 PDFs in one shot from IBM i)

  • #2
    I do it DIY with Java using the PDFBox library.

    Comment


    • #3
      thanks jtaylor. we are using RPGle code. the client demand is generate one file straight from green screen.
      i will look into open() write() to see if I can find anything.

      Comment


      • #4
        Using open(), read(), write(), etc will let you access the data inside the PDF files. But, what will you do with that data? Do you know how to merge the data from two different PDF documents together? Do you know how to interpret the bytes in the file, breaking them into headers, pages, sections, footer, etc? Do you know how to re-do the table of contents in the document index so that it is merged properly? If you do, you can use write() to write it back out again.

        Seems to me that reading/writing the data isn't the problem. Its understanding how to change the PDF that is the hard part.

        Comment


        • #5
          I don't think you'll get very far just trying to slam together multiple PDF files using IFS APIs.

          We're doing the PDF merge from RPGLE, which calls the Java procedures (RPGLE allows Java methods to be prototyped like you do with ILE *SRVPGM). It can be done from RPGLE/5250, but you do need some Java skills however.

          Comment


          • #6
            A quick Google search found some examples of merging PDFs with GhostScript, too. I know that's available in YUM, so could be called from an RPG program. Have tried it, myself.

            Comment


            • #7
              Originally posted by Scott Klement View Post
              Using open(), read(), write(), etc will let you access the data inside the PDF files. But, what will you do with that data? Do you know how to merge the data from two different PDF documents together? Do you know how to interpret the bytes in the file, breaking them into headers, pages, sections, footer, etc? Do you know how to re-do the table of contents in the document index so that it is merged properly? If you do, you can use write() to write it back out again.

              Seems to me that reading/writing the data isn't the problem. Its understanding how to change the PDF that is the hard part.
              great insight, yeah I did thought about this and tried last night, tried to figure it out how interpret PDF in () byte and perhaps manipulate there if I figure how 2 pages exact structured.(this way Open() read() Write() would help)
              I used PC tool to create file1 (1 page of PDF), file 2 (merge 2 pages PDF, exact same page with file1 page), then encode them to base64, then to text to see how they structured.
              I saw obj<</Filter as the starting of the page, it also inculdes producer PDFill info. I think to figure it out is not really pain here, what I am more concern is when I try another set of samples (another 2 PDF files, one is 1 page, another is 2 pages) from other source, then the metadata tag is different, I saw /Type /Page as the staring of the page.

              back to my client requirement, I think 1 PDF we get if from third party source(like cover letter), another PDF is supposed to be generated from IBMi, then my goal is to put 2 together into one PDF. so the realistic concern is the meta data tags between the two could be different, even if I figure it out my set of sample, still could run into the issue when PDF format or source is different. so looks this way is hard way to go.
              thanks Scott.

              Comment


              • #8
                Originally posted by jtaylor___ View Post
                I don't think you'll get very far just trying to slam together multiple PDF files using IFS APIs.

                We're doing the PDF merge from RPGLE, which calls the Java procedures (RPGLE allows Java methods to be prototyped like you do with ILE *SRVPGM). It can be done from RPGLE/5250, but you do need some Java skills however.
                this seems a close approach, I haven't tried prototyped Java methods but I would like to try this time, had some Java experience 12 years ago, could pick it up if i really need to, lol. I will search PDFBox library. thank you.

                Comment


                • #9
                  Originally posted by Scott Klement View Post
                  A quick Google search found some examples of merging PDFs with GhostScript, too. I know that's available in YUM, so could be called from an RPG program. Have tried it, myself.
                  that's exciting news, wow, I need to figure out call GhostScript from RPG program, is there any special requirement for that?

                  Comment

                  Working...
                  X