Example Code

PDF Report with ItextSharp

Code and Documents

Attachment

Exaprom PDF 2.0

 

LV2009 and  LV 2013 w/.net 4.0

 

After unzipping "Exaprom PDF2.0 (2009).ZIP" (or "Exaprom PDF2.0 (2013).ZIP"), you have a folder and a file:

1) the folder "Exaprom PDF";

2) and the file "exaprompdf.mnu".

Unzip ExapromPDF 2.jpg

 

The folder "Exaprom PDF" has to be place in:

C:\Program Files\National Instruments\LabVIEW Version\vi.lib\

Folder programming.jpg

The file "exaprompdf.mnu" have to be place in:

C:\Program Files\National Instruments\LabVIEW Version\menus\Categories\Programming\

Folder menu.jpg

 

After restart LabVIEW, the palette "Exaprom PDF 2.0" will appears.

Palette Exaprom.jpg

Note: Replace "Exaprom PDF\VIs\Low level\Table Low level\Create Paragraph for Cell.vi" in "Exaprom PDF2.0 (LV2013).zip" with the new "Create Paragraph for Cell.vi" (LV2013).

 

 

For Windows 7-64 bits with LV2013right-click the assembly and click Unblock on the General tab to grant an assembly full trust.

Unblock assembly.png

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Member
Member
on

Perfect!!

I was looking for a better then the standard labview tools for generating a report. I don't like classes (good for text but I still fail to see the benifit for using them in G), they support only HTML (which has no pages) and MS-office (which I don't see as a way forward).

This tool worked first time after extracting and placing in correct folder. Some language difficulties but the example build a very extensive PDF document of 19 pages with links, images, page formatting, logo's and all the stuff you can dream of.

Active Participant
Active Participant
on

If the built application is running from a from a Network Drive take a look at:  Running LabVIEW VIs or Executables That Use .NET Assemblies From a Network Drive .

For the built application:

“Properties>>Source Files>>Always included” add “itextsharp.dll”

(located at C:\Program Files\National Instruments\LabVIEW XXXX\user.lib\Exaprom PDF\DLL\ itextsharp.dll).

Jean-Marc

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Active Participant
Active Participant
on

Exaprom PDF 1.0 is a new version of the toolkit.

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

Splendid,
I just started to write my code with your library and it's pure happiness with so many options and exhaustive documentation (et en français pour ne rien gâcher ).

Furthermore, is there a way to add a row header (1D string) to the VIs "create & append table", like the "Append Text Table to Report.vi" from Function palette/Report Generation ?
There are lots of properties and methods for "PdfPTable" Refnum but I do not see how to implement.. any idea.. ?

Thank you again for sharing

Active Participant
Active Participant
on

You could add the row header in the first column of the "Table data 2D" (Create Table.vi). If it is because you want to split the table vertically and repeat the row header on each new page, I verified this morning, and I didn't find an easy way to do that. This is feasible, but it is a lot of work.

JM

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

Are there istructions on how to install it? I copied it to my user.lib folder as mentioned above, but the funtion pallets apear as blancks.

Thanks for the tookit, by the way !

Jose

Active Participant
Active Participant
on

Sorry,

Rename the folder "Exaprom PDF 1.0" with the name "Exaprom PDF".

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

Its small program with that toolpack. Try to add couple of headers into one file... Efect is terrible.

Active Participant
Active Participant
on

Could you give me a little more details? Do you try to add more than three headers in a PDF Report?

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

I will explain,but plese tell me how can I add atachments? Those are subvi adn pdf results file.

"Could you give me a little more details? Do you try to add more than three headers in a PDF Report?"

I didnt, I want to add 2 only,and in that is problem.

Active Participant
Active Participant
on

You have to open a knew thread in the LabVIEW forum:

http://forums.ni.com/t5/LabVIEW/bd-p/170

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on
Member
Member
on

Hi,

Just to let everybody know, using ITextSharp (or products using it) is not free per se.

The license (which you have to mention and include when you distribute it) can be found here:

http://itextpdf.com/terms-of-use/

ITextSharp is a .net version of IText, and uses the same licensing schema.

It mentions:

