Created attachment 104631 [details] Example program Files loaded through the poppler_document_new_from_stream() call seem not to be loaded correctly. While I can access all pages from PDFs, rendering fails halfway through a page, and on stderr I see Syntax Error (153504): Unexpected end of file in flate stream Syntax Error: Unterminated string Syntax Error: End of file inside array Syntax Error: Leftover args in content stream If I load the same file into a char array and use poppler_document_new_from_data(), the file renderes fine. I'll attach an example program, example PDF file, and screenshots of expected and actual renderings. I've compiled the example using cc test.c -o test $(pkg-config --libs --cflags gtk+-3.0 glib-2.0 cairo gio-2.0 poppler-glib) and tested against a clean build of the latest poppler git (commit e62e18e).
Created attachment 104632 [details] Example PDF
Created attachment 104633 [details] Flawed rendering
I'll skip the screensout of the expected output - pdfJS displays it correctly, Evince also does.
Created attachment 104634 [details] Example program Uploaded the wrong version before; fixed the example.
I did some debugging and believe that the error lies in PopplerInputStream. I don't understand how you use sub streams and copies yet though, therefore I haven't been able to fix it. What I've found: At the top of PopplerInputStream::fillBuf(), I added some lines to check if bufPos coincides with the output of g_seekable_tell. When loading fails, it does not. Another thing is that this seems to be a race condition: When I add sufficiently much debug output or blur/refocus the window to enforce a redraw, the output is rendered correctly.
Created attachment 104667 [details] [review] Bugfix
With the bugfix I've uploaded earlier, the bug is gone.
Comment on attachment 104667 [details] [review] Bugfix Thanks for the patch and sorry the delay reviewing it. I'm not sure this is the right fix, I think the actual problem is that saved member is not initialized, and a call to close() is making an invalid seek. I've found some other issues while debugging this, so I'll fix all of them.
Created attachment 106201 [details] [review] Another patch Could you confirm this patch fixes the problem for you?
For the latest git version (f74a596) your patch also resolves the problem for me, in my example program as well as in the application where I actually need the function.
(In reply to comment #10) > For the latest git version (f74a596) your patch also resolves the problem > for me, in my example program as well as in the application where I actually > need the function. Thanks for testing it. I've pushed the patch to both master and poppler-0.26 branches.
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.