LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Print PDF report in exe on other PC

Solved!
Go to solution

Hello,

I am using the LabVIEW 2020 32bit version.

 

The main task of my project is to create a PDF report file with Word 2016 and Bookmarks.

I am using the MS Office Report with the option to print it with the "Print to PDF" function.

It all works fine on the development computer. When I filled in the gaps I wanted and run the VI the PC asks me where i wanted to save the PDF file. 

So I got another PC (with the same Word version) and installed the LabVIEW Runtime Engine. Then I built an exe and added the VI, the folder NIReport.llb and the used MSOffice_RGT_Template.dot. (I´ve attached a screenshot)

 

On this second PC I wanted to use the exe it was able to fill in the gaps. But then I run the exe (to save the report as an PDF) there popped up no window to select the saving-destination like on the development PC.

 

I´ve also attached my VI.

 

Does anyone know how to handle this problem?

 

Thank you!

0 Kudos
Message 1 of 14
(457 Views)

So, no window popped up. Did it create a pdf with a standard name or did nothing happen?

 

Do you get an error? I guess not since you haven't wired the error out. Put an error indicator on the front panel connected from the "error out" terminal on the express-VI and see if you get an error when running on the other PC.

 

Does the PC have a printer named as you specified:

thols_0-1642768974052.png

If not, that feature is not active on Windows. Google how to activate it.

 

Certified LabVIEW Architect
0 Kudos
Message 2 of 14
(430 Views)

If you are already using the NI-supplied Report Generation Toolkit VIs, you may want to try the attached.  It's a VI I created (others on here have trod the same path) which isn't part of the RGT library, but very easily could be added to it.  It wraps/invokes the Word or Excel "Export as Fixed Format" functionality allowing you to have a Word doc, or a selected sheet in Excel, render to PDF or XPS.  Because this is built-in MS Office functionality, it's not dependent on having the correct "Print to PDF" printer setup on the target PC, and it allows the output file path and name to be specified in the code - without user prompting.

 

Below is the BD as a snippet.  The other cases are for Excel (the ActiveX call differs), and for HTML (the VI is a no-op).  I've attached the complete VI as well.

 

Report Export As Fixed Format.png

 

Hope this helps - best regards,

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 3 of 14
(391 Views)

Nothing happened, not even a standard-named pdf was created.

 

The printed on the other PC was activated and available. 

 

But I´ve put an error indicator on the front panel and there is an error now. But I didn´t get the problem, even with the error. I don´t know whats the problem. 

 

I´ve attached a screenshot of the error code.

0 Kudos
Message 4 of 14
(369 Views)

@Dave

 

Thank you for the VI, but I think this solution doesn´t work.. I have to save it directly after filling in the bookmarks as a PDF on the PC, I am not allowed to save it as a Word document first.

So I don´t have a finished report and can change it to PDF after creating it as a Word document. I don´t have a path to get a report from.

I am using the RGT tools because later with the EXE it´s much easier to use the template I want to on the target PC.

I don´t have trouble with paths that way.

0 Kudos
Message 5 of 14
(371 Views)

@bjoernde wrote:

@Dave

 

Thank you for the VI, but I think this solution doesn´t work.. I have to save it directly after filling in the bookmarks as a PDF on the PC, I am not allowed to save it as a Word document first.

So I don´t have a finished report and can change it to PDF after creating it as a Word document. I don´t have a path to get a report from.

I am using the RGT tools because later with the EXE it´s much easier to use the template I want to on the target PC.

I don´t have trouble with paths that way.


I think you do not understand. The method proposed by Dave does not save as a word document first, but exports the word report directly as a PDF document. This is an build-in feature of word.

0 Kudos
Message 6 of 14
(361 Views)

Not sure I understand your planned workflow, then - you say you are using the Report Generation Tools, and you mention a "template" to be used.

 

To use what I provided, the target PC does need to have Word installed, but there is no requirement to save a Word document (as a .doc or .docx file), at any point.  The method operates on a "report" (as in, a Word document in memory), which was my understanding of how you were "filling bookmarks".  What is the form of your "template"?

 

Dave

David Boyd
Sr. Test Engineer
Abbott Labs
(lapsed) Certified LabVIEW Developer
0 Kudos
Message 7 of 14
(357 Views)

@bjoernde wrote:

Nothing happened, not even a standard-named pdf was created.

 

The printed on the other PC was activated and available. 

 

But I´ve put an error indicator on the front panel and there is an error now. But I didn´t get the problem, even with the error. I don´t know whats the problem. 

 

I´ve attached a screenshot of the error code.


Error 7: LabVIEW: (Hex 0x7) File not found. The file might be in a different location or deleted. Use the command prompt or the file explorer to verify that the path is correct.

 

An earlier screenshot shows that you use MSOffice_RGT_Template.dot. Is it possible that this file is not found? Put an indicator on the front panel and check at which path the file is supposed to be. Maybe you check in the preview category of the application builder where the file is placed.

And be aware that dynamic created paths may be different between development system and an exe (e.g. if you use 'Current VI's Path').

0 Kudos
Message 8 of 14
(354 Views)

Sorry for this misunderstandings. It´s the template from the MSOffice Report I am using.

(C:\Program Files (x86)\National Instruments\LabVIEW 2020\templates\Report\MSOffice_RGT_Template.dot)

 

I´ve created my own bookmarks in this template.

 

So, first I am filling the bookmarks in this template you can read above. Then i want to directly safe it as a PDF. There ist no Word report required. 

 

What I don´t understand in your sent VI is that I first have to choose an already created report to read out the report type? Or how do I get in the filled in template to crate a PDF?

0 Kudos
Message 9 of 14
(353 Views)

@UliB

 

I´ve read that I have to insert the template to the "always included" when I build the exe, so I did this. 

Is it possible that it´s not enough to insert the template document only? Should I insert any folders where the template is in?

 

Error 7 says that the is a problem with the file. So it must be a wrong way I am inserting this template when buildingthe EXE?

0 Kudos
Message 10 of 14
(350 Views)