"Buying such a license is mandatory as soon as you develop commercial activities distributing the iText software inside your product or deploying it on a network without disclosing the source code of your own applications under the AGPL license. These activities include: offering paid services to customers as an ASP, serving PDFs on the fly in the cloud or in a web application, shipping iText with a closed source product."

So if you ship your Exaprom application to a customer, you'll have to share your code with the world. Or buy a license. You should at least ask a lawyer (or buy a license).

Regards,

Wiebe.

Active Participant
Active Participant
on

wiebe@CARYA, maybe I am wrong and you could corrrect me.

The link you gave is for the newer versions of iText or iTextSharp (version 5.X) and the license is under the Affero General Public License.

The license of iTextSharp 4.1.6 is Mozilla Public License Version 1.1.

In the FAQ for Mozilla Public License Version 1.1:

How 'viral' is the MPL? If I use MPLed code in my proprietary application, will I have to give all the source code away?


The MPL has a limited amount of 'copyleft' - more copyleft than the BSD family of licenses, which have no copyleft at all, but less than the LGPL or the GPL. It is based around the definition of a 'Modification' in the license [1.9].

What is a Modification? Any changes to MPLed files, or new files into which MPLed code has been copied, are Modifications and so fall under the MPL. New files containing only your code are not Modifications, and not covered by the MPL.

Files which fall under the MPL because they are or contain Modifications must be made available as detailed in the license (or elsewhere in this FAQ.) Other files may be kept proprietary.

One well-known example of this is the Netscape-branded browser. It contains (and Netscape makes source code available for) many files from the Mozilla project, which are under the MPL. But it also contains proprietary code, for example to integrate with the AOL Instant Messenger service.

1.9. "Modifications"

means any addition to or deletion from the substance or structure of either the Original Code or any previous Modifications. When Covered Code is released as a series of files, a Modification is:

  1. Any addition to or deletion from the contents of a file containing Original Code or previous Modifications.
  2. Any new file that contains any part of the Original Code or previous Modifications.

I did not make any modification in the original code of iTextSharp 4.1.6.

Finally, Bruno Lowagie, one of the creator of iText, wrote in his blog (June 6, 2012):

You currently have iText 2.1.7 and older versions available on SourceForge. While those versions were available under MPL or LGPL, it has come to our attention that some of the code (which has been removed in the 5.0+ versions), cannot be verified as free of possible copyright violations. You took great steps to go through the entire code base and obtain general releases for all code when moving from the LGPL/MPL version to the AGPL version. There is code in older versions (that no longer exists in version 5.0) which could pose indemnity problems for organizations. This is for your information only, we are not directly aware of any situation, only aware of the possibility since no waivers could be obtained from the organization(s) and individual(s) who contributed the code and the actual source of this code could not be identified.

