LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

print texts in different formats on one page

Solved!
Go to solution

Hi all,

 

Is it possible to print the texts on one page in different fonts and sizes? It seems like PrintTextBuffer prints all the texts onto one page at once and there is no chance to change the format. Thanks,

 

LT

0 Kudos
Message 1 of 6
(3,416 Views)

Attributes for printing are set with SetPrintAttribute with the proper attribute. Specifically, if you use ATTR_EJECT_AFTER attribute to 0, the printer won't eject the paper after printing. With this option you sgould be able to set different print attributes for different parts of texts. When you have finished preparing the page, set ATTR:EJECT_AFTER to 1 and perform the last print function to have the page printed.

 

This is not the most confortable way of printing, though: CVI offers alternatives like NIReports or report printing with Word or Excel, provided the products are installed on the target system. There is also the possibility to use aditional libraries to create reports in PDF format like the HARU Pdf library I used for this example



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 6
(3,400 Views)

Thanks, Roberto. But it doesn't work. ATTR_EJECT_AFTER can hold the paper, but the printing attributes can not be changed. For examle, I have these codes:

 

    SetPrintAttribute (ATTR_PRINTER_NAME, "");
    SetPrintAttribute(ATTR_ORIENTATION, VAL_PORTRAIT);

    SetPrintAttribute(ATTR_EJECT_AFTER, 0);
    SetPrintAttribute(ATTR_PRINT_POINT_SIZE, 10);
    PrintTextBuffer ("This is the teststring printed with LabWindows/CVI 1!", "");
    SetPrintAttribute(ATTR_PRINT_POINT_SIZE, 30);
    PrintTextBuffer ("This is the teststring printed with LabWindows/CVI 2!", "");
    SetPrintAttribute(ATTR_EJECT_AFTER, 1);

 

The two lines were printed on one page, but the font size was always 10. Do you have any idea?

 

Also, as soon as I call SetPrintAttribute(ATTR_EJECT_AFTER, 1), the paper is ejected. This is different from the description of ATTR_EJECT_AFTER: "Specifies whether to eject the paper from the printer AFTER the next call to a printing function." But I guess this is not an important issue.

 

Thanks!

0 Kudos
Message 3 of 6
(3,371 Views)
Solution
Accepted by topic author LtinVa

I must admit that I give you that suggestion but I have not used those functions in several years Smiley Embarassed ; testing your function on my system now (CVI 2009SP1 on Win7 with HP LaserJet printer) I have the same results as you.

 

Due to the limitations of this printing method I moved rapidly to other ways of printing: there are numerous discussions that you can find in the forums about reporting, but basically you can:

 

  • Create a hidden "report" panel where to print your data on standard controls (strings, numerics, graphs, tables and so on) and use PrintPanel to print it
  • Use NIReports instrument
  • Use Office report printing (via Word or Excel)
  • Create a PDF
  • ... (other methods I cannot think of at the moment)

The first one is probably the fastest one: you are already accustomed to create panels and after a short trial you can define the correct panel/control aspect to obtain a good report; it permits you also a limited preview if you want to.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 6
(3,363 Views)

One format one page may be acceptable in my project. If it's not, I'll go for Solution 1. Thank you very much!

0 Kudos
Message 5 of 6
(3,360 Views)

OK for that. In the meanwhile I posted a suggestion for a report printing tool in CVI that you may want to support with Kudos.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 6
(3,349 Views)