diff options
author | Simon Steiner <ssteiner@apache.org> | 2017-09-25 13:42:23 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2017-09-25 13:42:23 +0000 |
commit | 10e0d1c238b40735c51c1bf841fe7bf4f6418dda (patch) | |
tree | cb345d57beb4dc0264d88db1f3d655426c690035 /fop-core/src | |
parent | 1decbe283fa2c27fb382bd61cc4ac8b97db6839c (diff) | |
download | xmlgraphics-fop-10e0d1c238b40735c51c1bf841fe7bf4f6418dda.tar.gz xmlgraphics-fop-10e0d1c238b40735c51c1bf841fe7bf4f6418dda.zip |
FOP-2740: PDF to PostScript tiling pattern error in Acrobat
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1809628 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src')
6 files changed, 30 insertions, 3 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSDocumentHandler.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSDocumentHandler.java index 62c7ffeb8..aa91453cf 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSDocumentHandler.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSDocumentHandler.java @@ -163,6 +163,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { //Setup for PostScript generation this.gen = new FOPPSGeneratorImpl(out); this.gen.setPSLevel(psUtil.getLanguageLevel()); + this.gen.setAcrobatDownsample(psUtil.isAcrobatDownsample()); this.currentPageNumber = 0; this.documentBoundingBox = new Rectangle2D.Double(); @@ -294,7 +295,7 @@ public class PSDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { ResourceHandler handler = new ResourceHandler(getUserAgent(), eventProducer, this.fontInfo, resTracker, this.formResources); handler.process(in, this.outputStream, - this.currentPageNumber, this.documentBoundingBox); + this.currentPageNumber, this.documentBoundingBox, psUtil); this.outputStream.flush(); } catch (DSCException e) { throw new RuntimeException(e.getMessage()); diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfig.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfig.java index eb2b7ce42..4df5e6bad 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfig.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfig.java @@ -36,6 +36,7 @@ import org.apache.fop.fonts.FontEventAdapter; import org.apache.fop.render.RendererConfig; import org.apache.fop.util.LogUtil; +import static org.apache.fop.render.ps.PSRendererOption.ACROBAT_DOWNSAMPLE; import static org.apache.fop.render.ps.PSRendererOption.AUTO_ROTATE_LANDSCAPE; import static org.apache.fop.render.ps.PSRendererOption.DSC_COMPLIANT; import static org.apache.fop.render.ps.PSRendererOption.LANGUAGE_LEVEL; @@ -85,6 +86,10 @@ public final class PSRendererConfig implements RendererConfig { return (PSRenderingMode) params.get(RENDERING_MODE); } + public Boolean isAcrobatDownsample() { + return (Boolean) params.get(ACROBAT_DOWNSAMPLE); + } + /** * The PostScript renderer configuration data parser. */ @@ -124,6 +129,7 @@ public final class PSRendererConfig implements RendererConfig { setBoolConfigParam(cfg, OPTIMIZE_RESOURCES); setBoolConfigParam(cfg, SAFE_SET_PAGE_DEVICE); setBoolConfigParam(cfg, DSC_COMPLIANT); + setBoolConfigParam(cfg, ACROBAT_DOWNSAMPLE); Configuration child = cfg.getChild("rendering"); if (child != null) { config.params.put(RENDERING_MODE, diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfigurator.java index 3540732d7..752d6a6bf 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfigurator.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererConfigurator.java @@ -58,6 +58,9 @@ public class PSRendererConfigurator extends DefaultRendererConfigurator { if (psConfig.getRenderingMode() != null) { psUtil.setRenderingMode(psConfig.getRenderingMode()); } + if (psConfig.isAcrobatDownsample() != null) { + psUtil.setAcrobatDownsample(psConfig.isAcrobatDownsample()); + } } @Override diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererOption.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererOption.java index 992ca1959..eaeab00b3 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererOption.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSRendererOption.java @@ -37,7 +37,8 @@ public enum PSRendererOption implements RendererConfigOption { SAFE_SET_PAGE_DEVICE("safe-set-page-device", false), /** Indicates whether the PostScript output should be DSC compliant, default: true*/ DSC_COMPLIANT("dsc-compliant", true), - RENDERING_MODE("rendering", PSRenderingMode.QUALITY); + RENDERING_MODE("rendering", PSRenderingMode.QUALITY), + ACROBAT_DOWNSAMPLE("acrobat-downsample", false); private final String name; private final Object defaultValue; diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/PSRenderingUtil.java b/fop-core/src/main/java/org/apache/fop/render/ps/PSRenderingUtil.java index cae8a0440..13d54fb3b 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/PSRenderingUtil.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/PSRenderingUtil.java @@ -33,6 +33,7 @@ import org.apache.fop.render.ps.extensions.PSCommentBefore; import org.apache.fop.render.ps.extensions.PSExtensionAttachment; import org.apache.fop.render.ps.extensions.PSSetupCode; +import static org.apache.fop.render.ps.PSRendererOption.ACROBAT_DOWNSAMPLE; import static org.apache.fop.render.ps.PSRendererOption.AUTO_ROTATE_LANDSCAPE; import static org.apache.fop.render.ps.PSRendererOption.LANGUAGE_LEVEL; import static org.apache.fop.render.ps.PSRendererOption.OPTIMIZE_RESOURCES; @@ -56,6 +57,7 @@ public class PSRenderingUtil { private boolean autoRotateLandscape; private int languageLevel = PSGenerator.DEFAULT_LANGUAGE_LEVEL; + private boolean acrobatDownsample; /** Determines whether the PS file is generated in two passes to minimize file size */ private boolean optimizeResources; @@ -86,6 +88,10 @@ public class PSRenderingUtil { if (obj != null) { setOptimizeResources(booleanValueOf(obj)); } + obj = userAgent.getRendererOptions().get(ACROBAT_DOWNSAMPLE.getName()); + if (obj != null) { + setAcrobatDownsample(booleanValueOf(obj)); + } } private boolean booleanValueOf(Object obj) { @@ -281,6 +287,14 @@ public class PSRenderingUtil { return languageLevel; } + public void setAcrobatDownsample(boolean b) { + acrobatDownsample = b; + } + + public boolean isAcrobatDownsample() { + return acrobatDownsample; + } + /** * Controls whether PostScript resources are optimized in a second pass over the document. * Enable this to obtain smaller PostScript files. diff --git a/fop-core/src/main/java/org/apache/fop/render/ps/ResourceHandler.java b/fop-core/src/main/java/org/apache/fop/render/ps/ResourceHandler.java index 42eea5dfd..ac3ad5b10 100644 --- a/fop-core/src/main/java/org/apache/fop/render/ps/ResourceHandler.java +++ b/fop-core/src/main/java/org/apache/fop/render/ps/ResourceHandler.java @@ -139,16 +139,18 @@ public class ResourceHandler implements DSCParserConstants, PSSupportedFlavors { * @param pageCount the number of pages (given here because PSRenderer writes an "(atend)") * @param documentBoundingBox the document's bounding box * (given here because PSRenderer writes an "(atend)") + * @param psUtil * @throws DSCException If there's an error in the DSC structure of the PS file * @throws IOException In case of an I/O error */ public void process(InputStream in, OutputStream out, - int pageCount, Rectangle2D documentBoundingBox) + int pageCount, Rectangle2D documentBoundingBox, PSRenderingUtil psUtil) throws DSCException, IOException { DSCParser parser = new DSCParser(in); parser.setCheckEOF(false); PSGenerator gen = new PSGenerator(out); + gen.setAcrobatDownsample(psUtil.isAcrobatDownsample()); parser.addListener(new DefaultNestedDocumentHandler(gen)); parser.addListener(new IncludeResourceListener(gen)); |