Home Devices

Canvas does not allow drawing (PDF creation)

edited February 2017 in Devices

One of our customers reported some errors that occurred while creating
PDF files. The error message was "Canvas does not allow drawing". The
strange thing is that it fails only sometimes with that error, the rest
of the time it word (and always worked) without problems.

Could that be a temporary resource problem?

Thanks in advance,

Here is the stacktrace the customer sent us (i have only replaced the
pallication name with "SomeApp"...)

Canvas does not allow drawing

Location: $00604F54
at $00000000 in unit: Vcl.Graphics, proc:
Vcl.Graphics.TCanvas.RequiredState, line: 0, ofln: 0

(00203F4F){SomeApp.exe} [00604F4F] Vcl.Graphics.TCanvas.RequiredState + $43
(00203E49){SomeApp.exe} [00604E49] Vcl.Graphics.TCanvas.GetHandle + $15
(0042A112){SomeApp.exe} [0082B112] ppPDFUtils.TppPDFUtils.NumFontGlyphs
+ $2A
(0042A096){SomeApp.exe} [0082B096] ppPDFUtils.TppPDFUtils.IsUnicodeFont
+ $3E
(00424973){SomeApp.exe} [00825973]
ppPDFCanvas.TppPDFCanvas.WriteCustomText + $37
(0042544A){SomeApp.exe} [0082644A] ppPDFCanvas.TppPDFCanvas.DrawBoldText
+ $62
(00424904){SomeApp.exe} [00825904] ppPDFCanvas.TppPDFCanvas.WriteText + $5C
(0042487F){SomeApp.exe} [0082587F] ppPDFCanvas.TppPDFCanvas.WriteText + $27
(004243D9){SomeApp.exe} [008253D9] ppPDFCanvas.TppPDFCanvas.DrawText + $45
(00448FC2){SomeApp.exe} [00849FC2]
ppPDFRendererStandardText.TppPDFRendererStandardText.CreateText + $1A6
(00448777){SomeApp.exe} [00849777]
ppPDFRendererCustomText.TppPDFRendererCustomText.RenderToPDF + $8F
(003377A6){SomeApp.exe} [007387A6] ppDrwCmd.TppDrawText.GetText + $E
(004493C7){SomeApp.exe} [0084A3C7]
ppPDFRendererStandardText.TppPDFRendererStandardText.RenderToPDF + $33
(0044AC27){SomeApp.exe} [0084BC27]
ppPDFRendererText.TppPDFRendererText.RenderToPDF + $8B
(0049EC02){SomeApp.exe} [0089FC02] ppPDFDevice.TppPDFDevice.DrawToPage + $9E
(0049EA46){SomeApp.exe} [0089FA46]
ppPDFDevice.TppPDFDevice.SavePageToFile + $10E
(00572BD5){SomeApp.exe} [00973BD5] ppFilDev.TppFileDevice.ReceivePage + $6D
(0049E930){SomeApp.exe} [0089F930] ppPDFDevice.TppPDFDevice.ReceivePage + $0
(0033F25D){SomeApp.exe} [0074025D]
ppDevice.TppPublisher.TakeDeviceAction + $BD
(0033F68C){SomeApp.exe} [0074068C] ppDevice.TppPublisher.ReceivePage + $18
(0036D908){SomeApp.exe} [0076E908]
ppArchiv.TppCustomArchiveReader.Generate + $120
(0036D7DA){SomeApp.exe} [0076E7DA]
ppArchiv.TppCustomArchiveReader.RequestPage + $22
(0033F7FD){SomeApp.exe} [007407FD] ppDevice.TppPublisher.DoOnPageRequest
+ $55
(0033F49B){SomeApp.exe} [0074049B] ppDevice.TppPublisher.Publish + $63
(004DBBF2){SomeApp.exe} [008DCBF2] ppProd.TppProducer.PublishReport + $6
(004DBCCB){SomeApp.exe} [008DCCCB] ppProd.TppProducer.PrintToDevices + $7F
(0036D63C){SomeApp.exe} [0076E63C]
ppArchiv.TppCustomArchiveReader.PrintToDevices + $C


  • edited February 2017
    Hi Ralf,

    Which version of ReportBuilder and Delphi are you using?

    Generally the "canvas does not allow drawing" error is caused by a
    memory or resource leak of some kind. This could be somewhere in
    ReportBuilder or your code.

    If possible, please give me the exact settings you are using to export
    to PDF (specifically the font settings) so I can run some tests here
    with a memory manager and see if I can find a problem.

    Best Regards,

    Nico Cizik
    Digital Metaphors
  • edited February 2017
    Hi Nico,

    Sorry for the late reply...

    We are still using version 15 (we have switched to version 18 lately but
    this version is not available to our customers yet).

    For the exact settings i will have to ask our customer waht was used


    Am 17.02.2017 um 17:15 schrieb Nico Cizik (Digital Metaphors):
  • edited March 2017

    Sorry again for the delay. Meanwhile our customer gave us more
    information, including some stack traces of that error.

    The error happens in the method "TppPDFUtils.NumFontGlyphs". But it
    happens only if certain fonts are used. Our customer uses the font
    "Avenir LT Std 35 Light" in one of the reports and with this font he
    gets that error from time to time.

    If we take that report and replace the font by "Arial" or "Tahoma" for
    example that error does not happen anymore.

    The problem is now that i am not able to tell the customer "just use
    another font" because the font is part of his corporate design and
    cannot be changed.

    Any idea why one font could cause the "Canvas does not allow drawing"
    and another font does not?


    Am 24.02.2017 um 08:06 schrieb Kaiser:
  • edited March 2017
    Hi Ralf,

    I do not have the "Avenir..." font on my machine. The PDF device
    extensively uses numerous Windows API font processing routines and we
    test these with all the standard fonts installed with the operating system.

    It could be that the Avenir font is a custom font and is invalid for
    certain API calls.

    If you would like, you can send me a copy of this font and I can run
    some tests here with RB 18. support@digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
  • edited March 2017
    Hi Nico,

    I have sent the customer now a speccial version of the software that was
    created using RB 18. Now i will wait for a response if the error ist
    still there.


    Am 16.03.2017 um 17:24 schrieb Nico Cizik (Digital Metaphors):
  • edited March 2017
    Am 16.03.2017 um 17:24 schrieb Nico Cizik (Digital Metaphors):

    Hi Nico,

    I sent the font to support@digital-metaphors.com this morning.

  • edited March 2017
    Hello Nico,

    I have already sent the font to the given address. Did the mail not
    reach you?


    Am 16.03.2017 um 17:24 schrieb Nico Cizik (Digital Metaphors):
  • edited March 2017
    Hi Ralf,

    Sorry for the delay. We received your email and have been researching
    the problem. I just sent you an email response. I included my response


    Thanks for the font files. After some debugging, it appears that these
    fonts are being seen by the Windows API as Device Fonts which will
    prevent them from being embedded or processed correctly. There was a
    bug that was fixed for RB 15 as device type fonts cannot be processed
    correctly so a substitute font is now used.

    After some research I found that the AvenirLTStd font is a free version
    of the Avenir Font Family and from what I can tell is likely poorly
    made. All the OpenType/TrueType fonts provided by Microsoft with
    Windows behave correctly and are able to be embedded without issues in
    PDF. I suggest that your users use a different font or perhaps a
    registered version of the Avenir font (Avenir Next) if they would like
    it to be properly embedded into a PDF file.

    Best Regards,

    Nico Cizik
    Digital Metaphors
This discussion has been closed.