PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → [WD21] Print to PDF
[WD21] Print to PDF
Iniciado por guest, 15,ago. 2016 10:51 - 9 respuestas
Publicado el 15,agosto 2016 - 10:51
Hi
We have a sales docket which is normally printed to a printer and this works fine, using the following code iConfigure(Application::xclTermDetail.DocketPrinter) iFont(mfnt_NormalFont) iWindowCancel(False) PrintDocketHeader(lb_copy) PrintTransactionLines() PrintDocketFooter(lb_copy) iEndPrinting() I now need to print it to PDF for emailing so I have changed the code as follows iDestination(iGenericPDF,ls_PDFFile) iFont(mfnt_NormalFont) iWindowCancel(False) PrintDocketHeader(False) PrintTransactionLines() PrintDocketFooter(False) iEndPrinting() All the procedures are unchanged & basically consist of IPrint lines. When I print to PDF I get a docket printed but it is empty, no data is displayed, only a couple of things that I have hardcoded. Printing the docket to the printer (which I have immediately following the print to pdf at the moment) all works perfectly.

What am I missing?

Thanks

David
Publicado el 16,agosto 2016 - 00:01
Hi
Well I've sorta solved it. It looks like it doesn't like iFont lines. I'm not sure whether it's my fonts or any IFont line that's the problem but removing them has got data printing so I'll live with that for now.

Cheers

David
Publicado el 16,agosto 2016 - 09:26
Hi, of course, you should create the font using iCreateFont(..) after that you will be able to use the font. There's no such command iFont(FontName) like you did use it. iFont(...) needs an integer as a parameter which is returned by iCreateFont(...)
Publicado el 16,agosto 2016 - 10:57
Hi Guenter
I have created the font using FontCreate(...) & it works perfectly well printing to physical printers so why should it be different for PDF?
I wrote the base code years ago so I've just looked at the help page for FontCreate again. It shows exactly what I was hoping to achieve, even using iDestination(iPDF) which suggests that it should work.

David
Publicado el 16,agosto 2016 - 11:14
Hi David, however, the code line iFont(FontName) is definitely a no-go, because the parameter is the integer which you defined in iCreateFont(1, 48, iBold + iItalic, iRoman) .. here it is a "1".
Publicado el 16,agosto 2016 - 21:13
Hi Guenter,

while we cannot see it from the code, mfnt_NormalFont coult be a variable with (i.e.) the "1" as value.
Publicado el 17,agosto 2016 - 00:49
Hi Guenter
Sorry, cannot agree.

mfnt_NormalFont is a font variable which I imagine must scale back to an integer for IFont to use it. The help for FontCreate specifically states that it works with iFont; the difference between FontCreate and iCreateFont is that the former can be used anywhere in the application (hence why I use it) whereas the latter is restricted to print functions only.

Also as noted previously it has been working for years coded as above to go to a physical printer; if there was a problem with the code surely it wouldn't work with that either.

David
Publicado el 17,agosto 2016 - 08:21
Hi Stefan,

even if so - there's no working code line like:
iFont(1)
This should be flagged as a compiler error, but since it is a valid function it is not!
iFont(..) is generally used for selection of a font within another iPrint-function, but never alone.
Publicado el 17,agosto 2016 - 08:25
Hi David,

even if so - there's no working code line like:
iFont(1)
This should be flagged as a compiler error, but since it is a valid function it is not!
iFont(..) is generally used for selection of a font within another iPrint-function, but never alone.
Publicado el 17,agosto 2016 - 20:34
Hi Guenter
From the help for iFont, which is exactly how I am using it.

Quote

Syntax



Using a dynamic font



{Result} = iFont( [, {Immediate Calculation}])



{Result}: Character string



Control string describing the use of the specified font.



: Font



Name of the default font to use. This parameter corresponds to a Font variable. The characteristics of the font have been defined by FontCreate or by the properties for font management.

Cheers

David