LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Print RTF document with PrintDocument and PrintPageEventHandler

Hi Community,

my goal is to print a rtf document with the .net Framework. As a reference i used the MSDN article.

 

The problem is that the constructor PrintPageEventHandler needs a reference to a method. In the source code this is PrintPageEventArgs, but in LabVIEW i cant connect the ReferenceOut of PrintPageEventArgs and method.

 

2017-08-29 13_20_56-PrintDocumentEventHandler.vi Block Diagram.png

 

 

 

0 Kudos
Message 1 of 4
(3,724 Views)

I made some changes, but still i dont know what need to be connect with the method 😞2017-08-30 08_40_09-PrintDocumentEventHandler.vi Block Diagram _.png

0 Kudos
Message 2 of 4
(3,673 Views)

Another try 😄
This time the Programm works but the document i print is empty. Is the position of the graphics wrong or does anyone know how to print properly with PrintDocument?2017-08-30 14_09_09-PrintDocumentEventHandler.vi Block Diagram.png2017-08-30 14_09_40-PrintDocumentEventHandler.vi Block Diagram.png

0 Kudos
Message 3 of 4
(3,652 Views)

@NikoWenz wrote:

The problem is that the constructor PrintPageEventHandler needs a reference to a method. In the source code this is PrintPageEventArgs, but in LabVIEW i cant connect the ReferenceOut of PrintPageEventArgs and method.


This is an old thread, but for whomever wanders here looking for using .net to print from LabVIEW -

 

To do the above, refer to https://forums.ni.com/t5/Developer-Center-Resources/Register-Callback-VIs-for-NET-Events-in-LabVIEW/...

There are also examples in LabVIEW itself (search by .net keyword).

 

You need to create a second VI that will act as a callback to your printPage() event.

In that vi you will need to use "Event Data -> e -> Graphics" methods to provide information to print.

 

Attached is an example that prints an image from file to a PDF. To print your RTF you will need to replace "Image.FromFile" and "DrawImage" to your StreamReader and corresponding drawing functions.

Download All
Message 4 of 4
(3,164 Views)