Example Code

PDF Report with ItextSharp

Community Verified
by: Knight of NI JÞB

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

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

Comments
beuvink
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.

---

25+ years long fan of LabVIEW. Move to Emerson looks to be for the better! See the last posts in subscription model thread.
Fred_A
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

Jose_Perez
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

J-M
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?

Marcin Gajewski
Member
Member
on
Wiebe@CARYA
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.

Wiebe@CARYA
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.

DavidZ.
Member
Member
on

Great to have such a large pdf tool shared!

DavidZ.
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?

bhalaji10
Member
Member
on

Hi everyone,

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

J-M
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

tca-adam
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.

J-M
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...

Wiebe@CARYA
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.

motima
Member
Member
on

thank you very much

excellant quality

taras_33
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!

GarryG
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!
Hank79
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

Fonsi
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.

J-M
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

Fonsi
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.

J-M
Active Participant
Active Participant
on

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

asper
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

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

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

J-M
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.

asper
Member
Member
on
Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

You won't be able to do this the same way you are in LabVIEW.  When you get an image of a control, LabVIEW has no way of returning it with any transparency layer.  The closes LabVIEW has is a mask which can ignore pixels, which can be seen as a way of setting opacity to 0 or 100%. 

What you will probably want to do is take the image of your front panel using the VI Server call to the invoke node Front Panel >> Get Image, then crop the image to the part of the front panel you want, then insert that image into the PDF instead of trying to insert the two controls.

taras_33
Member
Member
on

I think you're right, because  when i get image of "transparent" XY Graph with cursors, it has white background, not transparent.

Ok then how to crop the image using LabVIEW?

taras_33
Member
Member
on
Ok then how to crop the image using LabVIEW?

Solved.

Cedric51
Member
Member
on

hi J-M,

First, I want to thank you for sharing this very nice toolbox!

I want to place two images (or tables) side by side. What are the possible solutions?

thank you

Cedric

J-M
Active Participant
Active Participant
on

You could place the two images in a table of one row and two columns. 

You could also use Right or Left (TextWrap) to place two images side by side.  The downside is: you couldn't use the automatic numbering for legend (works only for centered image).

For two tables, the only way i see is to use one table to mimic two tables.

J-M
Active Participant
Active Participant
on

Je vous en prie.

donkdonk
Member
Member
on

Seems a very nice toolset. However I have difficulties installing it in LabVIEW 2015.

When installing Exaprom PDF2.0 (LV2013).zip according to the procedure I get all the vi's in the programming pallette, but when I try a simple vi to make a pdf, an error occurs and it seems a .NET related issue.

When viewing the .NET Assemblies in Memory, it is stated that "LabVIEW is using CLR version 4.0.30319.42000 to load .NET assemblies".

Then I saw you also have a .NET 4.0 version . However, when installing this, in the same manner as the other version, things don't go smoothly: a) LabVIEW somehow now expects a lot of vis in the user.lib in stead of vi.lib and b) at least the footer header vi has errors and refuses to run .

What is the correct installing procedure when using .NET 4 (assuming .NET is the culprit)?

J-M
Active Participant
Active Participant
on

What is your configuration?

I have no problem with:

-  LabVIEW 2015

-  Windows 7 Entreprise

- .NET framework 4.5.2

AlbertoZonato
Member
Member
on

Hello everybody,
thank you for sharing this great piece of code. I would like to use this this toolkit in my project.
I wrote the code and the output is good (PDF has both text and tables and control images etc...)
But I am experimenting unpredictable access violations in the built application (Exception - Access Violation - 0xC0000005).

Exceptions occurs only when I enter the page of my program that contains the VI for PDF generation. They are random and don't occur every time I enter the page, but occasionally (I don't need to invoke the PDF VI, simply I have to load it by opening the page). If I disable this VI and I recompile the exe, these access violations disappear.
What can I do to avoid this?


Thank you in advance

Alberto

 

Hooovahh
Proven Zealot Proven Zealot
Proven Zealot
on

