Class PdfAction


  • public class PdfAction
    extends PdfDictionary
    A PdfAction defines an action that can be triggered from a PDF file.
    See Also:
    PdfDictionary
    • Field Detail

      • FIRSTPAGE

        private static final int FIRSTPAGE
        A named action to go to the first page.
        See Also:
        Constant Field Values
      • PREVPAGE

        private static final int PREVPAGE
        A named action to go to the previous page.
        See Also:
        Constant Field Values
      • NEXTPAGE

        private static final int NEXTPAGE
        A named action to go to the next page.
        See Also:
        Constant Field Values
      • LASTPAGE

        private static final int LASTPAGE
        A named action to go to the last page.
        See Also:
        Constant Field Values
      • PRINTDIALOG

        private static final int PRINTDIALOG
        A named action to open a print dialog.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PdfAction

        public PdfAction()
        Create an empty action.
      • PdfAction

        public PdfAction​(java.net.URL url)
        Constructs a new PdfAction of Subtype URI.
        Parameters:
        url - the Url to go to
      • PdfAction

        public PdfAction​(java.lang.String url)
        Constructs a new PdfAction of Subtype URI.
        Parameters:
        url - the url to go to
      • PdfAction

        private PdfAction​(java.lang.String url,
                          boolean isMap)
        Construct a new PdfAction of Subtype URI that accepts the x and y coordinate of the position that was clicked.
        Parameters:
        url -
        isMap -
      • PdfAction

        PdfAction​(PdfIndirectReference destination)
        Constructs a new PdfAction of Subtype GoTo.
        Parameters:
        destination - the destination to go to
      • PdfAction

        public PdfAction​(java.lang.String filename,
                         java.lang.String name)
        Constructs a new PdfAction of Subtype GoToR.
        Parameters:
        filename - the file name to go to
        name - the named destination to go to
      • PdfAction

        public PdfAction​(java.lang.String filename,
                         int page)
        Constructs a new PdfAction of Subtype GoToR.
        Parameters:
        filename - the file name to go to
        page - the page destination to go to
      • PdfAction

        public PdfAction​(int named)
        Implements name actions. The action can be FIRSTPAGE, LASTPAGE, NEXTPAGE, PREVPAGE and PRINTDIALOG.
        Parameters:
        named - the named action
      • PdfAction

        public PdfAction​(java.lang.String application,
                         java.lang.String parameters,
                         java.lang.String operation,
                         java.lang.String defaultDir)
        Launches an application or a document.
        Parameters:
        application - the application to be launched or the document to be opened or printed.
        parameters - (Windows-specific) A parameter string to be passed to the application. It can be null.
        operation - (Windows-specific) the operation to perform: "open" - Open a document, "print" - Print a document. It can be null.
        defaultDir - (Windows-specific) the default directory in standard DOS syntax. It can be null.
    • Method Detail

      • rendition

        static PdfAction rendition​(java.lang.String file,
                                   PdfFileSpecification fs,
                                   java.lang.String mimeType,
                                   PdfIndirectReference ref)
                            throws java.io.IOException
        Creates a Rendition action
        Parameters:
        file -
        fs -
        mimeType -
        ref -
        Returns:
        a Media Clip action
        Throws:
        java.io.IOException
      • javaScript

        static PdfAction javaScript​(java.lang.String code,
                                    PdfWriter writer,
                                    boolean unicode)
        Creates a JavaScript action. If the JavaScript is smaller than 50 characters it will be placed as a string, otherwise it will be placed as a compressed stream.
        Parameters:
        code - the JavaScript code
        writer - the writer for this action
        unicode - select JavaScript unicode. Note that the internal Acrobat JavaScript engine does not support unicode, so this may or may not work for you
        Returns:
        the JavaScript action
      • createHide

        private static PdfAction createHide​(PdfObject obj,
                                            boolean hide)
        A Hide action hides or shows an object.
        Parameters:
        obj - object to hide or show
        hide - true is hide, false is show
        Returns:
        a Hide Action
      • buildArray

        private static PdfArray buildArray​(java.lang.Object[] names)
      • gotoEmbedded

        private static PdfAction gotoEmbedded​(java.lang.String filename,
                                              PdfTargetDictionary target,
                                              PdfObject dest,
                                              boolean newWindow)
        Creates a GoToE action to an embedded file.
        Parameters:
        filename - the root document of the target (null if the target is in the same document)
        target - a path to the target document of this action
        dest - the destination inside the target document, can be of type PdfDestination, PdfName, or PdfString
        newWindow - if true, the destination document should be opened in a new window
        Returns:
        a GoToE action