Note:  iText 2.1.7 (Java) = iTextSharp 4.1.6 (C#)

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

J-M,

I did not check if the older version uses a different license, but if you say so I believe it.

But the quote from Bruno Lowagie seems to me like an argument to not use old versions (older then 5.0), because these versions "cannot be verified as free of possible copyright violations", and that these versions "could pose indemnity problems for organizations".

I understand you're not too worried about this, since they are "not aware of any situations". It seems like a valid warning to me.

Regards.

Wiebe.

Member
Member
on

Great to have such a large pdf tool shared!

Member
Member
on

Hi every body,

Please Help me, how can I take the first item (page) of tab control reference using Append Control Image.

The Append Control Image.vi usually create the Image of the last Item !!!!


Another question, how can I create the Image of a control without its label. 

Best regards,

Jaouher.

Member
Member
on

A question regarding table formatting: Is it possible by the Exaprom tool to have different formats per cell of one table? e.g. the first row, which is often also a kind of a title row with wider size, or then to have all diagonal values in bold? Thanks for any help!

To Djoo89: I don't understand the relation between a tab control reference and a pdf creation tool?

Member
Member
on

Hi everyone,

Is it possible to read the contents of a pdf file using ItextSharp?

Active Participant
Active Participant
on

Not easy with iTextSharp but maybe with PDFBox (jcarmody).

https://forums.ni.com/t5/LabVIEW/read-text-from-pdf/m-p/2585419/highlight/true#M778081 

I tried with one PDF file and it is working.

Don't forget to give him a kudo (to jcarmody)!!!

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

When I use this to generate a PDF, the output resolution of graphics is low, leaving me with pixelated images on my PDF file. Any suggestions?

Active Participant
Active Participant
on

For the image of a control I utilize the invoke node getimage.

Take a look at:

http://forums.ni.com/t5/LabVIEW/Method-Get-Image-resolution/m-p/1305404/highlight/true#M537385

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

I should have given more explanation.... I am wanting to capture a front panel image that includes multiple waveforms set up as a report page. When I print this front panel using Adobe Acrobat, the resolution is high and my waverforms show lots of detail. However, when I use the Exaprom PDF VI called "Append Front Panel Image", the PDF generated is very pixelated and at a low resolution, leaving it unsuitable for publishing in our final report. Looking at the VI, it is using the "FP.Get Image" Invoke node as per the link above. Perhaps I will just have to make a larger front panel image and scale it down.......

Member
Member
on

SUCCESS, I think! 

If you go into the Exaprom "Append Front Panel Image" VI, and change the method from "FP.Get Image" to "FP.Get Image Scaled", you can then increase the MAX WIDTH and MAX HEIGHT properties to large numbers which then effectively increases the output resolution of the PDF created.

Member
Member
on

First, thanks for sharing this great PDF generating method with us. I once used iTextsharp to create PDF and created PDF is over 50M and when I opened and save it with Adobe, the file size is reduced to 10M. Hope this method will not cause such problem.

Active Participant
Active Participant
on

This tool is great, however, the problem I'm having is that it's dependent on the old .Net 2.0 framework.

Is there a newer version which is compatible with .Net 4??

Active Participant
Active Participant
on

I am surprised. I done some test a couple weeks ago. The computer has only .Net 3.5 framework, and I had no problem.  What kind of problem do you have?

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

I posted a .net 4.0 version. I think the problem mainly has to do with Labview 2013's defaulting to the CLR 4.0, where as all previous versions defaulted to .net 2.0, it has nothing to do with the VI's but he .net DLL being built to the .net 2.0 runtime. Labview seems to have a bit of a mixup when using 2.0 dlls (sometimes). I simply rebuilt the dll to the 4.0 runtime and things seem to be happy.

You can find more information here:

http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/configuring_clr_version/

Member
Member
on

hello, thanks for the great toolkit!

Is it possible to include a xy graph as a vector graphic? Do you know any workaround?

thanks.

Active Participant
Active Participant
on

The only "image vector graphic", as far as I know, that iTextSharp supports is WMF.  The VI  "Append Image File.vi" is suppose to accept WMF, but I never test this file format.  This is the reason that WMF is not in the valid format list (Valid formats: GIF, JPEG, PNG and BMP).

The problem is that I have no idea how to generate a WMF image from a XY Graph in LabVIEW...

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

Graphs and charts have a method to export it's image. You should be able to export it as EMF (export it as simplified image). This does the same as right clicking the image, and exporting it as simplified image. But with the method, you can do it without user interaction.

This will get you an EMF. But sadly, it won't do you much good. The exported image is simply a bitmap embedded in a EMF.

Regards.

Wiebe.

Member
Member
on

thank you very much

excellant quality

Member
Member
on

LabVIEW 32 bit installed on windows 7 64 bit. In this combination itextsharp doesn't work  error 1386

LabVIEW 32 installed on Windows 7 - 32 has no problem. What can be solution for this?

And BTW, I agree - exellent tools and exelent quality!

Member
Member
on

Solved! Thanks to J-M

right-click the assembly and click Unblock

Member
Member
on

This is a great library!  Can someone post an example of how you might use it to modify an existing document?  For example, add a watermark to a PDF you inherit from other processes (not generated by your test).

CLA, CTA
Not my tempo... AGAIN!
Active Participant
Active Participant
on

The only easy modifications that you could do (with iTextSharp) on an existing PDF file is to add a header, a footer and a watermark.  If you want to do other modifications, it is a lot of work!

If this is the kind of modifications you have in mind, start a new thread in the LabVIEW forum and I will guide you.

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Active Participant
Active Participant
on
Member
Member
on

I use Print PDF.vi , but how to set printer and number of copys when I want to Print?
(Like Print Report.vi)

Thanks

Active Participant
Active Participant
on

You could set the default printer:

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

If you want a dialog popup:

Print with dialog.png

You could just repeat "PrintAll" for the number of copy you want.

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Active Participant
Active Participant
on

Hello J-M,

Is it possible to create one table and use 'Absolute position (x,y)' to show the table on page where you want position?. Or add 'box text' with the option to fix the box in one point (x,y).

When I add any picture I can do it. I use absolute position to fix the position of picture in pages. I think it would be good do it too for tables.

Another question is about pictures. Labview can export images in eps, ems extension. Vectorial images would be the best way to go. But I believe it is no possible to use this image type in Exaprom. What do you think is the best way to export or get image from LV to input in Exaprom?.

I read in other post You speak about wmf, but LV seems no use this extension to get image.

Best Regards, Fred.

Active Participant
Active Participant
on

Question 1 (table with absolute position)

The short answer is yes, but with a lot of work.  You could take a look at "C:\Program Files (x86)\National Instruments\LabVIEW 201X\vi.lib\Exaprom PDF\VIs\Low level\Header, Footer and Watermark Low level\Header or Footer.vi"

Question 2 (Vector image formats)

VMF is the only vector image format supported.

This question is about this?

http://forums.ni.com/t5/LabVIEW/Get-image-several-indicators-help/m-p/3118002#M894910

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Active Participant
Active Participant
on

Thanks J-M,

question 1. Thanks it is difficult to do. I create one table in FP and use reference control to  append like picture.

question 2. No, it is for general way to append good  quality images in file. In the link I solved it doing like I put in the thread.

Regards.

Proven Zealot Proven Zealot
Proven Zealot
on

I think I found a bug.  I was upgrading from 1.0 to 2.0 and I found my table formatting was lost.  Looking in the Write Table Predefined infos.vi file I saw that the Predefined Borders information is never passed into predefined to Cell row [ ].vi  After fixing this formatted tables worked again.

Active Participant
Active Participant
on

Yes, it is a bug.  I am afraid that will not be the only one...

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on

Hello J-M,

thanks for sharing your very useful code.

I'm using the Exaprom PDF2.0 (2009)  in LabView 2011, in my country the comma is the decimal separator and the line spacing 1.5 is ignored!

The bug can be solved by setting FALSE the input 'use system decimal point' of the 'Fract/Exp String To Number Function'.

The affected function is located in the following VIs:

  'Default or Users Font, Leading and Alignment.vi' and

  'Header Footer Transform Header Footer [ ] V3.vi'

The solution is compatible also if the dot is the decimal separator.

Regards,

Asper

Member
Member
on

Dear J-M,

probability a small bug Inside the table, the line spacing (1, 1.5, 2.0) is not respected for ASCII text. The line spacing is always 1 independently from the selection.

The bug is in the "Create Paragraph for Cell.vi", for the ASCII case, the property Leading of the Paragraph is connected to the font size instead of the Leading value.

By connecting correctly the property the bug is solved.

Regards,

Asper

Member
Member
on

Dear J-M,

could you post an example how to span a cell on an entire row in the table body with the function "Append Customized Table.vi."

I have tried several time but i was unsuccessful! ... 😞

The table should result as:

__________

| __|__|__|__|

| __|__|__|__|

|__________|

| __|__|__|__|

Please for the example use the 2009 version.

Thanks,

Asper

Active Participant
Active Participant
on

Asper,

I made an example, but I can't post it here.  Start a new thread in the LabVIEW forum and I will post the example there.

Jean-Marc
LV2009 and LV2013
Free PDF Report with iTextSharp
Member
Member
on
Member
Member
on

Dear J-M,

How to print two controls on top of each other? I have waveform chart and transparent XY Graph on top with same parameters, so. I'm using XY Graph's cursors to measure time in Chart. And I'd like to print them both on top each other. Print the entire front panel is not the option. Thank you

Contributors