git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1809628 13f79535-47bb-0310-9956-ffa450edef68pull/6/head
@@ -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()); |
@@ -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, |
@@ -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 |
@@ -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; |
@@ -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. |
@@ -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)); | |||