1. Daniel Vivier
  2. PowerBuilder
  3. Tuesday, 29 June 2021 19:43 PM UTC

There's an enhancement request somewhere to add the capability for the NativePDF saving of DataWindows to append their output to an existing PDF.

In the meantime, I really wanted that ability, so users of our software could put multiple reports into one PDF without using external tools.

My solution has our program including and using an external open source tool, QPDF, so the user doesn't have to! you get it from https://sourceforge.net/projects/qpdf/.

QPDF can actually do a bunch of things with PDF files, either via a command-line, or via a C++ library (which also apparently also has at least a partial C implementation, which I guess thus might be callable from PB). But I just use the command line.

The command line to append file2.pdf to file1.pdf is:

qpdf "file1.pdf" --pages . "file2.pdf" -- --replace-input

You don't need the quotes unless there are (or might be!) spaces in the filenames. It can also append multiple files together, pick only selected pages, and a ton of other things. You can see the manual online for more details.

The part of it that I need to deploy with my program is a bit over 4MB, which isn't bad.

Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 7 July 2021 17:15 PM UTC
  2. PowerBuilder
  3. # 1

It can be done with Ghostscript. I have an example:

https://www.topwizprogramming.com/freecode_ghostscript.html

 

Comment
There are no comments made yet.
ilya Milin Accepted Answer Pending Moderation
  1. Wednesday, 7 July 2021 15:38 PM UTC
  2. PowerBuilder
  3. # 2

Guys,

We still have unresolved issue with printing PostScript file to PDF.

Below lines of code create PostScript file(run_batch.ps). How do we send this ps file to be printed by

'Microsoft Print to PDF' from PowerBuilder code.


ps_job_file_name = is_work_dir+'\' + "run_batch.ps"

li_file_handle = FileOpen ( ps_job_file_name ,LineMode! , Write! , LockReadWrite! , Replace!)

li_ret = FileWrite(li_file_handle, ps_job_file)
li_ret = FileClose(li_file_handle)

Thanks you,

Ilya Milin

 

Comment
  1. Daniel Vivier
  2. Wednesday, 7 July 2021 15:47 PM UTC
Ilya, I believe this is entirely unrelated to my original post here. I think you should post it as a new topic. (And sorry, I know nothing about your question!)
  1. Helpful
  1. ilya Milin
  2. Wednesday, 7 July 2021 18:06 PM UTC
Dan, my apology for the unintentional hijack your post.

I accidentally post it in the wrong thread.



Ilya Milin
  1. Helpful
There are no comments made yet.
Bruce Armstrong Accepted Answer Pending Moderation
  1. Wednesday, 30 June 2021 17:15 PM UTC
  2. PowerBuilder
  3. # 3

Not sure if you saw this:

https://community.appeon.com/index.php/codeexchange/powerbuilder/286-pdfutils

Comment
  1. Daniel Vivier
  2. Wednesday, 30 June 2021 17:34 PM UTC
Thanks Bruce. Since we do have landscape-mode reports, I guess we'd have to use the PDFSharp solution (that's the right name, right - not SharpPDF?). But since we already have a working solution I don't think we will be changing it. We also use QPDF to encrypt some PDFs we generate from HTML in a WebBrowser control, saved to PDF with a headless Chrome command line, with user or owner passwords.
  1. Helpful
  1. Bruce Armstrong
  2. Wednesday, 30 June 2021 17:53 PM UTC
There are libraries with both names ( PDFSharp and sharpPDF). I believe I'm using PDFSharp http://www.pdfsharp.com/PDFsharp/



Like PoDoFo it's a full features PDF library, I just exposed the concatenation for now. Have seen a request for adding split and sign to the wrapper. Sign looks pretty complicated though. Will have to wait until I have some free time, and that's pretty rare right now.





  1. Helpful
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 29 June 2021 22:07 PM UTC
  2. PowerBuilder
  3. # 4

Thanks for this great info, Dan!

 

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 29 June 2021 20:00 PM UTC
  2. PowerBuilder
  3. # 5

Hi Dan;

  Thank you for that information! Yes, converting, splitting or merging PDF's has been a long time requirement for many PB Apps and yes, there is an enhancement request for that in the Appeon System.

   FWIW: I have been using the free PDF Tool Kit for this functionality for over 2 decades now.It works great and it's super fast. Also a good tool is the free ImageMagicK software. It can convert PDF's into images and vise versa.  ;-)

FYI: http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit

Regards ... Chris

Comment
  1. Daniel Vivier
  2. Tuesday, 29 June 2021 20:17 PM UTC
Thanks, Chris. However, unlike QPDF which is open source, "A commercial license is required to distribute PDFtk with your commercial product." That would be an issue for us.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Tuesday, 29 June 2021 22:51 PM UTC
FYI: There are two versions ...

1) Free (no distribution restrictions)

2) PRO which is a paid version (licensing required).

$3.99 though ... LOL!
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 29 June 2021 19:54 PM UTC
  2. PowerBuilder
  3. # 6

Thanks for sharing this solution!

Comment
  1. ilya Milin
  2. Wednesday, 30 June 2021 19:59 PM UTC
Guys,

Is there a solution to use already created Postscript file in PB script(trying not to touch much the existing business logic) to PDF file without the Distill.

Note:

a) PB-2017 R3, Windows10/Windows Server 2016

b) The output PDF file could be distributed



Thank you,

Ilya
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.