invoice_folder24 Create an image with vpxPrint

<< Click to Display Table of Contents >>

Navigation:  How to >

invoice_folder24 Create an image with vpxPrint

 

The <EXPORT> tag allows creating image files, like .jpg or a lot of different other formats.

 

These files are images of the pages, that means that the images will be the same size as the printer canvas.

The <FORMAT> tag is used to define the size of the work area. But as it relates to a printer, the setting can be rejected by the printer driver.

It's often the case with real printers, they have limit in size and they use their own margins…

 

The "Microsoft XPS Document writer" is a standard Microsoft driver with no margins and a great flexibility in size. The <FORMAT=CUSTOM,xxx,yyy> will then allow to adjust the canvas to the expected image size.

 

If this driver does not exist on your PC, install it from the Windows "add a new printer" panel.

 

Example:

Creating a jpg file of 25 x 25mm that contains a QRCode of 25x25mm:

 

In the xpr file below:

<PRINTER=Microsoft XPS Document>" directs the ouput to the Microsoft driver,

<FORMAT=CUSTOM,250,250>                  sets the page format to 25x25mm (dimensions are in 10th of millimeters)

 

Sample program:

{xprint.i}

 

DEF STREAM O.

 

DEF VAR xFile   AS CHAR NO-UNDO.

xFile = SESSION:TEMP-DIRECTORY + "Qrcode.xpr".

 

OUTPUT STREAM O TO VALUE(xFile) PAGED PAGE-SIZE 70.

 

PUT STREAM O CONTROL                                        

                   "<PRINTER=Microsoft XPS Document>"  /* this printer has no margins and allows */

                   "<FORMAT=CUSTOM,250,250>"           /* a flexible "CUSTOM" format             */                        

                   "<EXPORT=c:/temp/Qrcode.jpg>"

                   "<PREVIEW>"                         /* If no preview, delete this line

                                                          =============================*/

                    "<PRINT=NO>"

                    /* ================================================================*/                  

                    "<UNITS=mm>"

                    "<#1>"            /* start position upper left corner           */

                    "<AT=+25,+25>"    /* end point 25mm lower and 25mm to the right */

                                                                           

                    "<BARCODE#1,TYPE=QRCODE,VALUE="

                                  "https://www.4gl.fr"          /* your value here */

                    ">".

                    /* ================================================================*/                  

                           

OUTPUT STREAM O CLOSE.

RUN printFile( xFile ).

 

/*      The file Qrcode0001.jpg" is created, you can rename it

       ======================================================

               ("0001" means 'page 1')

*/

 

OS-DELETE "c:/temp/Qrcode.jpg".

OS-RENAME "c:/temp/Qrcode0001.jpg"   "c:/temp/Qrcode.jpg".

 

/*      Delete the xpr file

       =================*/

OS-DELETE VALUE(xFile).