xPrint.dll entry points
<< Click to Display Table of Contents >> Navigation: »No topics above this level« xPrint.dll entry points |
These entries are FREE.
• First parameter: the file name
• Second parameter: memptr to the result area.
•Third parameter: integer, length of the the output area
•Fourth parameter: integer, length of the base64 string or error retun code
if the area is not large enough.
o-1 file not found
o0 error
o>0 length of the output base64 string.
SET-SIZE(Z64) = 50000. /* allocate the memory with the right size */
RUN base64("c:/temp/image.png", Z64, 50000, OUTPUT size64).
/*=======================================================*/
Call a first time base64 with zero ad output length will return the length of the area todefine.
That helps to allocate the memory area with a SET-SIZE().
Consider using PROGRESS function.
getPrinterList |
get a list of installed printers |
• First parameter: length of the receiving area (LONG)
• Second parameter: memptr to this area. This return value is a comma-separated list of available printers.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getPrinterList( 1024, M).
L = get-String(M, 1).
Set-size(M) = 0.
getPrinterFonts |
get a list of printers fonts |
• First parameter: length of the receiving area (LONG)
• Second parameter : memptr to this area. This return value is a comma-separated list of available fonts for the current printer.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getPrinterFonts( 1024, M).
L = get-String(M, 1).
Set-size(M) = 0.
getScreenFonts |
get a list of screen fonts |
•First parameter: length of the receiving area (LONG)
• Second parameter: memptr to this area. This return value is a comma-separated list of available screen fonts.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getScreenFonts( 1024, M).
L = get-String(M, 1).
Set-size(M) = 0.
• First parameter: input Text
• Second parameter : font description. The font parameter is a comma-delimited list: Font_Name,Font_size,[U,B,I,K]
• Third parameter: output returned length of the text in pixels.
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
def var I as int NO-UNDO.
RUN getTextWidth( myText, myFont, output I). /* I = length in pixels */
NOTE:
The size in pixels depends of the current printer resolution. If you want to convert this value in inches, call the as follows:
RUN getPrinterRes(OUTPUT R).
DEF VAR sizeInInches as DECIMAL.
sizeInInches = I / R.
You can see this example in the xTest.w program.
WARNING: old version was getWidth() in conflict with the ADM2 function getWidth()
• First parameter: input Text
• Second parameter : font description. The font parameter is a comma-delimited list: Font_Name,Font_size,[U,B,I,K]
• Third parameter: string return value
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
DEF VAR M AS MEMPTR NO-UNDO.
DEF VAR iLength AS CHAR NO-UNDO.
SET-SIZE(M, 20).
RUN getINWidth( myText, myFont, M).
iLength = GET-STRING(M, 1).
SET-SIZE(M) = 0.
• First parameter: input Text
• Second parameter : font description. The font parameter is a comma-delimited list: Font_Name,Font_size,[U,B,I,K]
• Third parameter: string return value
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
DEF VAR M AS MEMPTR NO-UNDO.
DEF VAR mmLength AS CHAR NO-UNDO.
SET-SIZE(M, 20).
RUN getMMWidth( myText, myFont, M).
mmLength = GET-STRING(M, 1).
SET-SIZE(M) = 0.
•First parameter: OUTPUT return value (LONG)
def var R as INT NO-undo.
run getPrinterRes( Output R).
fontDialog |
Displays the WINDOWS font dialog box. |
•First parameter: integer type of font: 1 = Screen font dialog, 2 = Printer font dialog, other values = screen + printer fonts,
•Second parameter: MEMPTR to return value. The return-value is structured as a LINE-FEED (chr(10)) delimited list:
o | Entry(1, <areaName>, chr(10) ) = "Arial,10,B,U". This entry can be directly used as input for getTextWidth |
o | Entry(2, <areaName>, chr(10) ) = "<Farial><P10><B><U>". This entry can be used for vpxPrint files (*.xpr). |
• Third parameter: return INTEGER(LONG) value : 0 = user has canceled the dialog-box, 1 = OK
def var M as MEMPTR NO-undo.
def var dialogType as int no-undo.
def var returnCode as int no-undo.
def var L as char no-undo.
dialogType = 3. /* 1 = Screen fonts, 2 = Printer fonts, other = all */
set-size(M) = 512.
run fontDialog( dialogType, M, output returnCode).
L = get-String(M, 1).
set-size(M) = 0.
Same as getTextHeight but the width is specified in millimeters, not in pixels.
There is no need to call getTextHeight before textHeight.
• First parameter: input Text
• Second parameter : font description. The font parameter is a comma-delimited list: Font Name,Size,[U,B,I,K]
• Third parameter: length in millimeters of the target area
• Output : number of lines.
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
Def var myWidth as int initial 100 NO-UNDO. /* 10 cm */
def var I as int NO-UNDO.
RUN textHeight( myText, myFont, myWidth, output I). /* I = # lines */
getTextHeight |
Height of text within a frame |
// DEPRECATED //
• First parameter: input Text
• Second parameter : font description. The font parameter is a comma-delimited list: Font Name,Size,[U,B,I,K]
• Third parameter: length in pixels of the target area
• Output : number of lines.
def var myText as char initial "Here is my text." NO-UNDO.
def var myFont as char initial "Arial,14,B" NO-UNDO.
Def var myWidth as int initial 600 NO-UNDO.
def var I as int NO-UNDO.
RUN getTextHeight( myText, myFont, myWidth, output I). /* I = # lines */
NOTE:
1. The size in pixels depends of the current printer resolution. If you want to convert this value in inches, call the getPrinterRes() as follows:
DEF VAR numberOfPixels AS INT.
DEF VAR sizeInInches AS DECIMAL.
DEF VAR R AS INT.
RUN getPrinterRes(OUTPUT R).
sizeInInches = 5.5. /* 5.5" */
numberOfPixels = sizeInInches * R.
RUN getTextHeight( "Hello world, this is my first text.", "Arial,12,B", numberOfPixels, output I). /* I = # lines */
2. getTextWidth() returns also the right number of lines of multiple lines strings (lines are delimited by line feeds, #10)
You can use this function to determine the number of lines produced by a <FRAME#1><USE#1> xxx xxx xxxxxxxx sequence. When you send such text, vpxPrint smoothly prints the text in the area but you don't get the number of lines that vpxPrint writes.
getImageDim |
get the image width and height (see the xPrint.i include getImageDim reference) |
• First parameter : image name
• Second parameter : width in pixels
• Third parameter : height in pixels
Example :
DEF VAR imageWidth AS INTEGER NO-UNDO.
DEF VAR imageHeight AS INTEGER NO-UNDO.
RUN getImageDim( "C:\TEMP\myImage.BMP",
input-output imageWidth,
input-output imageHeight).
•First parameter : integer font size.
• Second parameter : MEMPTR to CPI setting (vpxPrint tag string)
Example 1:
DEF VAR M AS MEMPTR.
DEF VAR L AS CHAR.
SET-SIZE(M) = 256.
run getCPI(8, M).
L = get-String(M, 1).
SET-SIZE(M) = 0.
in return L contains <CPI=15>
Example 2 :
To get all the CPI settings for font sizes varying from 2 to 20 :
DEF VAR C AS CHAR.
DEF VAR M AS MEMPTR.
DEF VAR I AS INT.
SET-SIZE(M) = 30.
REPEAT I = 2 TO 20:
RUN getCPI(I, OUTPUT M).
C = GET-STRING(M, 1).
DISPLAY I LABEL "Size" C LABEL "Tag" FORMAT "x(20)".
END.
SET-SIZE(M)= 0.
GetLPI |
get the number of lines per inch for a given font size. |
• First parameter : font description. The font parameter is a comma-delimited list : Font Name,Size,[U,B,I,K]
• Second parameter : MEMPTR to LPI setting (string)
Example :
DEF VAR M AS MEMPTR.
DEF VAR L AS CHAR.
SET-SIZE(M) = 256.
run getLPI('ARIAL,12,B', M).
L = get-String(M, 1).
SET-SIZE(M) = 0.
/* Now we can use '<LPI' + L + '>' as a normal setting for vpxPrint.
See the xTest.w, button Font dialog for an example.
*/
printerDialog |
displays a printer dialog box and returns a comma-separated list containing theprinter name, paper format name, dimensions, orientation, bin and copies number. |
•First parameter : comma-separated list area
7 entries : printer name,
Format name (see the list of supported formats by vpxPrint)
Width in tenth of millimeters,
Height in tenth of millimeters,
Orientation,
BIN=binName
COPIES=#ofCopies
Example :
DEF VAR M AS MEMPTR NO-UNDO.
DEF VAR A AS CHAR NO-UNDO.
SET-SIZE(M) = 256.
RUN printerDialog( M ).
A = GET-STRING(M, 1).
SET-SIZE(M) = 0.
MESSAGE "Printer name :" ENTRY(1, A)
SKIP
"Format Name :" ENTRY(2, A)
SKIP(1)
"Dim :" ENTRY(3, A) "x" ENTRY(4, A) "(tenth mm)"
SKIP
"Orientation :" ENTRY(5, A)
VIEW-AS ALERT-BOX INFO.
The getPrinter procedure returns the current attributes for the current printer without asking for a printer.
setPrinter |
Sets the current printer attributes. |
This entry can be used (for example) before a printerDialog for setting default values.
•Parameter : printer attributes description, a comma delimited list with the following available keywords:
PRINTER= printerName
BIN= bin name or number
COPIES= number of copies
ORIENTATION= Portrait or Landscape
FORMAT= | vpxPrint format : as the list is a comma delimited, if a custom size is to be specified, replace the commas in this entry by a ; |
Example: |
FORMAT=CUSTOM;120;130 |
All parameters are optional, but at least specify one.
Updated in version 10: support of different formats.
Images, WORD, EXCEL and other contents are supported. The file can then be imported within an vpxPrint report.
Two parameters:
· | The output file name: must be a valid file name with the jpg, png or wmf extension |
· | The return status: integer value |
Example:
DEF VAR L AS INT NO-UNDO. /* return status */
FILE-INFO:FILE-NAME = ".".
OS-DELETE VALUE( FILE-INFO:FULL-PATHNAME + "\clipboard.wmf" ) NO-ERROR.
RUN saveFromClipboard( FILE-INFO:FULL-PATHNAME + "\clipboard.wmf", OUTPUT L).
IF SEARCH( FILE-INFO:FULL-PATHNAME + "\clipboard.wmf") = ? THEN
MESSAGE "Image has not been created."
SKIP
"Please fill in the clipboard with an image" SKIP
"to test this function." VIEW-AS ALERT-BOX WARNING.
ELSE
MESSAGE FILE-INFO:FULL-PATHNAME + "\clipboard.wmf"
"has been created from Clipboard." VIEW-AS ALERT-BOX INFO.
If the file ends with a form-feed with no characters (except LF, CR or space) after it, the last page is not counted.
This procedure returns invalid value when orientation changes in the report.
Add to the result the number of orientation changes (<OPORTRAIT> or <OLANDSCAPE>)
New in 10.6f:
pageCount now takes care of orientation changes.
If the first page of the report is in landscape format, then subtract 1 from the value returned.
Two parameters:
· | The input file name: must be a valid full file name |
· | The page count: integer value ( -1 if the file does not exist) |
· |
Example:
DEF VAR N AS INT NO-UNDO. /* return value */
RUN pageCount( "c:\Temp\MyFile.xpr", OUTPUT N).
convertRTF is hosted by vpxRTF.dll.
Two parameters:
•The input RTF sequence (character variable).
•The return value: MEMPTR value
Note:
This procedure processes strings and attributes (font, size, style, color) only.
It does not support indentation, bullets, justification or images.
Example:
DEF VAR A AS CHAR NO-UNDO.
DEF VAR RTFCode AS LONGCHAR NO-UNDO.
DEF VAR M AS MEMPTR NO-UNDO.
DEF VAR i AS INT NO-UNDO.
SET-SIZE(M) = 500000.
INPUT STREAM RTF FROM "c:/temp/HelloWorld.rtf" BINARY NO-CONVERT.
REPEAT:
A = "".
IMPORT STREAM RTF UNFORMATTED A.
RTFCode = RTFCode
+ (IF RTFCode > "" THEN CHR(10) ELSE "")
+ A.
END.
INPUT STREAM RTF CLOSE.
/* Call vpxPrint RTF conversion tool */
RUN convertRTF(RTFCode, M). /* translate RTF to vpxPrint tags */
/*************************/
RTFCode = GET-STRING(M, 1). /* translated RTF to vpxPrint */
SET-SIZE(M) = 0.
OUTPUT STREAM RTF TO c:/temp/inRTF.xpr.
PUT STREAM RTF CONTROL "<PREVIEW>"
"<#1><UNITS=mm><AT=100,205><FRAME#1><RECT#1>"
"<ALIGN=BASE>"
"<USE#1>".
/* Segments of 30.000 bytes (PROGRESS limit) */
DO i = 1 TO LENGTH(RTFCode) / 30000 + 1:
A = SUBSTRING(RTFCode, (i - 1) * 30000 + 1, 30000).
PUT STREAM RTF CONTROL A.
END.
PUT STREAM RTF CONTROL "</USE>".
OUTPUT STREAM RTF CLOSE.
RUN printFile("c:/temp/inRTF.xpr").
DEF VAR inputRTF AS CHAR NO-UNDO.
DEF VAR M AS MEMPTR NO-UNDO.
SET-SIZE(M) = 60000. /* Allocate enough size */
/*
Put a valid RTF sequence in the inputRTF variable
=================================================
*/
RUN convertRTF( inputRTF, M).
L = GET-STRING(M, 1). /* M contains the vpxPrint tags */
SET-SIZE(M) = 0. /* Frees the MEMPTR memory */
OUTPUT STREAM I TO demoRTF.xpr.
PUT STREAM I CONTROL "<PREVIEW>"
"<#1><UNITS=mm><AT=250,190><FRAME#1><RECT#1><ALIGN=BASE><USE#1><AT=+5>"
L "</USE>".
OUTPUT STREAM I CLOSE.
RUN printFile("demoRTF.xpr").
• One parameter: memptr to the area. This return value is the printer name.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 1025. /* Add one for chr(0) terminator */
run getLastPrinter( M ).
L = get-String(M, 1).
Set-size(M) = 0.
MESSAGE "Last printer"
SKIP
L
VIEW-AS ALERT-BOX.
This entry can be used to define a new Windows default printer.
•Parameter : printer name
RUN setDefaultPrinter("Printername").
vpxPrint searches all available printers for a printer whose name equals to or begins by the specified printer name.
if no printer matches the specified name, no change occurs.
This entry can be used to get the name of the Windows default printer.
• One parameter: memptr to the area. The return value is the printer name.
Def var M as MEMPTR no-undo.
def var L as char no-undo.
set-size(M) = 255.
run getDefaultPrinter( M ).
L = get-String(M, 1).
Set-size(M) = 0.
MESSAGE "Default printer"
SKIP
L
VIEW-AS ALERT-BOX.
Parameters:
1.ExeName: name of the executable (Ansi string)
2.Parameters: parameters (Ansi string)
3.DefaultDir Default Directory (Ansi string)
4.ShowMode Integer
5.ReturnStatus Integer, value of the windows return code.
DEF VAR ReturnValue AS INTEGER.
RUN ExecuteAndWait(
"PDFtoJPG.exe",
"File.jpg outImage.jpg -pages=all",
"",
1,
ReturnValue
).
showMode:
-1: default mode
0: SW_SHOWHIDE
1: SW_SHOWNORMAL
2: SW_SHOWMNIMIZED
3: SW_SHOWMAXIMIZED
Parameters:
6.ExeName: name of the executable (Ansi string)
7.Parameters: parameters (Ansi string)
8.DefaultDir Default Directory (Ansi string)
9.ShowMode Integer
10.ReturnStatus Integer, value of the windows return code.
DEF VAR ReturnValue AS INTEGER.
RUN WaitFor(
"PDFtoJPG.exe",
"File.jpg outImage.jpg -pages=all",
"",
1,
ReturnValue
).
same functionality than ExecuteAndWait but run in vpxWait.dll, a lighter dll than xprint.dll
showMode:
-1: default mode
0: SW_SHOWHIDE
1: SW_SHOWNORMAL
2: SW_SHOWMNIMIZED
3: SW_SHOWMAXIMIZED
Returns an integer value:
▪1 Mail is sent
▪10 Mail error
▪100 Mail is saved // Applies to Outlook, no support for MAPI
▪1000 Mail attachment error
▪10000 Outlook
▪100000 CDO
▪1000000 MAPI
PROGRESS:
DEF VAR retCode AS INT NO-UNDO.
RUN getMailResult(OUTPUT retCode).
PROGRESS users may use the mailStatus() function, easier to code:
From xprint.i:
/* MailStatus
========*/
DEF VAR MailSent AS INT NO-UNDO INITIAL 1.
DEF VAR MailError AS INT NO-UNDO INITIAL 2.
DEF VAR MailSave AS INT NO-UNDO INITIAL 3.
DEF VAR MailAttachError AS INT NO-UNDO INITIAL 4.
DEF VAR MailOutlook AS INT NO-UNDO INITIAL 5.
DEF VAR MailCDO AS INT NO-UNDO INITIAL 6.
DEF VAR MailMAPI AS INT NO-UNDO INITIAL 7.
FUNCTION mailStatus RETURNS LOGICAL (I AS INTEGER) FORWARD.
/* ====================================================================*/
IF mailStatus( MailSent ) THEN
MESSAGE "Mail is sent" VIEW-AS ALERT-BOX.