com.aspose.pdf.facades

Class PdfContentEditor

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


    public final class PdfContentEditor
    extends SaveableFacade

    Represents a class to edit PDF file's content.

    • Field Detail

      • DOCUMENT_WILL_SAVE

        public static final String DOCUMENT_WILL_SAVE

        A document event type. Excute a action before saving.

        See Also:
        Constant Field Values
      • DOCUMENT_SAVED

        public static final String DOCUMENT_SAVED

        A document event type. Excute a action after saving.

        See Also:
        Constant Field Values
      • DOCUMENT_WILL_PRINT

        public static final String DOCUMENT_WILL_PRINT

        A document event type. Excute a action before printing.

        See Also:
        Constant Field Values
      • DOCUMENT_PRINTED

        public static final String DOCUMENT_PRINTED

        A document event type. Excute a action after printing.

        See Also:
        Constant Field Values
    • Constructor Detail

      • PdfContentEditor

        public PdfContentEditor()

        The constructor of the PdfContentEditor object.

      • PdfContentEditor

        public PdfContentEditor(IDocument document)

        Initializes new PdfContentEditor object on base of the document.

        Parameters:
        document - Pdf document.
    • Method Detail

      • getTextSearchOptions

        public TextSearchOptions getTextSearchOptions()

        Gets text search options.

        Returns:
        TextSearchOptions element
      • setTextSearchOptions

        public void setTextSearchOptions(TextSearchOptions value)

        Sets text search options.

        Parameters:
        value - TextSearchOptions element
      • getTextEditOptions

        public TextEditOptions getTextEditOptions()

        Gets text edit options.

        Returns:
        TextEditOptions element
      • setTextEditOptions

        public void setTextEditOptions(TextEditOptions value)

        Sets text edit options.

        Parameters:
        value - setTextEditOptions element
      • getTextReplaceOptions

        public TextReplaceOptions getTextReplaceOptions()

        Gets text replace options.

        Returns:
        TextReplaceOptions element
      • setTextReplaceOptions

        public void setTextReplaceOptions(TextReplaceOptions value)

        Sets text replace options.

        Parameters:
        value - TextReplaceOptions element
      • getReplaceTextStrategy

        public ReplaceTextStrategy getReplaceTextStrategy()

        Get a set of parameters for replace text operation

        Returns:
        ReplaceTextStrategy element
      • setReplaceTextStrategy

        public void setReplaceTextStrategy(ReplaceTextStrategy value)

        Set a set of parameters for replace text operation

        Parameters:
        value - ReplaceTextStrategy element
      • bindPdf

        public void bindPdf(String inputFile)

        Binds a PDF file for editing.

        Specified by:
        bindPdf in interface IFacade
        Overrides:
        bindPdf in class Facade
        Parameters:
        inputFile - A PDF file to be edited.
      • bindPdf

        public void bindPdf(InputStream inputStream)

        Binds a PDF stream for editing.

        Specified by:
        bindPdf in interface IFacade
        Overrides:
        bindPdf in class Facade
        Parameters:
        inputStream - A PDF stream to be edited.
      • extractLink

        public List<Annotation> extractLink()

        Extracts the collection of Link instances contained in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         List links = editor.extractLink();
         for (object obj : links)
         {
             Link link = (Link)obj;
             // work with Link instance
         }
         
        Returns:
        The collection of Link objects
      • createWebLink

        public void createWebLink(Rectangle rect,
                                  String url,
                                  int originalPage,
                                  Color clr,
                                  int[] actionName)

        Creates a web link in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createWebLink(new Rectangle(0, 0, 100, 100),
             "http://www.aspose.com", 1, Color.red,
             new int[] { PredefinedAction.FirstPage, PredefinedAction.PrintDialog });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        url - The web link destination.
        originalPage - The number of original page on which rectangle bound with web link will be created.
        clr - The color of rectangle for active click.
        actionName - The array of actions (members of PredefinedAction enum) corresponding to executing menu items in Acrobat viewer.
      • createWebLink

        public void createWebLink(Rectangle rect,
                                  String url,
                                  int originalPage,
                                  Color clr)

        Creates a web link in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createWebLink(new Rectangle(0, 0, 100, 100),
             "http://www.aspose.com", 1, Color.red });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        url - The web link destination.
        originalPage - The number of original page where rectangle bound with web link will be created.
        clr - The color of rectangle for active click.
      • createWebLink

        public void createWebLink(Rectangle rect,
                                  String url,
                                  int originalPage)

        Creates a web link in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createWebLink(new Rectangle(0, 0, 100, 100), "http://www.aspose.com", 1 });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        url - The web link destination.
        originalPage - The number of original page where rectangle bound with web link will be created.
      • createLocalLink

        public void createLocalLink(Rectangle rect,
                                    int desPage,
                                    int originalPage,
                                    Color clr,
                                    int[] actionName)

        Creates a local link in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createLocalLink(new Rectangle(0, 0, 100, 100),
             2, 1, Color.red,
             new int[] { PredefinedAction.FirstPage, PredefinedAction.PrintDialog });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        desPage - The destination page.
        originalPage - The number of original page where rectangle bound with local link will be created.
        clr - The color of rectangle for active click.
        actionName - The array of actions (members of PredefinedAction enum) corresponding to executing menu items in Acrobat viewer.
        See Also:
        PredefinedAction
      • createLocalLink

        public void createLocalLink(Rectangle rect,
                                    int desPage,
                                    int originalPage,
                                    Color clr)

        Creates a local link in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createLocalLink(new Rectangle(0, 0, 100, 100),
             2, 1, Color.red });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        desPage - The destination page.
        originalPage - The number of original page where rectangle bound with local link will be created.
        clr - The color of rectangle for active click.
      • createPdfDocumentLink

        public void createPdfDocumentLink(Rectangle rect,
                                          String remotePdf,
                                          int originalPage,
                                          int destinationPage,
                                          Color clr,
                                          int[] actionName)

        Creates a link to another PDF document page.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createPdfDocumentLink(new Rectangle(0, 0, 100, 100),
             "another_example.pdf", 1, 1, Color.red,
             new int[] { PredefinedAction.FirstPage, PredefinedAction.PrintDialog });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        remotePdf - The PDF document which page will be opened.
        originalPage - The number of original page where rectangle bound with link will be created.
        destinationPage - The destination page.
        clr - The color of rectangle for active click.
        actionName - The array of actions (members of PredefinedAction enum) corresponding to executing menu items in Acrobat viewer.
      • createPdfDocumentLink

        public void createPdfDocumentLink(Rectangle rect,
                                          String remotePdf,
                                          int originalPage,
                                          int destinationPage,
                                          Color clr)

        Creates a link to another PDF document page.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createPdfDocumentLink(new Rectangle(0, 0, 100, 100),
             "another_example.pdf", 1, 1, Color.red });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        remotePdf - The PDF document which page will be opened.
        originalPage - The number of original page where rectangle bound with link will be created.
        destinationPage - The destination page.
        clr - The color of rectangle for active click.
      • createPdfDocumentLink

        public void createPdfDocumentLink(Rectangle rect,
                                          String remotePdf,
                                          int originalPage,
                                          int destinationPage)

        Creates a link to another PDF document page.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createPdfDocumentLink(new Rectangle(0, 0, 100, 100), "another_example.pdf", 1, 1 });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        remotePdf - The PDF document which page will be opened.
        originalPage - The number of original page where rectangle bound with link will be created.
        destinationPage - The destination page.
      • createCustomActionLink

        public void createCustomActionLink(Rectangle rect,
                                           int originalPage,
                                           Color color,
                                           int[] actionName)

        Creates a link to custom actions in PDF document.

        Parameters:
        rect - The rectangle for active click.
        originalPage - The number of original page where rectangle bound with link will be created.
        color - The color of rectangle for active click.
        actionName - The array of actions (members of PredefinedAction enum) corresponding to executing menu items in Acrobat viewer.
      • createApplicationLink

        public void createApplicationLink(Rectangle rect,
                                          String application,
                                          int page,
                                          Color clr,
                                          int[] actionName)

        Creates a link to launch an application in PDF document.

        Parameters:
        rect - The rectangle for active click.
        application - The path of application to be launched.
        page - The number of original page where rectangle bound with link will be created.
        clr - The color of rectangle for active click.
        actionName - The array of actions (members of PredefinedAction enum) corresponding to executing menu items in Acrobat viewer.
      • createApplicationLink

        public void createApplicationLink(Rectangle rect,
                                          String application,
                                          int page,
                                          Color clr)

        Creates a link to launch an application in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createApplicationLink(new Rectangle(0, 0, 100, 100),
             "explorer", 1, Color.red });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        application - The path of application to be launched.
        page - The number of original page where rectangle bound with link will be created.
        clr - The color of rectangle for active click.
      • createApplicationLink

        public void createApplicationLink(Rectangle rect,
                                          String application,
                                          int page)

        Creates a link to launch an application in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createApplicationLink(new Rectangle(0, 0, 100, 100), "explorer", 1 });
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle for active click.
        application - The path of application to be launched.
        page - The number of original page where rectangle bound with link will be created.
      • createJavaScriptLink

        public void createJavaScriptLink(String code,
                                         Rectangle rect,
                                         int originalPage,
                                         Color color)

        Creates a link to JavaScript in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createJavaScriptLink("app.alert('welcome to aspose!');",
             new Rectangle(0, 0, 100, 100), 1, Color.red });
         editor.save("example_out.pdf");
         
        Parameters:
        code - The JavaScript code.
        rect - The rectangle for active click.
        originalPage - The number of original page where rectangle bound with link will be created.
        color - The color of rectangle for active click.
      • createText

        public void createText(Rectangle rect,
                               String title,
                               String contents,
                               boolean open,
                               String icon,
                               int page)

        Creates text annotation in PDF document


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createText(new Rectangle(0, 0, 100, 100),
             "Welcome to Aspose", "You are welcome to Aspose!", true, "Key", 1);
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        title - The title of the annotation.
        contents - The contents of the annotation.
        open - A flag specifying whether the annotation should initially be displayed open.
        icon - The name of an icon will be used in displaying the annotation. This value can be: "Comment", "Key", "Note", "Help", "NewParagraph", "Paragraph", "Insert"
        page - The number of original page where the text annotation will be created.
      • createFreeText

        public void createFreeText(Rectangle rect,
                                   String contents,
                                   int page)

        Creates free text annotation in PDF document


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createFreeText(new Rectangle(0, 0, 100, 100), "Welcome to Aspose", 1);
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        page - The number of original page where the text annotation will be created.
      • createMarkup

        public void createMarkup(Rectangle rect,
                                 String contents,
                                 int type,
                                 int page,
                                 Color clr)

        Creates markup annotation it PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createMarkup(new Rectangle(0, 0, 100, 100),
             "Welcome to Aspose", 0, 1, Color.red);
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        type - The type of markup annotation. Can be 0 (Highlight), 1 (Underline), 2 (StrikeOut), 3 (Squiggly).
        page - The number of original page where the annotation will be created.
        clr - The color of markup.
      • createPopup

        public void createPopup(Rectangle rect,
                                String contents,
                                boolean open,
                                int page)

        Creates popup annotation in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createPopup(new Rectangle(0, 0, 100, 100), "Welcome to Aspose", true, 1);
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        open - A flag specifying whether the pop-up annotation should initially be displayed open.
        page - The number of original page where the annotation will be created.
      • createFileAttachment

        public void createFileAttachment(Rectangle rect,
                                         String contents,
                                         String filePath,
                                         int page,
                                         String name)

        Creates file attachment annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createFileAttachment(new Rectangle(0, 0, 100, 100),
             "Welcome to Aspose", "attachment_file.pdf", 1, "Graph");
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        filePath - The path of the file will be attached.
        page - The number of original page where the annotation will be created.
        name - The name of an icon will be used in displaying the annotation. This value can be: "Graph", "PushPin", "Paperclip", "Tag".
      • createFileAttachment

        public void createFileAttachment(Rectangle rect,
                                         String contents,
                                         InputStream attachmentStream,
                                         String attachmentName,
                                         int page,
                                         String name)

        Creates file attachment annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         java.io.InputStream attStream = new java.io.FileInputStream("attachment_file.pdf");
        
             editor.createFileAttachment(new Rectangle(0, 0, 100, 100),
                 "Welcome to Aspose", attStream, "attachment_file.pdf", 1, "Graph");
             editor.save("example_out.pdf");
        
         
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        attachmentStream - The attachment file stream.
        attachmentName - The attachment name.
        page - The number of original page where the annotation will be created.
        name - The name of an icon will be used in displaying the annotation. This value can be: "Graph", "PushPin", "Paperclip", "Tag".
      • addDocumentAttachment

        public void addDocumentAttachment(String fileAttachmentPath,
                                          String description)

        Adds document attachment with no annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.addDocumentAttachment("attachment_file.pdf", "description of attachment_file");
         editor.save("example_out.pdf");
         
        Parameters:
        fileAttachmentPath - The path of the file will be attached.
        description - The description information.
      • addDocumentAttachment

        public void addDocumentAttachment(InputStream fileAttachmentStream,
                                          String fileAttachmentName,
                                          String description)

        Adds document attachment with no annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         InputStream attStream = new FileInputStream("attachment_file.pdf")
             editor.addDocumentAttachment(attStream, "attachment_file.pdf", "description of attachment_file");
             editor.save("example_out.pdf");
         
        Parameters:
        fileAttachmentStream - The stream of the file will be attached.
        fileAttachmentName - The attachment name.
        description - The description information.
      • deleteAttachments

        public void deleteAttachments()

        Deletes all attachments in PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.deleteAttachments();
         editor.save("example_out.pdf");
         
      • createLine

        public void createLine(Rectangle rect,
                               String contents,
                               float x1,
                               float y1,
                               float x2,
                               float y2,
                               int page,
                               int border,
                               Color clr,
                               String borderStyle,
                               int[] dashArray,
                               String[] LEArray)

        Creates line annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createLine(new Rectangle(0, 0, 100, 100), "Welcome to Aspose", 0, 0, 100, 100,
             1, 1, Color.red, "D", new int[] {2, 3}, new string[] {"OpenArrow", "ClosedArrow"});
         editor.save("example_out.pdf");
         
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        x1 - The starting horizontal coordinate of the line.
        y1 - The starting vertical coordinate of the line.
        x2 - The ending horizontal coordinate of the line.
        y2 - The ending vertical coordinate of the line.
        page - The number of original page where the annotation will be created.
        border - The border width in points. If this value is 0 no border is drawn. Default value is 1.
        clr - The color of line.
        borderStyle - The border style specifying the width and dash pattern to be used in drawing the line. This value can be: "S" (Solid), "D" (Dashed), "B" (Beveled), "I" (Inset), "U" (Underline).
        dashArray - A dash array defining a pattern of dashes and gaps to be used in drawing a dashed border. If it is used, borderSyle must be accordingly set to "D".
        LEArray - An array of two values respectively specifying the beginning and ending style of the drawing line. The values can be: "Square", "Circle", "Diamond", "OpenArrow", "ClosedArrow", "None", "Butt", "ROpenArrow", "RClosedArrow", "Slash".
      • createSquareCircle

        public void createSquareCircle(Rectangle rect,
                                       String contents,
                                       Color clr,
                                       boolean square,
                                       int page,
                                       int borderWidth)

        Creates square-circle annotation.


        
        
          PdfContentEditor editor = new PdfContentEditor();
          editor.bindPdf("example.pdf");
                editor.createSquareCircle(new Rectangle(0, 0, 100, 100),
                    "Welcome to Aspose", Color.red, false, 1, 5);
          editor.save("example_out.pdf");
          
        Parameters:
        rect - The annotation rectangle defining the location of the annotation on the page.
        contents - The contents of the annotation.
        clr - The color of square or circle.
        square - True (square), false (sircle).
        page - The number of original page where the annotation will be created.
        borderWidth - The border width of square or circle.
      • drawCurve

        public void drawCurve(LineInfo lineInfo,
                              int page,
                              Rectangle annotRect,
                              String annotContents)

        Creates curve annotation.

        
        
         PdfContentEditor editor = new PdfContentEditor();
         newApiEditor.bindPdf("example.pdf");
         LineInfo lineInfo = new LineInfo();
         lineInfo.setVerticeCoordinate ( new float[] { 0, 0, 100, 100 });  //x1, y1, x2, y2, .. xn, yn
         lineInfo.setVisibility ( true);
         editor.drawCurve(lineInfo, 1, new Rectangle(0, 0, 0, 0), "Welcome to Aspose");
         editor.save("example_out.pdf");
         
        Parameters:
        lineInfo - The instance of LineInfo class.
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        annotContents - The contents of the annotation.
      • createPolygon

        public void createPolygon(LineInfo lineInfo,
                                  int page,
                                  Rectangle annotRect,
                                  String annotContents)

        Creates polygon annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         LineInfo lineInfo = new LineInfo();
         lineInfo.setVerticeCoordinate ( new float[] { 0, 0, 100, 100, 100, 50 });
         lineInfo.setVisibility ( true);
         editor.createPolygon(lineInfo, 1 , new Rectangle(0, 0, 0, 0), "Welcome to Aspose");
         editor.save("example_out.pdf");
         
        Parameters:
        lineInfo - The instance of LineInfo class.
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        annotContents - The contents of the annotation.
      • createPolyLine

        public void createPolyLine(LineInfo lineInfo,
                                   int page,
                                   Rectangle annotRect,
                                   String annotContents)

        Creates polyline annotation.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         LineInfo lineInfo = new LineInfo();
         lineInfo.setVerticeCoordinate ( new float[] { 0, 0, 100, 100, 100, 50 });
         lineInfo.setVisibility ( true);
         editor.createPolyLine(lineInfo, 1 , new Rectangle(0, 0, 0, 0), "Welcome to Aspose");
         editor.save("example_out.pdf");
         
        Parameters:
        lineInfo - The instance of LineInfo class.
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        annotContents - The contents of the annotation.
      • createCaret

        public void createCaret(int page,
                                Rectangle annotRect,
                                Rectangle caretRect,
                                String symbol,
                                String annotContents,
                                Color color)

        Creates caret annotation.


        
        
          PdfContentEditor editor = new PdfContentEditor();
          editor.bindPdf("example.pdf");
                editor.createCaret(1,
                    new Rectangle(50, 50, 100, 100),
                    new Rectangle(60, 60, 70, 70),
                    "None", "Welcome to Aspose", Color.red);
          editor.save("example_out.pdf");
          
        Parameters:
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        caretRect - The actual boundaries of the underlying caret.
        symbol - A symbol will be associated with the caret. Value can be: "P" (Paragraph), "None".
        annotContents - The contents of the annotation.
        color - The color of the annotation.
      • createRubberStamp

        public void createRubberStamp(int page,
                                      Rectangle annotRect,
                                      String icon,
                                      String annotContents,
                                      Color color)

        Creates a rubber stamp annotation.


        
        
          PdfContentEditor editor = new PdfContentEditor();
          editor.bindPdf("example.pdf");
                editor.createRubberStamp(1, Rectangle(0, 0, 100, 100),
                    "Welcome to Aspose", Color.red);
          editor.save("example_out.pdf");
          
        Parameters:
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        icon - String value
        annotContents - The contents of the annotation.
        color - The color of the annotation.
      • createRubberStamp

        public void createRubberStamp(int page,
                                      Rectangle annotRect,
                                      String annotContents,
                                      Color color,
                                      String appearanceFile)

        Creates a rubber stamp annotation.


        
        
          PdfContentEditor editor = new PdfContentEditor();
          editor.bindPdf("example.pdf");
                editor.createRubberStamp(1, Rectangle(0, 0, 100, 100),
                    "Welcome to Aspose", Color.red, "appearance_file.pdf");
          editor.save("example_out.pdf");
          
        Parameters:
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        annotContents - The contents of the annotation.
        color - The color of the annotation.
        appearanceFile - The path of appearance file.
      • createRubberStamp

        public void createRubberStamp(int page,
                                      Rectangle annotRect,
                                      String annotContents,
                                      Color color,
                                      InputStream appearanceStream)

        Creates a rubber stamp annotation.


        
        
          PdfContentEditor editor = new PdfContentEditor();
          editor.bindPdf("example.pdf");
          InputStream appStream = new FileInputStream("appearance_file.pdf");
                    editor.createRubberStamp(1, Rectangle(0, 0, 100, 100),
                        "Welcome to Aspose", Color.red, appStream);
              editor.save("example_out.pdf");
        
          
        Parameters:
        page - The number of original page where the annotation will be created.
        annotRect - The annotation rectangle defining the location of the annotation on the page.
        annotContents - The contents of the annotation.
        color - The color of the annotation.
        appearanceStream - The stream of appearance file.
      • createBookmarksAction

        public void createBookmarksAction(String title,
                                          Color color,
                                          boolean boldFlag,
                                          boolean italicFlag,
                                          String file,
                                          String actionType,
                                          String destination)

        Creates a bookmark with the specified action.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.createBookmarksAction("bookmark title",
             Color.red, true, true, null, "GoTo", 1(page number));
         editor.save("example_out.pdf");
         
        Parameters:
        title - The title of the bookmark.
        color - The color of the bookmark's title.
        boldFlag - The flag of bold attribution.
        italicFlag - The flag of italic attribution.
        file - Another file or application required when the action type is "GoToR" or "Launch".
        actionType - The action type. The value can be: "GoToR", "Launch", "GoTo", "URI".
        destination - The local destination or remote destination or URL.
      • addDocumentAdditionalAction

        public void addDocumentAdditionalAction(String eventType,
                                                String code)

        Adds additional action for document event.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.addDocumentAdditionalAction(PdfContentEditor.DocumentClose, "app.alert('Good-bye!');");
         editor.save("example_out.pdf");
         
        Parameters:
        eventType - The document event types.
        code - The code of JavaScript.
      • removeDocumentOpenAction

        public void removeDocumentOpenAction()

        Removes open action from the document. This operation is useful when concatenating multiple documents that use explicit 'GoTo' action on startup.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.removeDocumentOpenAction();
         editor.save("example_out.pdf");
         
      • changeViewerPreference

        public void changeViewerPreference(int viewerAttribution)

        Changes the view preference.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.changeViewerPreference(ViewerPreference.HideMenubar);
         editor.changeViewerPreference(ViewerPreference.PageModeUseNone);
         editor.save("example_out.pdf");
         
        Parameters:
        viewerAttribution - The view attribution defined in the ViewerPreference class.
      • getViewerPreference

        public int getViewerPreference()

        Returns the view preference.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         int prefValue = editor.GetViewerPreference();
         if ((prefValue & ViewerPreference.PageModeUseOutline) != 0)
         { // ... }
         
        Returns:
        Returns set of ViewerPrefernece flags
      • replaceImage

        public void replaceImage(int pageNumber,
                                 int index,
                                 String imageFile)

        Replaces the specified image on the specified page of PDF document with another image.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.replaceImage(1, 1, "image.jpg");
         editor.save("example_out.pdf");
         
        Parameters:
        pageNumber - The number of page on which the image is replaced.
        index - The index of the image object must be replaced.
        imageFile - The image file will be used for replacing.
      • deleteImage

        public void deleteImage(int pageNumber,
                                int[] index)

        Deletes the specified images on the specified page.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.deleteImage(1, new int[] {1, 2});
         editor.save("example_out.pdf");
         
        Parameters:
        pageNumber - The number of page on which images must be deleted.
        index - An array repsents images' indexes.
      • deleteImage

        public void deleteImage()

        Deletes all images from PDF document.


        
        
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf("example.pdf");
         editor.deleteImage();
         editor.save("example_out.pdf");
         
      • replaceText

        public boolean replaceText(String srcString,
                                   int thePage,
                                   String destString,
                                   TextState textState)

        Replaces text in the PDF file on the specified page. TextState object (font family, color) can be specified to replaced text.


         The example demonstrates how to replace text on the first page of the PDF document and set  TextState
         text properties for the new text.
        
        
         // open document
         Document doc = new Document(inFile);
         com.aspose.pdf.Font font = com.aspose.pdf.FontRepository.findFont("Courier New");
         font.isEmbedded ( true);
         // create PdfContentEditor object to edit text
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf(doc);
         // create textState object
         com.aspose.pdf.TextState textState = new com.aspose.pdf.TextState();
         textState.setFont ( font);
         textState.setFontSize ( 17);
         textState.setFontStyle ( com.aspose.pdf.FontStyles.Bold | com.aspose.pdf.FontStyles.Italic);
         textState.setForegroundColor ( com.aspose.pdf.Color.getRed());
         // change text with specified font
         editor.replaceText("hello world", 1, "hi world", textState);
         // save document
         doc.save(outFile);
         
        Parameters:
        srcString - The string to be replaced.
        thePage - Page number (0 means "all pages").
        destString - The replaced string.
        textState - Text state (Text Color, Font etc).
        Returns:
        Returns true if replacement was made.
      • replaceText

        public boolean replaceText(String srcString,
                                   String destString)

        Replaces text in the PDF file.


         The example demonstrates how to replace text in PDF document.
        
        
         // open document
         Document doc = new Document(inFile);
         // create PdfContentEditor object to edit text
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf(doc);
         // change text
         editor.replaceText("hello world", "hi world");
         // save document
         doc.save(outFile);
         
        Parameters:
        srcString - The string to be replaced.
        destString - Replacing string.
        Returns:
        Returns true if replacement was made.
      • replaceText

        public boolean replaceText(String srcString,
                                   int thePage,
                                   String destString)

        Replaces text in the PDF file on the specified page.


         The example demonstrates how to replace text in PDF document on the specified page.
        
        
         // open document
         Document doc = new Document(inFile);
         // create PdfContentEditor object to edit text
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf(doc);
         // change text
         editor.replaceText("hello world", 1, "hi world");
         // save document
         doc.save(outFile);
         
        Parameters:
        srcString - The sting to be replaced.
        thePage - Page number (0 for all pages)
        destString - Replacing string.
        Returns:
        Returns true if replacement was made.
      • replaceText

        public boolean replaceText(String srcString,
                                   String destString,
                                   TextState textState)

        Replaces text in the PDF file using specified TextState object.


         The example demonstrates how to replace text and set  TextState text properties for the new text.
        
        
         Document doc = new Document(inFile);
         // Create font and mark it to be embedded
         com.aspose.pdf.Font font = com.aspose.pdf.FontRepository.findFont("Courier New");
         font.isEmbedded ( true);
         // create PdfContentEditor object to edit text
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf(doc);
         // create textState object
         com.aspose.pdf.TextState textState = new com.aspose.pdf.TextState();
         textState.setFont ( font);
         textState.setFontStyle ( com.aspose.pdf.FontStyles.Bold | com.aspose.pdf.FontStyles.Italic);
         // change text with specified font
         editor.replaceText("hello world", "hi world", textState);
         // save document
         doc.save(outFile);
         
        Parameters:
        srcString - String to be replaced
        destString - Replacing string
        textState - Text state (Text Color, Font etc)
        Returns:
        Returns true if replacement was made.
      • createMovie

        public void createMovie(Rectangle rect,
                                String filePath,
                                int page)
      • deleteStamp

        public void deleteStamp(int pageNumber,
                                int[] index)

        Deletes multiple stamps on the specified page by stamp indexes.


        
        
         PdfContentEditor contentEditor = new PdfContentEditor();
         contentEditor.bindPdf("file.pdf");
         contentEditor.deleteStamp(1, new int[] { 2, 3, 5} );
         contentEditor.save("outfile.pdf");
         
        Parameters:
        pageNumber - Page number where stamp will be deleted.
        index - Stamp indexes.
      • deleteStampByIds

        public void deleteStampByIds(int[] stampIds)

        Deletes stamps with specified IDs from all pages of the document.


        
        
         PdfContentEditor contentEditor = new PdfContentEditor();
         contentEditor.bindPdf("file.pdf");
         contentEditor.deleteStampByIds(new int[] { 102, 103 } );
         contentEditor.save("outfile.pdf");
         
        Parameters:
        stampIds - Array of stamp IDs.
      • deleteStampByIds

        public void deleteStampByIds(int pageNumber,
                                     int[] stampIds)

        Deletes stamps on the specified page by multiple stamp IDs.


        
        
         PdfContentEditor contentEditor = new PdfContentEditor();
         contentEditor.bindPdf("file.pdf");
         contentEditor.deleteStampByIds(1, new int[] { 100, 101 } );
         contentEditor.save("outfile.pdf");
         
        Parameters:
        pageNumber - Page number where stamps will be deleted.
        stampIds - Array of stamp IDs.
      • deleteStampById

        public void deleteStampById(int pageNumber,
                                    int stampId)

        Deletes stamp on the specified page by stamp ID.


        
        
         PdfContentEditor contentEditor = new PdfContentEditor();
         contentEditor.bindPdf("file.pdf");
         contentEditor.deleteStampById(1, 100);
         contentEditor.save("outfile.pdf");
         
        Parameters:
        pageNumber - Page number where stamp will be deleted.
        stampId - Identifier of stamp which should be deleted.
      • hideStampById

        public void hideStampById(int pageNumber,
                                  int stampId)

        Hides the stamp. After hiding, stamp visibility may be restored with ShowStampById method.

        Parameters:
        pageNumber - Number of the page.
        stampId - Identifier of stamp which should be hidden.
      • showStampById

        public void showStampById(int pageNumber,
                                  int stampId)

        Shows stamp which was hidden by HiddenStampById.

        Parameters:
        pageNumber - Number of the page.
        stampId - Identifier of stamp which should be shown.
      • moveStampById

        public void moveStampById(int pageNumber,
                                  int stampId,
                                  double x,
                                  double y)

        Changes position of the stamp on page.

        Parameters:
        pageNumber - Numer of page.
        stampId - Identifier of stamp which should be moved.
        x - New stamp horizontal pozition on the page.
        y - New stamp vertical position on the page.
      • moveStamp

        public void moveStamp(int pageNumber,
                              int stampIndex,
                              double x,
                              double y)

        Changes position of the stamp on page.

        Parameters:
        pageNumber - Number of page.
        stampIndex - Index of stamp on the page.
        x - New stamp horizontal position.
        y - New stamp vertical position.
      • deleteStampById

        public void deleteStampById(int stampId)

        Delete stamp by ID from all pages of the document.


        
        
         PdfContentEditor contentEditor = new PdfContentEditor();
         contentEditor.bindPdf("file.pdf");
         contentEditor.deleteStampById(100);
         contentEditor.save("outfile.pdf");
         
        Parameters:
        stampId - Identifier of stamp which should be deleted.
      • createLocalLink

        public void createLocalLink(Rectangle rect,
                                    int desPage,
                                    int originalPage)

        Creates a local link in PDF document.

        Parameters:
        rect - The rectangle for active click.
        desPage - The destination page.
        originalPage - The number of original page where rectangle bound with local link will be created.
      • replaceText

        public boolean replaceText(String srcString,
                                   String destString,
                                   int fontSize)

        Replaces text in the PDF file and sets font size.


         The example demonstrates how to replace text and set font size for the new text.
        
        
         // open document
         Document doc = new Document(inFile);
         // Create font and mark it to be embedded
         com.aspose.pdf.Font font = FontRepository.FindFont("Courier New");
         font.isEmbedded ( true);
         // create PdfContentEditor object to edit text
         PdfContentEditor editor = new PdfContentEditor();
         editor.bindPdf(doc);
         // change text with specified font
         editor.replaceText("hello world", "hi world", 14);
         // save document
         doc.save(outFile);
         
        Parameters:
        srcString - String to be replaced.
        destString - Replacing string.
        fontSize - Font size.
        Returns:
        Returns true if replacement was made.
      • getStamps

        public StampInfo[] getStamps(int pageNumber)

        Returns array of stamps on the page.

        Parameters:
        pageNumber - Page number where stamps will be searched.
        Returns:
        Array of stamps.
      • close

        public void close()

        Closes opened document.

        Specified by:
        close in interface IFacade
        Overrides:
        close in class Facade