Top Description Inners Fields Constructors Methods
org.apache.pdfbox.examples.printing

public Class OpaquePDFRenderer

extends PDFRenderer
Class Inheritance
Imports
java.awt.print.Printable, .PrinterException, .PrinterJob, java.io.IOException, java.net.URI, .URISyntaxException, java.util.List, javax.print.PrintServiceLookup, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.Loader, org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine, .PDFStreamEngine, org.apache.pdfbox.contentstream.operator.MissingOperandException, .Operator, .OperatorName, .OperatorProcessor, org.apache.pdfbox.contentstream.operator.graphics.GraphicsOperatorProcessor, org.apache.pdfbox.cos.COSBase, .COSName, org.apache.pdfbox.io.RandomAccessReadBuffer, org.apache.pdfbox.pdmodel.MissingResourceException, .PDDocument, org.apache.pdfbox.pdmodel.graphics.PDXObject, org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject, org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject, org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState, org.apache.pdfbox.printing.PDFPrintable, .Scaling, org.apache.pdfbox.rendering.PDFRenderer, .PageDrawer, .PageDrawerParameters

PDF documents with transparency are sometimes printed slowly and in poor quality, see PDFBOX-4123 and PDFBOX-5605. If the transparency isn't really needed (e.g. for most labels), we can use a custom PDFRenderer / PageDrawer that uses a custom DrawObject class which doesn't call showTransparencyGroup() but only showForm() and sets ca and CA to 1.

This OpaquePDFRenderer class object can be passed to the "long" constructor of PDFPrintable#PDFPrintable(org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.printing.Scaling, boolean, float, boolean, org.apache.pdfbox.rendering.PDFRenderer).

Author
Tilman Hausherr

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Inherited from org.apache.pdfbox.rendering.PDFRenderer:
document

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected PageDrawer
createPageDrawer(PageDrawerParameters
parameters to be used when creating the PageDrawer instance
parameters
)

Overrides org.apache.pdfbox.rendering.PDFRenderer.createPageDrawer.

Returns a new PageDrawer instance, using the given parameters.

public static void
main(String[] args)

Inherited from org.apache.pdfbox.rendering.PDFRenderer:
getAnnotationsFiltergetDefaultDestinationgetImageDownscalingOptimizationThresholdgetRenderingHintsisGroupEnabledisSubsamplingAllowedrenderImagerenderImagerenderImagerenderImagerenderImageWithDPIrenderImageWithDPIrenderPageToGraphicsrenderPageToGraphicsrenderPageToGraphicsrenderPageToGraphicssetAnnotationsFiltersetDefaultDestinationsetImageDownscalingOptimizationThresholdsetRenderingHintssetSubsamplingAllowed

Constructor Detail

OpaquePDFRendererback to summary
public OpaquePDFRenderer(PDDocument document)

Method Detail

createPageDrawerback to summary
protected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException

Overrides org.apache.pdfbox.rendering.PDFRenderer.createPageDrawer.

Doc from org.apache.pdfbox.rendering.PDFRenderer.createPageDrawer.

Returns a new PageDrawer instance, using the given parameters. May be overridden.

Parameters
parameters:PageDrawerParameters

parameters to be used when creating the PageDrawer instance

Returns:PageDrawer

a new PageDrawer instance

Annotations
@Override
Exceptions
IOException:
id the PageDrawer instance could not be created
mainback to summary
public static void main(String[] args) throws IOException, PrinterException, URISyntaxException
Annotations
@SuppressWarnings:java:S1075
org.apache.pdfbox.examples.printing back to summary

private Class OpaquePDFRenderer.OpaqueDrawObject

extends GraphicsOperatorProcessor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getName()

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.getName.

Returns the name of this operator, e.g. "BI".

public void
process(Operator
the operator to process
operator
,
List<COSBase>
the operands to use when processing
operands
)

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.process.

Process the operator.

Inherited from org.apache.pdfbox.contentstream.operator.graphics.GraphicsOperatorProcessor:
getGraphicsContext

Field Detail

LOGback to summary
private static final Log LOG

Constructor Detail

OpaqueDrawObjectback to summary
public OpaqueDrawObject(PDFGraphicsStreamEngine context)

Method Detail

getNameback to summary
public String getName()

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.getName.

Doc from org.apache.pdfbox.contentstream.operator.OperatorProcessor.getName.

Returns the name of this operator, e.g. "BI".

Returns:String

the name of the operator

Annotations
@Override
processback to summary
public void process(Operator operator, List<COSBase> operands) throws IOException

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.process.

Doc from org.apache.pdfbox.contentstream.operator.OperatorProcessor.process.

Process the operator.

Parameters
operator:Operator

the operator to process

operands:List<COSBase>

the operands to use when processing

Annotations
@Override
Exceptions
IOException:
if the operator cannot be processed
org.apache.pdfbox.examples.printing back to summary

private Class OpaquePDFRenderer.OpaquePageDrawer

extends PageDrawer
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from org.apache.pdfbox.rendering.PageDrawer:
appendRectanglebeginMarkedContentSequencebeginTextclipclosePathcurveTodrawImagedrawPageendMarkedContentSequenceendPathendTextfillAndStrokePathfillPathgetAnnotationFiltergetCurrentPointgetGraphicsgetLinePathgetNonStrokingPaintgetPaintgetRenderergetSubsamplinglineTomoveTosetAnnotationFiltersetClipshadingFillshowAnnotationshowFontGlyphshowFormshowTransparencyGroupshowTransparencyGroupOnGraphicsshowType3GlyphstrokePathtransferClip

Constructor Detail

OpaquePageDrawerback to summary
public OpaquePageDrawer(PageDrawerParameters parameters) throws IOException
org.apache.pdfbox.examples.printing back to summary

private Class OpaquePDFRenderer.OpaqueSetGraphicsStateParameters

extends OperatorProcessor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final Log

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getName()

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.getName.

Returns the name of this operator, e.g. "BI".

public void
process(Operator
the operator to process
operator
,
List<COSBase>
the operands to use when processing
arguments
)

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.process.

Process the operator.

Inherited from org.apache.pdfbox.contentstream.operator.OperatorProcessor:
checkArrayTypesClassgetContext

Field Detail

LOGback to summary
private static final Log LOG

Constructor Detail

OpaqueSetGraphicsStateParametersback to summary
public OpaqueSetGraphicsStateParameters(PDFStreamEngine context)

Method Detail

getNameback to summary
public String getName()

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.getName.

Doc from org.apache.pdfbox.contentstream.operator.OperatorProcessor.getName.

Returns the name of this operator, e.g. "BI".

Returns:String

the name of the operator

Annotations
@Override
processback to summary
public void process(Operator operator, List<COSBase> arguments) throws IOException

Implements abstract org.apache.pdfbox.contentstream.operator.OperatorProcessor.process.

Doc from org.apache.pdfbox.contentstream.operator.OperatorProcessor.process.

Process the operator.

Parameters
operator:Operator

the operator to process

arguments:List<COSBase>

the operands to use when processing

Annotations
@Override
Exceptions
IOException:
if the operator cannot be processed