Menu

#43 Faulty PDF

2.0
closed
zyx
None
2022-08-13
2022-06-10
No

Hi, when I print a metafile into a PDF with litePDF, the result is a faulty PDF. Acrobat Reader says it's buggy. I assume the metafile is correct. At least it can be displayed in e.g. OpenOffice without any problems. The EMF is also attached as a text file. I have little idea about the internals of litePDF. Can you help to localize the error in litePDF? Thank you!

1 Attachments

Related

Tickets: #37

Discussion

  • zyx

    zyx - 2022-06-10

    Thanks for a bug report. Do you use any SDK (which one, if so) or you build the latest sources on your own, please? I noticed something similar with the latest sources once, thinking it was my fault (due to some tests) and didn't pay much attention to it.

    If I read it correctly there's no text output, only drawing primitives. Then I'd guess the problem is possibly in the header/info of the PDF file. I need to dive into it, but I cannot promise when it'll be. My free time is limited at the moment.

    If you can, try to use older SDK, whether it'll work properly with it. It can help to pin-point which change broke the PDF generation.

     
  • ralf stocker

    ralf stocker - 2022-06-10

    Thanks for the answer. No, I'm using the omf dll from the SDK. I've gone through all the SDKs back to 2.0.0. Always the same error.

     
    • zyx

      zyx - 2022-06-10

      Nice, thank your for a quick and thorough testing of this. I thought it's a regression after some update (possibly a PoDoFo update, which is used for the low-level manipulation), but if all the SDK versions generate for adobe reader broken PDF, then it is not a regression.

      By the way, trying to open your PDF in evince 41.2 doesn't claim any error. It may not mean much, it can be the evince is just more forgiving (or the Adobe Reader less permissive after some update).

       
  • ralf stocker

    ralf stocker - 2022-06-10

    If I load the PDF into PDFcreator and then save it, the error is gone in Adobe. The wrong code will probably be removed or the PDF normalized.

     

    Last edit: ralf stocker 2022-06-10
    • zyx

      zyx - 2022-06-13

      Interesting. I do not have that application. Would you mind to share the re-saved PDF file, please? It can be compared and hopefully found out what causes the problem. My understanding is that it's either in the drawing stream, or in the PDF data itself. What's the most weird, it begun to show only recently, I didn't see it with the old versions, which is the reason why I wanted to re-test with the old versions first.

       
  • ralf stocker

    ralf stocker - 2022-06-13

    Please see my attachment. PDFcreator is free: https://www.pdfforge.org/

     
  • zyx

    zyx - 2022-06-13

    Thanks you for the test case. There seems to be a problem in the drawing stream, probably a pop of the graphics context, without corresponding (pair) push. I'll investigate this further.

    Just by an accident, a user opened a thread about similar problem, this time using PoDoFo directly, but there it looks like a problem with the font. At least on the first look. You can see the thread on their mailing list.

     
  • ralf stocker

    ralf stocker - 2022-06-13

    Exactly my mistake! You have found it. Thanks. Then now we have to wait for Podofo 1.0...

     
  • zyx

    zyx - 2022-06-14

    Exactly my mistake! You have found it.

    Do you mean you made the "pop" call, somehow accessing PoDoFo through the litePDF directly or even using the RestoreDC() GDI function without a pair SaveDC()? The list of the EMF instructions shows exactl one SaveDC() call and exactly one RestoreDC() call, from which I guess the problem is on the litePDF side, not on the way you use it.

     
  • ralf stocker

    ralf stocker - 2022-06-14

    No, I just meant that the error from the poster is exactly the same as mine.

     
  • zyx

    zyx - 2022-07-09
    • status: open --> closed
     
  • zyx

    zyx - 2022-07-09

    I fixed this in [r34]. The problem was handling of the MetaRgn, which is handled as saving the graphics context and restore it on restore, but the MetaRgn count was "inherited" incorrectly between saved graphics states, causing too many calls to Restore() and in turn an invalid PDF content stream.

     

    Related

    Commit: [r34]

  • ralf stocker

    ralf stocker - 2022-07-09

    Great! Would you please create a new SDK too (litePDF-2.0.5.0-SDK)? I have no working C tool chain at the moment to build the DLLs.

     
  • zyx

    zyx - 2022-07-09

    I'm waiting for [#41] resolution, after which I plan to make a new release.

     

    Related

    Tickets: #41

  • zyx

    zyx - 2022-08-06

    Hi, only a quick info, I just made a 2.0.5.0 release. Let me know if it won't work for you. Thanks and bye, zyx.

     
  • ralf stocker

    ralf stocker - 2022-08-06

    Hi, thanks for the new release. Unfortunately the clipping is now broken. Please compare test__with_2040.pdf and test__with_2050.pdf. The circle should be clipped into half. Which is not.

     
  • zyx

    zyx - 2022-08-08

    Hmm, that's bad. I cannot get to this before weekend, unless anything more urgent will postpone it a bit further. I'll let you know when I have anything.

     
  • zyx

    zyx - 2022-08-08
    • status: closed --> open
     
  • zyx

    zyx - 2022-08-13

    By the way, my antivirus claims your litePDF_test.exe in the .zip file contains a virus and prevents me to open the file.

     
  • zyx

    zyx - 2022-08-13

    The change for [#37] doesn't work well here. I'll reopen that ticket instead. Please, follow it for any further updates.

     

    Related

    Tickets: #37

  • zyx

    zyx - 2022-08-13
    • status: open --> closed
     
  • ralf stocker

    ralf stocker - 2022-08-13

    Ok, thanks. 5 out of 71 virus scanners on Virustotal report a virus. Would say that's a false positive.

     
    • zyx

      zyx - 2022-08-13

      True, I guess so too.

      Please see https://sourceforge.net/p/litepdf/tickets/37/#2431 for a test litePDF.dll

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.