Philipp Klaus Krause wrote: > Craig Ringer schrieb: > >> - If the document being imported is of a PDF version newer than the >> PDF being exported, problems may arise. >> It's probably best to rasterise the input PDF (like we do now) in >> this situation. In theory you could scan the >> content streams of the input PDF and check if it actually used >> features not supported by the current PDF >> version (like transparency and layers if you're exporting PDF 1.3) >> but this is difficult and may not be entirely >> reliable. > > Isn't there a way to handle this situation similar to the one below (so > we cankeep the vector stuff)? MAybe just going through pdf2ps and ps2df > to reduce the pdf version number?
As Andreas noted, that'll cause transparency flattening if the PDF uses transparency. Other interesting effects may also be observed, such as the conversion of text to images (!) under some circumstances. You'll lose all annotations (hyperlinks, comments, attached files, etc), but that's likely to happen with a simplistic XObject approach too. I guess that using gs to reduce PDF to PS-3 level feature use is better than rasterising the entire document. Very recent gs versions do a pretty good job retaining correct appearance with pdf2ps and ps2pdf but I'd still want to do a bunch of testing before relying on this instead of going straight to raster. What you ideally want to do is examine the page's content stream(s) and determine if they actually use any unsupported features rather than just relying on the version number. Distiller, the Adobe PDF printer, and quite a few other PDF producing apps like to set their highest supported version by default. There's also Acrobat, which sets the PDF version to the maximum supported by that version of Acrobat even if all you did is, say, alter the media box. [The cynic might wonder if this is a sales strategy on Adobe's part]. Scanning the content stream(s) would be rather more advanced, though, and relying on the PDF version would do for starters. It'd probably be necessary to provide a preference, though probably not an import-time option, to control how wrong version PDFs were handled: "Warn and import anyway" "Convert to PDF 1.3 (will convert transparency and complex graphics to raster images)" "Convert entire PDF to raster image" -- Craig Ringer
