PDF From a Table (again...)

This has definately been done before but I cant lay hands on the threads that show this well.

I have a series of PDF’s that are saved in a temp location. I have all those PDF’s (full path) in an array and am using

fjpd_saved_pdf = plugins.pdf_output.combinePDFDocuments(vPDFArray)
``` to combine the PDFs into one PDF.

Q 1. How do I name that Combined PDF?
Q 2. Is that the correct syntax for inserting into a column (column name is fjpd_saved_pdf)
Q 3. What code can I use to open the saved contents of the column (the PDF)?

BTW the column is set as 'image' in SQL Server and appears as media in Servoy table view.

Appreciate any feedback - this looks like a black art to me <img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" />

EDIT : Discovered this one from Laurian :

> each element of the array should be of type byte[] , so not the path but the content

So the question is - from the PDF's stored in the temp location - how can I convert them to the byte type for the array?
EDIT: I've now added a converter to the column where this is stored as a BlobSerializer. I believe this will convert anything stored there to byte and unconvert it when read. Using app.output on that column afeter storing the array I get % PDF-1.4 not sure if this is actually a file or something else though.

Hi Ian,

because a little sample solution is better than a long speech, - especially when it comes to black art :lol:

Try this one (with a db server called ‘pdfs’):
[attachment=0]MergePDF.servoy[/attachment]

Actually what is not very nice with the current implementation of the pdf_output plugin, is that if forces you to load entire PDF data as byte in memory… so be careful with big pdfs… don’t try that with high resolution files, otherwise your client will probably crash with an out of memory exception!

Hope this helps

MergePDF.servoy (69.7 KB)

Better solution is to use the free PDF Pro plugin. it allows you to merge, compress, encrypt, watermark, etc. And it uses files on the filesystem instead of byte. http://servoyguy.com/servoy_components/pdf_pro_plugin

Thanks Guys

Patrick - I’m building a Jb pack system that will combine 10 -12 separate documents - some of which will be 300 - 400 pages in size. I had’nt realised the Servoy implementation would cause the memory constraint.

Scott, I’ll give it a go with your Pro Plugin and see where I get to with it - but sounds like a better solution for this application.

Thanks for the feedback again Folks - appreciated.

Kahuna:
will combine 10 -12 separate documents - some of which will be 300 - 400 pages in size.

Will clients be accessing your solution locally or over the internet? If over the internet you may also need to consider the size of the combined PDF file that you are creating. Will the combined PDF file only contain text? Will there be a form image on each PDF page. If so, will the form image be the same for all pages? If so, it is possible to set the form image only once to the “background” of the combined PDF file. That way instead of saving the form image 4,000 times you can save it only once in the PDF file, dramatically reducing the PDF file size.

We had a similar situation, with a webclient solution, where we ended up having to move the “combine” operation to the local hard drive. When you combine hundreds of pages into one PDF file it can be very time consuming.

Dean Westover
Choices Software, Inc.

Westy:

Kahuna:
will combine 10 -12 separate documents - some of which will be 300 - 400 pages in size.

Will clients be accessing your solution locally or over the internet? If over the internet you may also need to consider the size of the combined PDF file that you are creating. Will the combined PDF file only contain text? Will there be a form image on each PDF page. If so, will the form image be the same for all pages? If so, it is possible to set the form image only once to the “background” of the combined PDF file. That way instead of saving the form image 4,000 times you can save it only once in the PDF file, dramatically reducing the PDF file size.

We had a similar situation, with a webclient solution, where we ended up having to move the “combine” operation to the local hard drive. When you combine hundreds of pages into one PDF file it can be very time consuming.

Dean Westover
Choices Software, Inc.

Hi Dean and thanks for the feedback.

There will be some clients who access the PDF over the internet - though through the SC, and unfortunately the form image will be different on many of the sections of the PDF. There is one report that may have many pages that have the same layout and that one may have 1 or more images on it too.

I am intending to give the user the opportunity to save the PDF to a local file source now as well as the chance to save it to a Db column and I’ll probably warn them about the ramifications of saving to the Db and accessing later!

Cheers