Package org.apache.pdfbox.pdmodel
Class PDPageContentStream
java.lang.Object
org.apache.pdfbox.pdmodel.PDAbstractContentStream
org.apache.pdfbox.pdmodel.PDPageContentStream
- All Implemented Interfaces:
Closeable,AutoCloseable
Provides the ability to write to a page content stream.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThis is to choose what to do with the stream: overwrite, append or prepend. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.apache.commons.logging.Logprivate booleanFields inherited from class org.apache.pdfbox.pdmodel.PDAbstractContentStream
document, fontStack, inTextMode, nonStrokingColorSpaceStack, outputStream, resources, strokingColorSpaceStack -
Constructor Summary
ConstructorsModifierConstructorDescriptionPDPageContentStream(PDDocument doc, PDAppearanceStream appearance) Create a new appearance stream.PDPageContentStream(PDDocument doc, PDAppearanceStream appearance, OutputStream outputStream) Create a new appearance stream.PDPageContentStream(PDDocument document, PDPage sourcePage) Create a new PDPage content stream.PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress) Create a new PDPage content stream.PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext) Create a new PDPage content stream.privatePDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext, PDStream stream, PDResources resources) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendRawCommands(byte[] commands) Deprecated.Usage of this method is discouraged.voidappendRawCommands(double data) Deprecated.Usage of this method is discouraged.voidappendRawCommands(float data) Deprecated.Usage of this method is discouraged.voidappendRawCommands(int data) Deprecated.Usage of this method is discouraged.voidappendRawCommands(String commands) Deprecated.Usage of this method is discouraged.Methods inherited from class org.apache.pdfbox.pdmodel.PDAbstractContentStream
addComment, addRect, beginMarkedContent, beginMarkedContent, beginText, clip, clipEvenOdd, close, closeAndFillAndStroke, closeAndFillAndStrokeEvenOdd, closeAndStroke, closePath, curveTo, curveTo1, curveTo2, drawForm, drawImage, drawImage, drawImage, drawImage, drawImage, endMarkedContent, endText, fill, fillAndStroke, fillAndStrokeEvenOdd, fillEvenOdd, getName, isOutside255Interval, lineTo, moveTo, newLine, newLineAtOffset, restoreGraphicsState, saveGraphicsState, setCharacterSpacing, setFont, setGraphicsStateParameters, setHorizontalScaling, setLeading, setLineCapStyle, setLineDashPattern, setLineJoinStyle, setLineWidth, setMaximumFractionDigits, setMiterLimit, setNonStrokingColor, setNonStrokingColor, setNonStrokingColor, setNonStrokingColor, setNonStrokingColor, setNonStrokingColorSpaceStack, setRenderingMode, setStrokingColor, setStrokingColor, setStrokingColor, setStrokingColor, setStrokingColor, setStrokingColorSpaceStack, setTextMatrix, setTextRise, setWordSpacing, shadingFill, showText, showTextInternal, showTextWithPositioning, stroke, transform, write, writeBytes, writeLine, writeOperand, writeOperand, writeOperand, writeOperator
-
Field Details
-
LOG
private static final org.apache.commons.logging.Log LOG -
sourcePageHadContents
private boolean sourcePageHadContents
-
-
Constructor Details
-
PDPageContentStream
Create a new PDPage content stream. This constructor overwrites all existing content streams of this page.- Parameters:
document- The document the page is part of.sourcePage- The page to write the contents to.- Throws:
IOException- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress) throws IOException Create a new PDPage content stream. If the appendContent parameter is set toPDPageContentStream.AppendMode.APPEND, you may want to usePDPageContentStream(PDDocument, PDPage, PDPageContentStream.AppendMode, boolean, boolean)instead, with the fifth parameter set to true.- Parameters:
document- The document the page is part of.sourcePage- The page to write the contents to.appendContent- Indicates whether content will be overwritten, appended or prepended.compress- Tell if the content stream should compress the page contents.- Throws:
IOException- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext) throws IOException Create a new PDPage content stream.- Parameters:
document- The document the page is part of.sourcePage- The page to write the contents to.appendContent- Indicates whether content will be overwritten, appended or prepended.compress- Tell if the content stream should compress the page contents.resetContext- Tell if the graphic context should be reset. This is only relevant when the appendContent parameter is set toPDPageContentStream.AppendMode.APPEND. You should use this when appending to an existing stream, because the existing stream may have changed graphic properties (e.g. scaling, rotation).- Throws:
IOException- If there is an error writing to the page contents.
-
PDPageContentStream
private PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress, boolean resetContext, PDStream stream, PDResources resources) throws IOException - Throws:
IOException
-
PDPageContentStream
Create a new appearance stream. Note that this is not actually a "page" content stream.- Parameters:
doc- The document the page is part of.appearance- The appearance stream to write to.- Throws:
IOException- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance, OutputStream outputStream) Create a new appearance stream. Note that this is not actually a "page" content stream.- Parameters:
doc- The document the appearance is part of.appearance- The appearance stream to add to.outputStream- The appearances output stream to write to.
-
-
Method Details
-
appendRawCommands
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
commands- The commands to append to the stream.- Throws:
IOException- If an error occurs while writing to the stream.
-
appendRawCommands
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
commands- The commands to append to the stream.- Throws:
IOException- If an error occurs while writing to the stream.
-
appendRawCommands
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
data- Append a raw byte to the stream.- Throws:
IOException- If an error occurs while writing to the stream.
-
appendRawCommands
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
data- Append a formatted double value to the stream.- Throws:
IOException- If an error occurs while writing to the stream.
-
appendRawCommands
Deprecated.Usage of this method is discouraged.This will append raw commands to the content stream.- Parameters:
data- Append a formatted float value to the stream.- Throws:
IOException- If an error occurs while writing to the stream.
-