C1PdfDocument DrawImage Exception

Posted by: kevin.banks on 3 June 2020, 2:11 am EST

    • Post Options:
    • Link

    Posted 3 June 2020, 2:11 am EST

    Really two part question…

    I’m drawing directly into a PDF from C# and it is working good except for a call to DrawImage. It throws an exception saying “Pdf document is closed: call Clear() to start a new one before adding any content.”

    This is the same document that I have been writing to and continue writing in. I call Clear() before writing anything into it. So message appears to be incorrect.

    I cant get past the writing of an image (logo) into my pdf so I tried to find a way to write an SVG image. Any suggestions?

  • Posted 3 June 2020, 9:32 am EST

    Hi Kevin,

    I’d recommend you to take a look at the product sample: ‘PdfSamples’ and refer the method ‘CreateDocumentImages’. This method draws string and image on a PDF instance.

    You can find the application installed here: \Documents\ComponentOne Samples\UWP\C1.UWP.Pdf\CS\PdfSamples

    Hope this helps.



  • Posted 3 June 2020, 9:55 am EST

    Hi Ruchir

    I couldn’t run the sample as the project is VS 2015. I didn’t take the time to try and sort it out to run in my environment VS-2019.


    Doesnt change the fact that all other DrawXXX commands work and DrawImage fails…

  • Posted 5 June 2020, 1:54 am EST

    Is there a new Project…

  • Posted 5 June 2020, 7:13 am EST

    Hi Kevin,

    I am not sure why the sample is not working for VS19 at your end, as I am running it with VS19 itself. Still, you can refer to sample code snippet using the following code: https://www.grapecity.com/componentone/docs/uwp/online-pdf/Adding_Images.html

    If the issue does not resolve, please share a demo app. demonstrating the problem. It will help us assist you accordingly in resolving the problem.



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels