Package org.apache.pdfbox.pdmodel
Class PDPageContentStream
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.PDAbstractContentStream
-
- org.apache.pdfbox.pdmodel.PDPageContentStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public final class PDPageContentStream extends PDAbstractContentStream implements java.io.Closeable
Provides the ability to write to a page content stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPDPageContentStream.AppendModeThis is to choose what to do with the stream: overwrite, append or prepend.
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.commons.logging.LogLOGprivate booleansourcePageHadContents-
Fields inherited from class org.apache.pdfbox.pdmodel.PDAbstractContentStream
document, fontStack, inTextMode, nonStrokingColorSpaceStack, outputStream, resources, strokingColorSpaceStack
-
-
Constructor Summary
Constructors Modifier Constructor Description PDPageContentStream(PDDocument doc, PDAppearanceStream appearance)Create a new appearance stream.PDPageContentStream(PDDocument doc, PDAppearanceStream appearance, java.io.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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidappendRawCommands(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(java.lang.String commands)Deprecated.Usage of this method is discouraged.-
Methods inherited from class org.apache.pdfbox.pdmodel.PDAbstractContentStream
addComment, addRect, beginMarkedContent, 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, setMarkedContentPoint, setMarkedContentPointWithProperties, 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
-
-
-
-
Constructor Detail
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage) throws java.io.IOException
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:
java.io.IOException- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument document, PDPage sourcePage, PDPageContentStream.AppendMode appendContent, boolean compress) throws java.io.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:
java.io.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 java.io.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:
java.io.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 java.io.IOException
- Throws:
java.io.IOException
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance) throws java.io.IOException
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:
java.io.IOException- If there is an error writing to the page contents.
-
PDPageContentStream
public PDPageContentStream(PDDocument doc, PDAppearanceStream appearance, java.io.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 Detail
-
appendRawCommands
@Deprecated public void appendRawCommands(java.lang.String commands) throws java.io.IOExceptionDeprecated.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:
java.io.IOException- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(byte[] commands) throws java.io.IOExceptionDeprecated.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:
java.io.IOException- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(int data) throws java.io.IOExceptionDeprecated.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:
java.io.IOException- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(double data) throws java.io.IOExceptionDeprecated.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:
java.io.IOException- If an error occurs while writing to the stream.
-
appendRawCommands
@Deprecated public void appendRawCommands(float data) throws java.io.IOExceptionDeprecated.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:
java.io.IOException- If an error occurs while writing to the stream.
-
-