com.aspose.pdf.facades

Class PdfPageEditor

  • All Implemented Interfaces:
    com.aspose.ms.System.IDisposable, IFacade, ISaveableFacade


    public final class PdfPageEditor
    extends SaveableFacade

    Represents a class to edit the PDF file's page, including rotating page, zooming page, moving position and changing page size.

    • Constructor Detail

      • PdfPageEditor

        public PdfPageEditor()

        Constructor for PdfPageEditor class.

      • PdfPageEditor

        public PdfPageEditor(Document document)

        Constructor for PdfPageEditor class.

        Parameters:
        document - Document object which should be processed.
    • Method Detail

      • getTransitionDuration

        public int getTransitionDuration()

        Gets duration of the transition effect.

        Returns:
        int value
      • setTransitionDuration

        public void setTransitionDuration(int value)

        Sets duration of the transition effect.

        Parameters:
        value - int value
      • getTransitionType

        public int getTransitionType()

        Gets transition style to use when moving to this page from another during a presentation.

        Returns:
        int value
      • setTransitionType

        public void setTransitionType(int value)

        Sets transition style to use when moving to this page from another during a presentation.

        Parameters:
        value - int value
      • getDisplayDuration

        public int getDisplayDuration()

        Gets display duration for pages.

        Returns:
        int value
      • setDisplayDuration

        public void setDisplayDuration(int value)

        Sets display duration for pages.

        Parameters:
        value - int value
      • getProcessPages

        public int[] getProcessPages()

        Gets the page numbers to be edited. By default, each page would be edited.

        Returns:
        array of int values
      • setProcessPages

        public void setProcessPages(int[] value)

        Sets the page numbers to be edited. By default, each page would be edited.

        Parameters:
        value - array of int values
      • getRotation

        public int getRotation()

        Gets the rotation of the pages, the rotation must be 0, 90, 180 or 270. Default value is 0.

        Returns:
        int value
      • setRotation

        public void setRotation(int value)

        Sets the rotation of the pages, the rotation must be 0, 90, 180 or 270. Default value is 0.

        Parameters:
        value - int value
      • getPageRotations

        public Map<Integer,Integer> getPageRotations()

        Gets the rotation of the pages, A hashtable contains the page number and rotation degree, the key represents the page number, the value of key represents the rotation in degrees.

        Returns:
        Map<Integer, Integer> object
      • setPageRotations

        public void setPageRotations(Map<Integer,Integer> value)

        Sets the rotation of the pages, A hashtable contains the page number and rotation degree, the key represents the page number, the value of key represents the rotation in degrees.

        Parameters:
        value - Map<Integer, Integer> object
      • getZoom

        public float getZoom()

        Get zoom coefficient. Value 1.0 corresponds to 100%. Default value is 1.0.

        Returns:
        float value
      • setZoom

        public void setZoom(float value)

        Sets zoom coefficient. Value 1.0 corresponds to 100%. Default value is 1.0.

        Parameters:
        value - float value
         The following example demonstrates how to change zoom of the document pages.
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         editor.setZoom ( 0.5f);
         
      • getPageSize

        public PageSize getPageSize()

        Gets the output file's page size.

        Returns:
        PageSize object
      • setPageSize

        public void setPageSize(PageSize value)

        Sets the output file's page size.

        Parameters:
        value - PageSize object
      • getAlignment

        @Deprecated
        public AlignmentType getAlignment()
        Deprecated. 

        Gets the horizontal alignment of the original PDF content on the result page, default is AlignmentType.Left.
        Use getHorizontalAlignment instead

        Returns:
        AlignmentType object
        See Also:
        HorizontalAlignment
      • setAlignment

        @Deprecated
        public void setAlignment(AlignmentType value)
        Deprecated. 

        Sets the horizontal alignment of the original PDF content on the result page, default is AlignmentType.Left.
        Use setHorizontalAlignment instead

        Parameters:
        value - AlignmentType value
      • getHorizontalAlignment

        public int getHorizontalAlignment()

        Gets the horizontal alignment of the original PDF content on the result page, default is AlignmentType.Left.

        Returns:
        HorizontalAlignment element
        See Also:
        HorizontalAlignment
      • setHorizontalAlignment

        public void setHorizontalAlignment(int value)

        Sets the horizontal alignment of the original PDF content on the result page, default is AlignmentType.Left.

        Parameters:
        value - int value
        See Also:
        HorizontalAlignment
      • getVerticalAlignment

        @Deprecated
        public VerticalAlignmentType getVerticalAlignment()
        Deprecated. 

        Gets the vertical alignment of the original PDF content on the result page, default is VerticalAlignmentType.Bottom.
        Use getVerticalAlignmentType instead

        Returns:
        VerticalAlignmentType object
      • setVerticalAlignment

        @Deprecated
        public void setVerticalAlignment(VerticalAlignmentType value)
        Deprecated. 

        Sets the vertical alignment of the original PDF content on the result page, default is VerticalAlignmentType.Bottom.
        Use setVerticalAlignmentType instead

        Parameters:
        value - VerticalAlignmentType value
      • getVerticalAlignmentType

        public int getVerticalAlignmentType()

        Gets the vertical alignment of the original PDF content on the result page, default is VerticalAlignmentType.Bottom.

        Returns:
        VerticalAlignmentType element
        See Also:
        VerticalAlignmentType
      • setVerticalAlignmentType

        public void setVerticalAlignmentType(int value)

        Sets the vertical alignment of the original PDF content on the result page, default is VerticalAlignmentType.Bottom.

        Parameters:
        value - VerticalAlignment element
        See Also:
        VerticalAlignment
      • movePosition

        public void movePosition(float moveX,
                        float moveY)

        Moves the origin from (0, 0) to the point that appointted. The origin is left-bottom and the unit is point(1 inch = 72 points).


         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("input.pdf");
         editor.movePosition(-100, 60);
         editor.save("moved.pdf");
         
        Parameters:
        moveX - X-coordinate.
        moveY - Y-coordinate.
      • getPages

        public int getPages()

        Returns total number of pages.


         The following example demonstrates using of GetPages() method:
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         System.out.println("Document has: " + editor.GetPages());
         
        Returns:
        Number of pages.
      • getPageSize

        public PageSize getPageSize(int page)

        Returns the page size of the specified page.


         The following example demonstrates using of GetPageSize method:
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         PageSize size = editor.getPageSize(1);
         System.out.println("Size of 1st page : " + size.getWidth() + " x " + size.getHeight());
         
        Parameters:
        page - Page index. Document pages are numbered from 1.
        Returns:
        Result is instance of PageSize. Use Width and Height properties of the returned object to get page width and height.
      • getPageRotation

        public int getPageRotation(int page)

        Returns the rotation of specified page.


         The following example demonstrates how to get page rotation:
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         int rotation = editor.getPageSize(1);
         System.out.println("Rotation of 1st page : " + rotation + " degrees");        
         
        Parameters:
        page - Page index. Document pages are numbered from 1.
        Returns:
        Page rotation in degrees.
      • getPageBoxSize

        public Rectangle getPageBoxSize(int page,
                               String pageBoxName)

        Returns size of specified box in document.


         The following example demonstrates how to get media box of the 1st page:
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         Rectangle rect = editor.getBoxSize(1, "media");
         
        Parameters:
        page - Page index. Document pages are numbered from 1.
        pageBoxName - Box type name. Valid values are: "art", "bleed", "crop", "media", "trim".
        Returns:
        Rectangle which contains requested box.
      • save

        public void save(String outputFile)

        Saves changed document into file.


         The following sample demonstrates how to save changed PDF document
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         editor.setZoom ( 0.5f);
         editor.save("newdocument.pdf");
         
        Specified by:
        save in interface ISaveableFacade
        Overrides:
        save in class SaveableFacade
        Parameters:
        outputFile - Path to file where document will be saved.
      • save

        public void save(OutputStream outputStream)

        Saves changed document into stream.


         The following sample demonstrates how to save changed PDF document into stream.
         
         
         PdfPageEditor editor = new PdfPageEditor();
         editor.bindPdf("sample.pdf");
         editor.setZoom ( 0.5f);
         editor.save("newdocument.pdf");
         
        Specified by:
        save in interface ISaveableFacade
        Overrides:
        save in class SaveableFacade
        Parameters:
        outputStream - Stream where changed PDF document will be saved.
      • applyChanges

        public void applyChanges()

        Apply changes made to the document pages.