Results 1 to 7 of 7

Thread: Is MuPDF consistent with Qt4 GUI apps?

  1. #1
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Is MuPDF consistent with Qt4 GUI apps?

    I am trying to create an app which fixes "bad" PDFs: PDFs without ToC (I mean outline tree - create ToC), PDFs with duplicate pages (delete them) or "quickly created" PDFs made by joining several other PDFs (senseless items in ToC, usually names of the PDF parts, senseless pages, etc. - delete all this). Such PDFs often contain useful information but in useless form so fix it.

    I need something for manipulating a PDF (I am trying PoDoFo) and something for displaying a page because PoDoFo cannot render a page image. I already have got a bad experience with poppler-qt - very ugly images, as if they came from middle 90s. So I compiled MuPDF ver. 1.3 and tried it.

    When I created a "non Qt" project in the Creator and let MuPDF render several pages of a test PDF (storing them in files), the result was splendid. When I created a Qt GUI project, the project worked until I started using MuPDF. With MuPDF, all texts vanished from the app and I got bags of error messages:
    Qt Code:
    1. render glyph failed err=13 face=0x29d1eb0, glyph=51
    2. <many similar lines>
    To copy to clipboard, switch view to plain text mode 

    The end. Does anybody know what is it all about? And why poppler-qt produces such ugly images? Many PDF apps use poppler and results aren't ugly. With poppler, I tried this:
    Qt Code:
    1. Poppler::Document *document = Poppler::Document::load(filename); // in fact, not here but in OpenPDF()
    2. Poppler::Page *pdfPage = document->page(pageNumber);
    3. QImage image = pdfPage->renderToImage();
    4.  
    5. <display image in the page window>
    6.  
    7. delete pdfPage;
    8. delete document; // in fact, not here but in ClosePDF()
    To copy to clipboard, switch view to plain text mode 

    What am I doing wrong?

  2. The following user says thank you to Radek for this useful post:

    louboutinoutlet (1st December 2013)

  3. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is MuPDF consistent with Qt4 GUI apps?

    Just a guess, but have you tried higher DPI values when rendering with Poppler?

    Alterantively you could check the code of Poppler using programs, e.g. KDE's Okular.

    Cheers,
    _

  4. #3
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is MuPDF consistent with Qt4 GUI apps?

    Yes, I have tried it. MuPDF renders at 96 DPI, so I have tried the default (72 DPI, ugly), 96 DPI (the image size is like the MuPDF image size - but the result was equally ugly), 144 DPI (no improvement).

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Is MuPDF consistent with Qt4 GUI apps?

    All guesses ... The missing text and error message looks like muPDF does not have, or know where to find, whatever font is used in the PDF file (or can find the font but it does not contain the relevant glyph). This could happen with PDFs that do not embed non-standard fonts or if you have missed some processing step for handling embedded fonts.

  6. #5
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is MuPDF consistent with Qt4 GUI apps?

    The error message comes not from MuPDF but from Qt. As long as you haven't linked MuPDF libraries, the GUI is okay. Also, if you create a non-Qt project with MuPDF (update the example.c from MuPDF so that you get a C++ Qt non-Qt project), the output is okay. The error messages pop up when you link MuPDF libraries to a Qt GUI project.

    The MuPDF libraries seem to interfere with Qt rendering somehow. You need not even activate MuPDF from the GUI project. It's enough to write a MuPDF-based "RenderPage()", add the libraries and compile. You need not call RenderPage() actually. You lose all texts, including menus, labels on buttons and similar texts in the app. All these texts were pure ASCII. No exotic glyphs.

    As to the Poppler: Antialiasing is off completely by default. If someone reads this then the output can be improved considerably by
    Qt Code:
    1. document = Poppler::Document::load("/home/radek/wk/test.pdf");
    2.  
    3. document->setRenderHint(Poppler::Document::TextAntialiasing);
    4. document->setRenderHint(Poppler::Document::Antialiasing);
    5.  
    6. ...
    To copy to clipboard, switch view to plain text mode 

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Is MuPDF consistent with Qt4 GUI apps?

    Ah, I read the problem as the text went missing from the generated PDF, not from the Qt GUI.

    MuPDF has an internal version of freetype that may well be colliding with the version Qt is built with. Is it possible to build MuPDF with the system freetype?

  8. The following user says thank you to ChrisW67 for this useful post:

    Radek (2nd December 2013)

  9. #7
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Thanks
    3
    Thanked 65 Times in 59 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Is MuPDF consistent with Qt4 GUI apps?

    Correct. Removing mupdf/libfreetype.a from the profile file seems to solve the problem. At least, the project compiles and runs - with the lost texts back.

Similar Threads

  1. values' decimal places not consistent
    By babygal in forum Newbie
    Replies: 1
    Last Post: 15th June 2011, 05:25
  2. Applying a consistent background
    By KanadaKid in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2009, 17:56
  3. Replies: 0
    Last Post: 26th June 2009, 17:53
  4. Replies: 1
    Last Post: 15th May 2009, 07:16
  5. Replies: 2
    Last Post: 9th January 2009, 19:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.