com.aspose.pdf

Interfaces

Classes

Enums

Exceptions

com.aspose.pdf

Class Page

  • All Implemented Interfaces:
    com.aspose.ms.System.IDisposable


    public final class Page
    extends Object
    implements com.aspose.ms.System.IDisposable

    Class representing page of PDF document.

    • Field Detail

      • EnginePage

        public com.aspose.pdf.engine.commondata.IPage EnginePage
        For Internal usage only
    • Method Detail

      • getBackgroundImage

        public final Image getBackgroundImage()

        Gets or sets background image for page (for generator only).

        Returns:
        Image instance
      • setBackgroundImage

        public final void setBackgroundImage(Image value)

        Gets or sets background image for page (for generator only).

        Parameters:
        value - Image instance
      • getTocInfo

        public TocInfo getTocInfo()

        Gets table of contents info.

        Returns:
        The table of contents info - default null. If it set this page will contain table of contents.
      • setTocInfo

        public void setTocInfo(TocInfo value)

        Sets table of contents info.

        Parameters:
        value - The table of contents info - default null. If it set this page will contain table of contents.
      • getHeader

        public HeaderFooter getHeader()

        Gets page header.

        Returns:
        The page header.
      • setHeader

        public void setHeader(HeaderFooter value)

        Sets page header.

        Parameters:
        value - The page header.
      • getLayers

        public List<Layer> getLayers()

        Gets layers collection.

        Returns:
        Value: The layers collection.
      • setLayers

        public void setLayers(ArrayList<Layer> value)

        Sets layers collection.

        Parameters:
        value - : The layers collection.
      • setLayersInternal

        public void setLayersInternal(com.aspose.ms.System.Collections.Generic.List<Layer> value)

        Sets layers collection.

        Parameters:
        value - : The layers collection.
      • getFooter

        public HeaderFooter getFooter()

        Gets page Footer.

        Returns:
        The page Footer.
      • setFooter

        public void setFooter(HeaderFooter value)

        Sets page Footer.

        Parameters:
        value - The page Footer.
      • getParagraphs

        public Paragraphs getParagraphs()

        Gets the paragraphs.

        Returns:
        The paragraphs.
      • setParagraphs

        public void setParagraphs(Paragraphs value)

        Sets the paragraphs.

        Parameters:
        value - Paragraphs value
      • getPageInfo

        public PageInfo getPageInfo()

        Gets the page info.(for generator only)

        Returns:
        The page info.
      • setPageInfo

        public void setPageInfo(PageInfo value)

        Sets the page info.(for generator only)

        Parameters:
        value - The page info.
      • convertToPNGMemoryStream

        public byte[] convertToPNGMemoryStream()
        Convert page to PNG for DSR, OMR , OCR
        Returns:
        byte[] array.
      • getDocument

        public IDocument getDocument()

        Get document

        Returns:
        IDocument object
      • getRect

        public Rectangle getRect()

        Gets rectangle of the page. Page crop box is returned if specified, otherwise page media box is returned.

        Returns:
        Rectangle value
         Example demonstrates how to get page rectangle:
        
         Document document = new Document("sample.pdf");
         Page page = document.getPages().get(1);
         Rectangle pageRect = page.getRect();
         
      • getRect_Rename_Namesake

        public Rectangle getRect_Rename_Namesake()

        Gets rectangle of the page. Page crop box is returned if specified, otherwise page media box is returned. Please note that this property don't consider page rotation. To get page rectangle considering rotation please use ActualRect.


         Example demonstrates how to get page rectangle:
        
         Document document = new Document("sample.pdf");
         Page page = document.getPages().get_Item(1);
         Rectangle pageRect = page.getRect();
         
        Returns:
        Rectangle object
      • setRect

        public void setRect(Rectangle value)

        Sets rectangle of the page. Page crop box is returned if specified, otherwise page media box is returned. Please note that this property don't consider page rotation. To get page rectangle considering rotation please use ActualRect.

        Parameters:
        value - Rectangle object
      • getColorType

        public int getColorType()

        Gets color type of the pages based on information getting from operators SetColor, images and forms.

        Returns:
        ColorType element
        See Also:
        ColorType
      • getNoteLineStyle

        public GraphInfo getNoteLineStyle()

        Gets the line style for notes.(for generator only)

        Returns:
        GraphInfo value
      • setNoteLineStyle

        public void setNoteLineStyle(GraphInfo value)

        Sets the line style for notes.(for generator only)

        Parameters:
        value - : GraphInfo value
      • isBlank

        public boolean isBlank(double fillThresholdFactor)

        Gets the flag whether page is blank or not.

        Parameters:
        fillThresholdFactor - The fill threshold value that manages the sensitivity of detection. Should be equal or greater than 0.01.
        Returns:
        boolean value
      • getPageRect

        public Rectangle getPageRect(boolean considerRotation)

        Returns rectangle of the page.

        Parameters:
        considerRotation - If true then rotation of the page will be considered in rect calculation.
        Returns:
        Rectangle of the page.
      • calculateContentBBox

        public Rectangle calculateContentBBox()

        Calculates bbox value - rectangle containing contents without visible margins.

        Returns:
        Bbox value - rectangle containing contents without visible margins
      • getTabOrder

        public int getTabOrder()

        Gets tab order of the page. Possible values: Row, Column. Default, Manual

        Returns:
        TabOrder value
        See Also:
        TabOrder
      • setTabOrder

        public void setTabOrder(int value)

        Sets tab order of the page. Possible values: Row, Column. Default, Manual

        Parameters:
        value - TabOrder object
        See Also:
        TabOrder
      • getDuration

        public double getDuration()

        Gets page display duration. This is time in seconds that page shall be displayed during presentation. Returs -1 if duration is not defined.


        Example demonstrates how to get page duration

        Document document = new Document("sample.pdf"); Page page = document.getPages().get(1); int pageRect = page.getDuration();

        Returns:
        double value
      • setDuration

        public void setDuration(double value)

        Sets page display duration. This is time in seconds that page shall be displayed during presentation.

        Parameters:
        value - page display duration.
      • getContents

        public OperatorCollection getContents()

        Gets collection of operators in the content stream of the page. OperatorCollection

        Returns:
        OperatorCollection object
         Example is demonstrates how to scan operators stream of page.
        
        
         Document document = new Document("sample.pdf");
         Operators contents = document.getPages().get_Item(1).getContents();
         for(Operator op :  (Iterable<Operator>)contents)
         {
             System.out.println(op);
         }
        
         
      • getGroup

        public Group getGroup()

        Gets a group attributes class specifying the attributes of the page's page group for use in the transparent imaging model.

        Returns:
        Group value
      • setGroup

        public void setGroup(Group value)

        Sets a group attributes class specifying the attributes of the page's page group for use in the transparent imaging model.

        Parameters:
        value - Group value
      • getAnnotations

        public AnnotationCollection getAnnotations()

        Gets collection of page annotations. Annotations

        Returns:
        AnnotationCollection value
      • getResources

        public Resources getResources()

        Gets page resources. Resources object contains collections of images, forms and fonts. Resources

        Returns:
        Resources value
         Example demonstrates scan through page images:
        
        
         Document document = new Document("sample.pdf");
         DocumentActions actions = document.getActions();
         Resources resources = document.getPages().get(1).getResources();
         for(XImage image :  (Ierable<XImage>)resources.getImages())
         {
           System.out.println(image.getWidth() + ":" + image.getHeight());
         }
        
         
      • getRotate

        public int getRotate()

        Gets rotation of the page.

        Returns:
        Rotation element
         Example demonstrates how to determine page rotation.
        
        
         Document document = new Document("sample.pdf");
         System.out.println(document.getPages().get(1).getRotate());
         
        See Also:
        Rotation
      • setRotate

        public void setRotate(int value)

        Sets rotation of the page.

        Parameters:
        value - Rotation element
        See Also:
        Rotation
      • getTrimBox

        public Rectangle getTrimBox()

        Gets trim box of the page.

        Returns:
        Rectangle value
         Example demonstrates how to get trim box of the page:
        
        
         Document document = new Document("sample.pdf");
         Rectangle trimBox = document.getPages().get(1).getTrimBox();
         
      • setTrimBox

        public void setTrimBox(Rectangle value)

        Sets trim box of the page.

        Parameters:
        value - Rectangle value
      • getArtBox

        public Rectangle getArtBox()

        Gets art box of the page.

        Returns:
        Rectangle value
         Example demonstrates how to get art box of the page:
        
        
         Document document = new Document("sample.pdf");
         Rectangle artBox = document.getPages().get(1).getArtBox();
         
      • setArtBox

        public void setArtBox(Rectangle value)

        Sets art box of the page.

        Parameters:
        value - Rectangle value
      • getBleedBox

        public Rectangle getBleedBox()

        Gets bleed box of the page.

        Returns:
        Rectangle value
         Example demonstrates how to get bleed box of the page:
        
        
         Document document = new Document("sample.pdf");
         Rectangle bleedBox = document.getPages().get(1).getBleedBox();
         
      • setBleedBox

        public void setBleedBox(Rectangle value)

        Sets bleed box of the page.

        Parameters:
        value - Rectangle value
      • getCropBox

        public Rectangle getCropBox()

        Gets crop box of the page.

        Returns:
        Rectangle value
         Example demonstrates how to get crop box of the page:
        
        
         Document document = new Document("sample.pdf");
         Rectangle cropBox = document.getPages().get_Item(1).getCropBox();
         
      • setCropBox

        public void setCropBox(Rectangle value)

        Sets crop box of the page.


         Example demonstrates how to get crop box of the page:
        
        
         Document document = new Document("sample.pdf");
         document.getPages().get_Item(1).setCropBox(new Rectangle(0d,0d,100d,100d));
         
        Parameters:
        value - Rectangle object
      • getMediaBox

        public Rectangle getMediaBox()

        Gets media box of the page.

        Returns:
        Rectangle value
         Example demonstrates how to get media box of the page:
        
        
         Document document = new Document("sample.pdf");
         Rectangle mediaBox = document.getPages().get(1).getMediaBox();
         
      • setMediaBox

        public void setMediaBox(Rectangle value)

        Sets media box of the page.

        Parameters:
        value - Rectangle
      • sendTo

        public void sendTo(PageDevice device,
                           OutputStream output)

        Sends page to process with given page device.

        Parameters:
        device - The device to process page.
        output - Result stream which is used with device to save its output.
      • accept

        public void accept(AnnotationSelector visitor)

        Accepts AnnotationSelector visitor object that provides functionality to work with annotations.

        Parameters:
        visitor - Annotation selector sobject.
      • rotationToInt

        public static int rotationToInt(int rotation)

        Translates rotation enumeration member into integer value.

        Parameters:
        rotation - Rotation enumeratioom member.
        Returns:
        Corresponding integer value
        See Also:
        Rotation
      • intToRotation

        public static int intToRotation(int rotation)

        Translates integer value into corresponding rotation enumeration member.

        Parameters:
        rotation - Integer value to convert
        Returns:
        Rotation enumeration member
        See Also:
        Rotation
      • addStamp

        public void addStamp(Stamp stamp)

        Put stamp into page. Stamp can be page number, image or simple text, e.g. some logo.

        Parameters:
        stamp - Stamp to add on the page. Each stamp has its coordinates and corresponding properties regarding to the kind of stamp, i.e. image or text value.
      • addImage

        public void addImage(InputStream imageStream,
                             Rectangle imageRect)

        Adds image onto the page and locates it in the middle of specified rectangle saving image's proportion.

        Parameters:
        imageStream - The stream of the image.
        imageRect - The position of the image.
      • addImage

        public void addImage(String hocr,
                             InputStream imageStream,
                             Rectangle imageRect)

        Adds searchable image onto the page and locates it in the middle of specified rectangle saving image's proportion.

        Parameters:
        hocr - The hocr of the image.
        imageStream - The stream of the image.
        imageRect - The position of the image.
      • addImage

        public void addImage(InputStream imageStream,
                             Rectangle imageRect,
                             int imageWidth,
                             int imageHeight,
                             boolean saveImageProportions)

        Adds searchable image onto the page and locates it in the middle of specified rectangle saving image's proportion.

        Parameters:
        imageStream - InputStream object
        imageRect - Rectangle object
        imageWidth - int value
        imageHeight - int value
        saveImageProportions - boolean value
      • addImage

        public void addImage(String imagePath,
                             Rectangle rectangle)

        Adds image onto the page and locates it in the middle of specified rectangle saving image's proportion.

        Parameters:
        imagePath - The path to image.
        rectangle - The position of the image.
      • addImage

        public void addImage(InputStream stream,
                             Rectangle rectangle,
                             CompositingParameters compositingParameters)

        Adds image onto the page and locates it in the middle of specified rectangle saving image's proportion.

        Parameters:
        stream - The stream of the image.
        rectangle - The position of the image.
        compositingParameters - The compositing parameters.
      • sendTo

        public void sendTo(PageDevice device,
                           String outputFileName)

        Sends page to process with given page device.

        Parameters:
        device - The device to process page.
        outputFileName - File which is used with device to save its output.
      • flatten

        public void flatten()

        Removes all static fields located on the page and place their values instead.

      • accept

        public void accept(TextFragmentAbsorber visitor)

        Accepts TextFragmentAbsorber visitor object that provides functionality to work with text objects.

        Parameters:
        visitor - Text absorber object.
      • accept

        public void accept(ImagePlacementAbsorber visitor)

        Accepts ImagePlacementAbsorber visitor object that provides functionality to work with image placement objects.

        Parameters:
        visitor - Image placement absorber object.
      • accept

        public void accept(TextAbsorber visitor)

        Accepts TextAbsorber visitor object that provides functionality to work with text objects.

        Parameters:
        visitor - Text absorber object.
      • setPageSize

        public void setPageSize(double width,
                                double height)

        Sets page size for page.

        Parameters:
        width - Page width.
        height - Page size.
      • setTransition

        public void setTransition(com.aspose.pdf.engine.data.IPdfDictionary transition)

        Set transition

        Parameters:
        transition - IPdfDictionary object
      • getNumber

        public int getNumber()

        Get number of the page.

        Returns:
        int value
      • getRotationMatrix

        public Matrix getRotationMatrix()

        Gets transfomation matrix for the page.

        Returns:
        Matrix value
      • getContentsAppender

        public ContentsAppender getContentsAppender()

        Gets current contents appender. ContentsAppender

        Returns:
        ContentsAppender value
      • getBackground

        public Color getBackground()

        Gets the background color of the page.

        Returns:
        Color value
      • setBackground

        public void setBackground(Color value)

        Sets the background color of the page.

        Parameters:
        value - Color object
      • setBackground

        public void setBackground(Color value)

        Sets the background color of the page.

        Parameters:
        value - Color object
      • getWatermark

        public Watermark getWatermark()

        Gets the watermark of the page.

        Returns:
        Watermark value
      • setWatermark

        public void setWatermark(Watermark value)

        Sets the watermark of the page.

        Parameters:
        value - Watermark object
      • removeObjectReferences

        public void removeObjectReferences(String name)

        Remove references to XObject from page contents (i.e. all Do operators which use name of object).

        Parameters:
        name - String value
      • removeObjectReferences

        public static void removeObjectReferences(OperatorCollection contents,
                                                  String name)

        Remove object references

        Parameters:
        contents - OperatorCollection object
        name - value
      • findReferences

        public List<Object> findReferences(String name)

        Find references

        Parameters:
        name - String value
        Returns:
        List<Object> object
      • findReferences

        public static List<Object> findReferences(OperatorCollection contents,
                                                  String name)

        Returns list of operators which uses resource with specified name.

        Parameters:
        contents - OperatorCollection value
        name - String value
        Returns:
        List of Object
      • dispose

        public void dispose()

        Frees up memory

        Specified by:
        dispose in interface com.aspose.ms.System.IDisposable
      • fillUsedObjectsTable

        public void fillUsedObjectsTable(com.aspose.ms.System.Collections.Generic.Dictionary<Integer,Integer> usageTable,
                                         com.aspose.pdf.engine.data.IPdfDictionary CommonResources)
      • deleteUnusedResources

        public void deleteUnusedResources(com.aspose.ms.System.Collections.Generic.Dictionary<Integer,Integer> usageTable)
      • clearContents

        public void clearContents()
        For internal usage only
      • getArtifacts

        public ArtifactCollection getArtifacts()

        Gets collection of artifacts on the page.

        Returns:
        ArtifactCollection value
      • getActions

        public PageActionCollection getActions()

        Gets collection of page properties.

        Returns:
        PageActionCollection value
      • makeGrayscale

        public void makeGrayscale()

        Converts images on page as grayscaled.

      • freeMemory

        public void freeMemory()

        Clears cached data

      • getNotifications

        public String getNotifications()

        Returns notifications about inside operations with page content. (Only notifications about paragraph events in text adding scenarios are supported now.)

        Returns:
        String representing notifications about inside operations with page content.
      • asByteArray

        public byte[] asByteArray(Resolution resolution)

        Converts current page as BMP bitmap and than returns array of bytes.

        Parameters:
        resolution - The resolution.
        Returns:
        Converted array of image bytes.
      • asXml

        public String asXml()

        Converts current page as xml in utf8 encoding.

        Returns:
        Converted xml string.
      • getFieldsInTabOrder

        public List<Field> getFieldsInTabOrder()

        Gets list of Field object in Tab order on this page.

        Returns:
        List of field objects