Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
10
Erster Beitrag:
vor 1 Jahr, 4 Monaten
Letzter Beitrag:
vor 1 Jahr, 4 Monaten
Beteiligte Autoren:
David Egan, GuenterP, Stefan Bentvelsen

[WD21] Print to PDF

Startbeitrag von David Egan am 15.08.2016 08: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

Antworten:

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

von David Egan - am 15.08.2016 22:01
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(...)

von GuenterP - am 16.08.2016 07:26
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

von David Egan - am 16.08.2016 08:57
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".

von GuenterP - am 16.08.2016 09:14
Hi Guenter,

while we cannot see it from the code, mfnt_NormalFont coult be a variable with (i.e.) the "1" as value.

von Stefan Bentvelsen - am 16.08.2016 19:13
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

von David Egan - am 16.08.2016 22:49
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.

von GuenterP - am 17.08.2016 06:21
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.

von GuenterP - am 17.08.2016 06:25
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

von David Egan - am 17.08.2016 18:34
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.