Class 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.
    • Field Detail

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • sourcePageHadContents

        private boolean sourcePageHadContents
    • 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,
                                   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 to PDPageContentStream.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

        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.IOException
        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:
        java.io.IOException - If an error occurs while writing to the stream.
      • appendRawCommands

        @Deprecated
        public void appendRawCommands​(byte[] commands)
                               throws java.io.IOException
        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:
        java.io.IOException - If an error occurs while writing to the stream.
      • appendRawCommands

        @Deprecated
        public void appendRawCommands​(int data)
                               throws java.io.IOException
        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:
        java.io.IOException - If an error occurs while writing to the stream.
      • appendRawCommands

        @Deprecated
        public void appendRawCommands​(double data)
                               throws java.io.IOException
        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:
        java.io.IOException - If an error occurs while writing to the stream.
      • appendRawCommands

        @Deprecated
        public void appendRawCommands​(float data)
                               throws java.io.IOException
        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:
        java.io.IOException - If an error occurs while writing to the stream.