Minor bug, in "VIs\Low level\File Low level\Generate Permissions Integer.vi"  The unbundle by name has Allow Assembly listed for 1024, and 256, but the 256 should be Allow Fill In.

RaptorUK
Member
Member
on

 Hi Jean-Marc & all,

 

firstly,  thank you for Exaprom, it has save me a lot of time and effort and will make my project deployment simpler by removing Word as a requirement to get an acceptable report. 

 

Yesterday I was writing a  vi  to create a report of all the vis in my project,  it includes all the subpanels so runs to a couple of hundred pages. I thought a TOC would be helpful in this situation so added one,  then I noticed something that I also noticed in the Exaprom manual,  the page numbers are in the wrong place within the TOC.  Instead of being at the end of the dotted line separator they are at the start just after the bookmark name (see attached image - examples circled in red).

 

I tried for a while to fix the Exaprom code concerned but wasn't successful, I assumed the issues lies in  \Low level\Chapter Low Level\Create TOC Line.vi

 

If anyone knows of a fix I'd be grateful to hear it.  Many thanks.

 

SimonG

 

Exaprom-TOC-issue.png

morio
Member
Member
on

hola, busque y encontre el problema en especifico, y  es que el nodo constructor hay que usar FileStream: mscorlib(2.0.0.0) pero labview 2017 no me deja usar FileStream: mscorlib(2.0.0.0), solo me deja usar FileStream: mscorlib(4.0.0.0) y eso produce el error.1.jpg2.jpg3.jpg

sciawatt
Member
Member
on

Hi,

I've been using Exaprom tool since years in different project with almost no problems.

In a recent project I've found that, if the PDF is created using a windows user account (in this example "pippo") and then the PDF is opened with a different account without admin rights (let's call "pluto") the PDF file opening in a reader e.g. Acrobat, fails due to the fact that the user hasn't got right to open the file. Looking at the file security properties:

 

1.png

 

is visible that the PDF creator has set the security option only for logged user, in this example "pippo" so when "pluto" or any other user without admin rights tries to open the file the operation fails.

I cannot say that the generation of PDF file is somehow wrong, but for example CSV data saved by the same user in the same program (LabVIEW executable) have also read/write rights for "Authenticated users", so this problem doesn't occur.

Any way to avoid this behaviour?

 

Many thanks

Tim30
Member
Member
on

This is amazing.  The user manual to use the code is actually generated with the code!  Brilliant! 

Hansi99
Member
Member
on

Hi

 

Does anybody knows what this error means?

 

 

Exaprom error.jpg

 

I would like to insert a picture on a new page after the "Append Table and Colors.vi".
For this it is necessary to create a new page, or is there another method?

 

Dhvanil479
Member
Member
on

I'm working on labview 2013 32-bit (Windows 7 - 64 bit) and i am using Exaprom PDF 2.0. I have a issue with closing pdf function. When we create or replace a file then generated pdf file shows the below error message

"there was an error opening this document.the file is damaged and could not be repaired".

I have try in another laptop but problem is still there.

Here i have attached two images with the generated error.

Please provide solution for this.

Error from Exaprom pdf close functionError from Exaprom pdf close functionGenerated pdf file error from Exaprom pdf 2.0Generated pdf file error from Exaprom pdf 2.0

bjtianli
Member
Member
on

Dear J-M,

how to print Chinese characters? I set the font to SimSun Regular and character encoding to UTF-16, kept Encoding=CP1252, but nothing on output file. Later i tried to print string "ab你好cd", only got "ab" and "cd", the two characters "你好" are disappeared.

 

thanks

muren
Member
Member
on

Dear Jean-Marc,

I work on labview 2014 32-bit (Windows 7 - 64 bit) with Exaprom PDF 2.0.

I cannot figure out how to do vertical merging cells in the table. I looked through the VIs and didn't find the VMerge field is used. Does the VMerge work?

Can you help me?

 

 

linu95k
Member
Member
on

Is this compatible with labview 2024?

Contributors