LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenate PDF files with Exaprom iTextSharp

1st Hats off the the folks at Exaprom. Thanks for this wonderful utility/toolkit.

 

I want to merge several PDF files into a single file along with some standard text files. Using the iTextSharp tools from Exaprom found here is very easy. The workflow is

  1. Create new PDF
  2. add content
  3. close PDF

I am assuming that I need to use some kind of openfile method to get the file I want to merge with my created file. Looking at the web it seems that pdf forms can have additional complecations using iTextSharp.

 

I have used pdftk in the past but it seems kinda clunky to me.

 

Any help will be appriciated.

0 Kudos
Message 1 of 25
(10,565 Views)

Hi Viper,

 

Since the toolkit you are referring to was not developed by NI I am not very familiar with the functionality of the VIs. After taking a look through the documentation it looks like in order to use those VIs to merge PDF files and text files you will need to first create a new PDF, read from the existing PDFs and text files that you want to merge and use the data that was read as an input to the append VI included in the iTextSharp package. The problem is that there is currently no function or VI that will specifically read from PDF. The easiest route to take in this case is probably to convert the PDFs that you want to merge to text files or HTML files, then read and input the data into the append VI. I have included some examples for reading from text and HTML files into string indicators in LabVIEW. 

 

https://decibel.ni.com/content/docs/DOC-16813

 

https://decibel.ni.com/content/docs/DOC-10662

 

https://decibel.ni.com/content/docs/DOC-3709

 

There are also other PDF toolkits that you could look in to: http://sine.ni.com/nips/cds/view/p/lang/en/nid/209030

 

I hope this helps.

 

Regards,

 

James D.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 25
(10,535 Views)

First, put the file “Concatenate PDF LV2009.vi” in this folder:

...\Exaprom PDF\VIs\Document\

 

Open this file and if you have no error,  then all “.NET constructor” are still linked with “itextsharp(4.1.6.0)”.  In this case, just try the VI.

 

If not, you will have to link all “.NET constructor” with the library itextsharp(4.1.6.0)”.  I think you will not have this problem, but on my computer, I have a new version of “Exaprom PDF”.

 

You must convert your standard text files into PDF files. After that, concatenate the PDF files. I have concatenated five PDF files (total of 53 pages) with two paper orientations and two page formats (letter and A4) and for this test, it is working, but it is not intensively tested.

Message 3 of 25
(10,522 Views)

J-M it works great as a stand alone. It even handles my fillable forms. Now I'm trying to mod it to fit in with the rest of the toolkit. Please see my 1st lame attempt.

 

Norm

0 Kudos
Message 4 of 25
(10,471 Views)

Could you save the file in LV2009 format?  I will take a look. 

 

Like I said, I have a knew version of the library Exaprom PDF, and I don't have the time right know to remove my actual version and  reinstall the old one.  I could take a look, but I will not be able to test your VI.  The major modifications in the new version are: 

 

- I changed the variable type of "PDF Report" ( LV Class instead Xcontrol);

- I modified the tables for more flexibility (merging cells per example).

 

The reason I didn't post this new version is because it is really not intuitive.

 

JM

0 Kudos
Message 5 of 25
(10,463 Views)

Copied as LV 9.0

0 Kudos
Message 6 of 25
(10,453 Views)

It is impossible  to use PDFCopy to add content in a PDF file if this file is not empty when we start to concatenate.  That's why I provided a standalone VI.

 

I dug a little bit, and I see two possible solutions.

 

The first one is to copy, in the PDF Report, the PDF file you want to add as an image (for each page).  This is the easiest way. “The major downside: All interactive features (annotations, bookmarks, fields, and so forth) of the imported page are lost in the process.”

 

The second one is to create the PDF Report and to keep the track of each position in the document, where we want to concatenate those PDF files. Before we add the header and the footer, we will concatenate all those files with PDFcopy like in the standalone VI (the PDF Report and the files to concatenate). This is a more elegant way, but it will take several days of work.  I think it could be a good add-on in Exaprom PDF, but I don’t have actually the time to do this.

0 Kudos
Message 7 of 25
(10,425 Views)

How would I go about adding headers and footers to this new multi file document. I'll skip page numbering the individual files  and number the pages after they all have been joined.

 

Thanks,

 

Norm

0 Kudos
Message 8 of 25
(9,895 Views)

Yeah I'm also curious to know if there is a good solution to the page numbering issue.

 

So if I have a PDF that has Page 1 of 10 in the footer, and then a new PDF that has Page 1 of 5 in the footer.  When I concatenate them it would be nice if the first page was then Page 1 of 15.  An alternative could be editing the PDF pages updating the number the concatenate but that also seems quite difficult.  Any thoughts?

0 Kudos
Message 9 of 25
(9,600 Views)

There is no direct and easy way to do this with iTextSharp:

1) Editing the PDF File will be a huge work.

2)  It will be easier to write a new page number over the concatenated PDF.
          i) The page number with this library is add in the footer.
          ii) The footer is a table of one line and one to three columns.
          iii) Actually, the background color of this table is transparent.
          iv)  It is possible to set this color to white and add a new page number over the old one.
          v)   What you will have at the end is a PDF file with the new page number (in a white cell)  over the old page number.

3) Actually the page numbering in the library Exaprom PDF is add over an existing PDF file.

If you take the option 2, it is still a lot of work.

0 Kudos
Message 10 of 25
(9,596 Views)