From 9c1fd9bd11710b9e1797718a31db5192c1ac8fb4 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 28 Jan 2014 06:06:09 +1030 Subject: [PATCH 8/8] pdftops: ensure there is always a page size in the output even if the PDF file as badly broken. --- poppler/PSOutputDev.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/poppler/PSOutputDev.cc b/poppler/PSOutputDev.cc index 34b7cbd..a85fc24 100644 --- a/poppler/PSOutputDev.cc +++ b/poppler/PSOutputDev.cc @@ -1257,6 +1257,13 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, if (!paperMatch) { w = paperWidth; h = paperHeight; + if (w < 0 || h < 0) { + // Unable to obtain a paper size from the document and no page size + // specified. In this case use A4 as the page size to ensure the PS output is + // valid. This will only occur if the PDF is very broken. + w = 595; + h = 842; + } } else if (noCropA) { w = (int)ceil(page->getMediaWidth()); h = (int)ceil(page->getMediaHeight()); -- 1.8.3.2