1. 21 Jul, 2021 1 commit
    • Oliver Sander's avatar
      Use additional samples to test for constant parts of an axial gradient · c97d3153
      Oliver Sander authored
      The method doAxialShFill does adaptive sampling of gradients.
      If the gradient color is found to be the same at two consecutive
      sampling locations then the gradient is concluded to be constant
      between the two locations.
      
      Of course, this conclusion may be wrong; one instance of this
      happening is
      
        poppler/poppler#938
      
      This patch fixes rendering of the test file in issue 938 by doing
      one more sampling when a part of the gradient is suspected to be
      constant.  Of course it is easily possible to create gradients
      also misrender with the additional sampling point.  Should such
      gradients ever appear in actual non-synthetic documents the code
      can now easily handle yet more sample points.
      
      Fixes: poppler/poppler#938
      c97d3153
  2. 14 Jul, 2021 1 commit
    • Oliver Sander's avatar
      Make getPdfVersion return a dedicated version object · 13c95f25
      Oliver Sander authored and Albert Astals Cid's avatar Albert Astals Cid committed
      That's a bit more modern than the old way where pointers to two
      integers had to be passed to the method.
      
      With the new method you can write
      
        auto pdfVersion = doc->getPdfVersion();
        // access numbers as pdfVersion.major and pdfVersion.minor
      
      instead of
      
        int major, minor;
        doc->getPdfVersion(&major, &minor);
      
      With C++17 you can even write
      
        auto [major, minor] = doc->getPdfVersion();
      
      The new method is put alongside the old one in the Qt5 interface.
      It replaces the old one in the Qt6 interface.
      13c95f25
  3. 12 Jul, 2021 2 commits
    • Nelson Benítez León's avatar
      glib: mimick TextSelectionDumper logic change for spaceAfter · fdb83a88
      Nelson Benítez León authored and Albert Astals Cid's avatar Albert Astals Cid committed
      Commit d6cccfb8 caused
      issue #1100 because that change in the TextSelectionDumper
      logic *must be mimicked* in poppler_page_get_text_layout_for_area()
      and in poppler_page_get_text_attributes_for_area() because
      all those functions must be consistent with each other in
      the way they traverse and extract the text from the PDF.
      
      Otherwise, wrong results may happen when using them
      to map between graphical coordinates of text glyphs and
      their corresponding positions in the text obtained from
      poppler_page_get_text() (which uses TextSelectionDumper
      to extract the text).
      
      Fixes issue #1100
      fdb83a88
    • Nelson Benítez León's avatar
      Add glib test for issue #1100 · e2f7f5e8
      Nelson Benítez León authored and Albert Astals Cid's avatar Albert Astals Cid committed
      e2f7f5e8
  4. 10 Jul, 2021 1 commit
  5. 08 Jul, 2021 2 commits
  6. 06 Jul, 2021 3 commits
  7. 05 Jul, 2021 1 commit
  8. 04 Jul, 2021 2 commits
    • Uli Schlachter's avatar
      Better error messages when libopenjpeg2 is not found · fcdff7bb
      Uli Schlachter authored and Albert Astals Cid's avatar Albert Astals Cid committed
      
      
      When I run "cmake -DENABLE_DCTDECODER=none -DENABLE_BOOST=OFF" on my
      system, I get the following output:
      
          -- Found Iconv: /usr/lib/x86_64-linux-gnu/libc.so
          CMake Warning at CMakeLists.txt:252 (find_package):
            By not providing "FindOpenJPEG.cmake" in CMAKE_MODULE_PATH this project has
            asked CMake to find a package configuration file provided by "OpenJPEG",
            but CMake did not find one.
      
            Could not find a package configuration file provided by "OpenJPEG" with any
            of the following names:
      
              OpenJPEGConfig.cmake
              openjpeg-config.cmake
      
            Add the installation prefix of "OpenJPEG" to CMAKE_PREFIX_PATH or set
            "OpenJPEG_DIR" to a directory containing one of the above files.  If
            "OpenJPEG" provides a separate development package or SDK, be sure it has
            been installed.
      
          CMake Error at CMakeLists.txt:255 (message):
            Install libopenjpeg2 before trying to build poppler.  You can also decide
            to use the internal unmaintained JPX decoder or none at all.
      
          -- Configuring incomplete, errors occurred!
          See also "/tmp/poppler/build/CMakeFiles/CMakeOutput.log".
          See also "/tmp/poppler/build/CMakeFiles/CMakeError.log".
      
      To figure out what exactly to do now, I have to read some
      CMakeLists.txt. This commit improves the situation by producing the
      following output instead:
      
          -- Found Iconv: /usr/lib/x86_64-linux-gnu/libc.so
          CMake Warning at CMakeLists.txt:254 (find_package):
            By not providing "FindOpenJPEG.cmake" in CMAKE_MODULE_PATH this project has
            asked CMake to find a package configuration file provided by "OpenJPEG",
            but CMake did not find one.
      
            Could not find a package configuration file provided by "OpenJPEG" with any
            of the following names:
      
              OpenJPEGConfig.cmake
              openjpeg-config.cmake
      
            Add the installation prefix of "OpenJPEG" to CMAKE_PREFIX_PATH or set
            "OpenJPEG_DIR" to a directory containing one of the above files.  If
            "OpenJPEG" provides a separate development package or SDK, be sure it has
            been installed.
      
          -- Could NOT find openjpeg2.
          CMake Error at CMakeLists.txt:258 (message):
            Install libopenjpeg2 before trying to build poppler.  You can also decide
            to use the internal unmaintained JPX decoder or none at all.
      
            Possible options are: -DENABLE_LIBOPENJPEG=openjpeg2,
            -DENABLE_LIBOPENJPEG=none, -DENABLE_LIBOPENJPEG=unmaintained,
      
          -- Configuring incomplete, errors occurred!
          See also "/tmp/poppler/build/CMakeFiles/CMakeOutput.log".
          See also "/tmp/poppler/build/CMakeFiles/CMakeError.log".
      Signed-off-by: Uli Schlachter's avatarUli Schlachter <psychon@znc.in>
      fcdff7bb
    • Uli Schlachter's avatar
      Better error message when libjpeg is not found · 27ea06e3
      Uli Schlachter authored and Albert Astals Cid's avatar Albert Astals Cid committed
      
      
      When I run cmake on my system, I get the following output:
      
          -- Checking for module 'nss>=3.19'
          --   Package 'nss', required by 'virtual:world', not found
          -- Could NOT find NSS3 (missing: NSS3_LIBRARIES NSS3_CFLAGS)
          CMake Error at CMakeLists.txt:149 (message):
            Install libjpeg before trying to build poppler.  You can also decide to use
            the internal unmaintained DCT decoder or none at all.
      
          -- Configuring incomplete, errors occurred!
          See also "/tmp/poppler/build/CMakeFiles/CMakeOutput.log".
          See also "/tmp/poppler/build/CMakeFiles/CMakeError.log".
      
      Being (badly) trained in CMake errors, I see "Could NOT find NSS3" and
      conclude that this is the problem. I do not even read the actual error
      message.
      
      This commit improves the situation by producing the following output
      instead:
      
          -- Checking for module 'nss>=3.19'
          --   Package 'nss', required by 'virtual:world', not found
          -- Could NOT find NSS3 (missing: NSS3_LIBRARIES NSS3_CFLAGS)
          -- Could NOT find libjpeg.
          CMake Error at CMakeLists.txt:150 (message):
            Install libjpeg before trying to build poppler.  You can also decide to use
            the internal unmaintained DCT decoder or none at all.
      
            Possible options are: -DENABLE_DCTDECODER=libjpeg,
            -DENABLE_DCTDECODER=none, -DENABLE_DCTDECODER=unmaintained
      
          -- Configuring incomplete, errors occurred!
          See also "/tmp/poppler/build/CMakeFiles/CMakeOutput.log".
          See also "/tmp/poppler/build/CMakeFiles/CMakeError.log".
      
      This also explicitly lists the possible values for the parameter that I
      figured out by reading the code around CMakeLists.txt:151.
      Signed-off-by: Uli Schlachter's avatarUli Schlachter <psychon@znc.in>
      27ea06e3
  9. 02 Jul, 2021 2 commits
  10. 01 Jul, 2021 2 commits
    • Oliver Sander's avatar
      JBIG2Stream: Do not abort if size-0 allocations returns nullptr · 2b280871
      Oliver Sander authored
      The JBIG2SymbolDict constructor gets a size parameter, and it allocates
      memory for a bitmap of that size.  Bug report 535
      
        poppler/poppler#535
      
      has a file where this size is 0.  In that case, the call to
      gmallocn_checkoverflow returns nullptr, and subsequent calls to
      JBIG2SymbolDict::isOk return false.  This is then interpreted
      as an error, and the JBIG2 processing is aborted.  For the
      test file mentioned above this happens in line 1807.
      
      I don't know whether such a file with a size-0 symbol dict
      is malformed or not.  However, the test file renders just fine
      if the 'failing' allocation is simply ignored.  This patch
      therefore relaxes the isOk method a little.  A JBIG2SymbolDict
      object is now deemed 'ok' either if it holds a bitmap (that was
      the previous test) *or if it has size 0*.
      
      This fixes
      
        poppler/poppler#535
      2b280871
    • Uli Schlachter's avatar
      ~CairoOutputDev(): Free textClipPath · 571d8138
      Uli Schlachter authored
      The textClipPath member is set in CairoOutputDev::endString() and freed
      in CairoOutputDev::endTextObject(). However, if endTextObject() is not
      called for whatever reason, the path will just be leaked.
      
      This adds code to the destructor to free this.
      
      This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=32326
      
      Testing done:
      
      $ wget -O testcase 'https://oss-fuzz.com/download?testcase_id=6659952325296128'
      [...]
      $ cmake .. -G Ninja -DENABLE_DCTDECODER=unmaintained -DENABLE_BOOST=OFF -DENABLE_LIBOPENJPEG=unmaintained && ninja
      [...]
      $ git describe
      poppler-21.06.1-5-gb7c40059
      
      
      $ valgrind --leak-check=full ./utils/pdftocairo testcase -png foo
      [...]
      ==104075==
      ==104075== HEAP SUMMARY:
      ==104075==     in use at exit: 28,292 bytes in 55 blocks
      ==104075==   total heap usage: 6,114 allocs, 6,059 frees, 1,617,444 bytes allocated
      ==104075==
      ==104075== 24 bytes in 1 blocks are definitely lost in loss record 4 of 37
      ==104075==    at 0x483877F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==104075==    by 0x48AE748: ??? (in /usr/lib/x86_64-linux-gnu/libcairo.so.2.11600.0)
      ==104075==    by 0x118995: endString (CairoOutputDev.cc:1474)
      ==104075==    by 0x118995: CairoOutputDev::endString(GfxState*) (CairoOutputDev.cc:1412)
      ==104075==    by 0x4B97295: Gfx::doShowText(GooString const*) (Gfx.cc:4010)
      ==104075==    by 0x4B97CB4: Gfx::opShowSpaceText(Object*, int) (Gfx.cc:3793)
      ==104075==    by 0x4B8D866: Gfx::go(bool) (Gfx.cc:681)
      ==104075==    by 0x4B8DCFA: display (Gfx.cc:642)
      ==104075==    by 0x4B8DCFA: Gfx::display(Object*, bool) (Gfx.cc:622)
      ==104075==    by 0x4BE1A83: Page::displaySlice(OutputDev*, double, double, int, bool, bool, int, int, int, int, bool, bool (*)(void*), void*, bool (*)(Annot*, void*), void*, bool) (Page.cc:576)
      ==104075==    by 0x11317C: renderPage (pdftocairo.cc:669)
      ==104075==    by 0x11317C: main (pdftocairo.cc:1183)
      ==104075==
      ==104075== LEAK SUMMARY:
      ==104075==    definitely lost: 24 bytes in 1 blocks
      ==104075==    indirectly lost: 0 bytes in 0 blocks
      ==104075==      possibly lost: 0 bytes in 0 blocks
      ==104075==    still reachable: 28,268 bytes in 54 blocks
      ==104075==         suppressed: 0 bytes in 0 blocks
      ==104075== Reachable blocks (those to which a pointer was found) are not shown.
      ==104075== To see them, rerun with: --leak-check=full --show-leak-kinds=all
      ==104075==
      ==104075== For lists of detected and suppressed errors, rerun with: -s
      ==104075== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
      $ git checkout cairo-leak-textClipPath && git describe && ninja
      Zu Branch 'cairo-leak-textClipPath' gewechselt
      poppler-21.06.1-6-g8df6f8d2
      $ valgrind --leak-check=full ./utils/pdftocairo testcase -png foo
      [...]
      ==104263==
      ==104263== HEAP SUMMARY:
      ==104263==     in use at exit: 28,268 bytes in 54 blocks
      ==104263==   total heap usage: 6,114 allocs, 6,060 frees, 1,617,444 bytes allocated
      ==104263==
      ==104263== LEAK SUMMARY:
      ==104263==    definitely lost: 0 bytes in 0 blocks
      ==104263==    indirectly lost: 0 bytes in 0 blocks
      ==104263==      possibly lost: 0 bytes in 0 blocks
      ==104263==    still reachable: 28,268 bytes in 54 blocks
      ==104263==         suppressed: 0 bytes in 0 blocks
      ==104263== Reachable blocks (those to which a pointer was found) are not shown.
      ==104263== To see them, rerun with: --leak-check=full --show-leak-kinds=all
      ==104263==
      ==104263== For lists of detected and suppressed errors, rerun with: -s
      ==104263== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
      
      As you (might) see, before this commit, there is a "definitely lost"
      leak of 24 bytes with this test case. After this commit, this leak is
      gone.
      Signed-off-by: Uli Schlachter's avatarUli Schlachter <psychon@znc.in>
      571d8138
  11. 26 Jun, 2021 1 commit
  12. 16 Jun, 2021 2 commits
  13. 15 Jun, 2021 1 commit
  14. 14 Jun, 2021 2 commits
  15. 03 Jun, 2021 1 commit
  16. 02 Jun, 2021 1 commit
  17. 01 Jun, 2021 1 commit
  18. 29 May, 2021 1 commit
  19. 28 May, 2021 1 commit
  20. 27 May, 2021 1 commit
  21. 25 May, 2021 3 commits
  22. 20 May, 2021 3 commits
  23. 19 May, 2021 1 commit
  24. 14 May, 2021 4 commits