LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I print a multipage doc to PDF from LabVIEW?

I have an app which prints reports for my client.
The reports are mostly graphs, with some attached labeling info.
These might be one or a hundred pages, all results of a modeling run.

I have several dummy VIs, which are laid out the way the page should look (different from the screen), and it can print to the printer, a PNG file, a BMP file, or a JPG file.

Right now, each page is a separate PRINT VI operation. In other words, the same VI may be called multiple times, with different data, and told to print.

This has worked well for several years. But now, the client would like to print directly to PDF, with each PDF file containing one to a hundred pages.

I've tried things like "Win2PDF", but that makes a separate file for each page. That's understandable, since I'm calling the PRINT VI multiple times, but it's not what I want.

I have never used the REPORT GENERATION VIs in LabVIEW, but my first look at them was not promising. One example complained that I cannot move or rename the "Documents and Settings" folder (I didn't really want to, but it apparently tried). Another generated an OK HTML file and printed it, but HTML introduces all kinds of uncertainties about page boundaries and such.

Anyone have suggestions about a better answer?
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 1 of 14
(4,050 Views)
Hi Coastalmainebird,

I've done somehting like this myself, also without the report toolkit. I've found controlling Word/Excel myself gives more control, and is easier to understand (If you are familiar with macro programming in Office).

You can place the objects into a WORD file, setting their position to fixed and so on (I'd have to check for the exact details, but you probably know this part already). I DO remember that "inlineshapes" and "shapes" are handled seperately by word. Make sure to only use one of the two types (Inlineshapes move with text I think, whereas Shapes float). A simple way would be to take a snapshot of the front panel required and pop the picture into the word file (preferably one screen per page).

Once all pics are in the file, print using the required PDF generator. I've used JawsPDF in the past and it worked almost good. It had the odd problem of missing a print from time to time, but otherwise gave good results.

I have always placed some kind of notifier in the word file to let WORD know to print a PDF. Then, using a macro which is tied into the event structure of WORD (A tricky thing to get running by the way), I check at run-time when printing if it's a designated "PDF" print. I can then route to the correct "printer" to get the job done properly. The event structure of WORD is quite useful as you can (As in LV) capture most user actions and act accordingly.

If you have some time, I might be able to dig up an example. Could take a few days though since I'm in a new company since I've done this particular piece.

Hope this helps.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 2 of 14
(4,034 Views)
Thanks for your reply.
I would like to avoid all that work, though. I don't know MS Word enough to make it happen and fix problems that come up. I'd really like a way to plop the images into a single print job then use Win2PDF, or maybe directly into PDF.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 14
(4,015 Views)
On another track...

Does anyone know if there is any way to control Fineprint through LabVIEW? I know it can collate multiple print jobs into one and route them all to a single printer. Maybe this would be a good solution.

I am aware of the manual "Print" function of fineprint after X print jobs have been sent, but I don't know if it's possible to programatically tell Fineprint that it now has enough pages to print.

Anyone out there know if this is possible?

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 4 of 14
(4,007 Views)
If you can tolerate some more EXE-sprawl (I'm sort of surprised you're not on a Mac here!), then you can append individual PDF pages together to form a longer document. I found a free utility a while back called pdftk, and it worked well for me. Maybe it's not exactly what you want to do, but I figured I'd suggest it.

See more info in this thread.

Regards,
John
0 Kudos
Message 5 of 14
(3,987 Views)
I'm sort of surprised you're not on a Mac here!


Well, I am on a Mac, it's my client who has the problem. ;->

I looked at the concatenate thing - basically, that would mean writing the individual pages somewhere, and then calling the PDFTK thing with a hundred file names on the command line. Isn't there a command-line length limit? I might run into that.

Thanks for the tip.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 6 of 14
(3,971 Views)
Ooooohh - the trouble with that is that Win2PDF has a dialog for every single page. To create those hundred pages, I would have to answer a hundred SAVE dialogs. Not a good idea.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 7 of 14
(3,968 Views)
If you can print to file (which creates a postscript file) then concatenate each new ps file to the main file, there is a win32 version of the unix command line tool 'ps2pdf'. For a hundred pages, it will take a few minutes to run.
0 Kudos
Message 8 of 14
(3,946 Views)
Try JawsPDF. AFAIK it has a function to automatically generate the filenames. Haven't used it in a while though.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 9 of 14
(3,939 Views)
Fineprint has a SDK for developers. Did you check out their website?

-Joe
0 Kudos
Message 10 of 14
(3,934 Views)