document.pdfConverter().convert() to pipe silently fails
I'm using the following snippet of code to write a Poppler document to a file descriptor:
def write_pdf(fd, document): converter = document.pdfConverter() converter.setPDFOptions(converter.pdfOptions() | Poppler.PDFConverter.WithChanges) qfile = QFile() qfile.open(fd, QIODevice.WriteOnly) converter.setOutputDevice(qfile) if not converter.convert(): raise IOError(converter.lastError())
This is working fine when
fd is a regular file, but when it is a pipe, some documents are corrupted when written to the pipe. My assumption is that Poppler tries to seek in the output file without checking the error code.
Assuming that Poppler actually needs to seek in the output file for some input files at least, I think it would also make sense to always check if the output file is seekable and to fail if it is not. Otherwise, programs using Poppler will appear to work fine when they are actually subtly broken.