Class FdfWriter


  • public class FdfWriter
    extends java.lang.Object
    Writes an FDF form.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  FdfWriter.Wrt  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Counter COUNTER  
      (package private) java.util.HashMap<java.lang.String,​java.lang.Object> fields  
      private java.lang.String file
      The PDF file associated with the FDF.
      private static byte[] HEADER_FDF  
      private java.lang.String statusMessage  
      (package private) FdfWriter.Wrt wrt  
    • Constructor Summary

      Constructors 
      Constructor Description
      FdfWriter()
      Creates a new FdfWriter.
      FdfWriter​(java.io.OutputStream os)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      PdfTemplate createTemplate​(float width, float height)  
      protected Counter getCounter()  
      java.lang.String getField​(java.lang.String field)
      Gets the field value.
      java.util.HashMap<java.lang.String,​java.lang.Object> getFields()
      Gets all the fields.
      java.lang.String getFile()
      Gets the PDF file name associated with the FDF.
      PdfImportedPage getImportedPage​(PdfReader reader, int pageNumber)  
      java.lang.String getStatusMessage()  
      (package private) void iterateFields​(java.util.HashMap<java.lang.String,​java.lang.Object> values, java.util.HashMap<java.lang.String,​java.lang.Object> map, java.lang.String name)  
      boolean removeField​(java.lang.String field)
      Removes the field value.
      (package private) boolean setField​(java.lang.String field, PdfObject value)  
      boolean setFieldAsAction​(java.lang.String field, PdfAction action)
      Sets the field value as a PDFAction.
      boolean setFieldAsImage​(java.lang.String field, Image image)  
      boolean setFieldAsJavascript​(java.lang.String field, PdfName jsTrigName, java.lang.String js)  
      boolean setFieldAsName​(java.lang.String field, java.lang.String value)
      Sets the field value as a name.
      boolean setFieldAsString​(java.lang.String field, java.lang.String value)
      Sets the field value as a string.
      boolean setFieldAsTemplate​(java.lang.String field, PdfTemplate template)  
      void setFields​(AcroFields af)
      Sets all the fields from this AcroFields
      void setFields​(FdfReader fdf)
      Sets all the fields from this FdfReader
      void setFields​(PdfReader pdf)
      Sets all the fields from this PdfReader
      void setFile​(java.lang.String file)
      Sets the PDF file name associated with the FDF.
      void setStatusMessage​(java.lang.String statusMessage)  
      void write()  
      void writeTo​(java.io.OutputStream os)
      Writes the content to a stream.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • HEADER_FDF

        private static final byte[] HEADER_FDF
      • fields

        java.util.HashMap<java.lang.String,​java.lang.Object> fields
      • file

        private java.lang.String file
        The PDF file associated with the FDF.
      • statusMessage

        private java.lang.String statusMessage
      • COUNTER

        protected Counter COUNTER
    • Constructor Detail

      • FdfWriter

        public FdfWriter()
        Creates a new FdfWriter.
      • FdfWriter

        public FdfWriter​(java.io.OutputStream os)
                  throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • writeTo

        public void writeTo​(java.io.OutputStream os)
                     throws java.io.IOException
        Writes the content to a stream.
        Parameters:
        os - the stream
        Throws:
        java.io.IOException - on error
      • write

        public void write()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • getStatusMessage

        public java.lang.String getStatusMessage()
      • setStatusMessage

        public void setStatusMessage​(java.lang.String statusMessage)
      • setField

        boolean setField​(java.lang.String field,
                         PdfObject value)
      • iterateFields

        void iterateFields​(java.util.HashMap<java.lang.String,​java.lang.Object> values,
                           java.util.HashMap<java.lang.String,​java.lang.Object> map,
                           java.lang.String name)
      • removeField

        public boolean removeField​(java.lang.String field)
        Removes the field value.
        Parameters:
        field - the field name
        Returns:
        true if the field was found and removed, false otherwise
      • getFields

        public java.util.HashMap<java.lang.String,​java.lang.Object> getFields()
        Gets all the fields. The map is keyed by the fully qualified field name and the values are PdfObject.
        Returns:
        a map with all the fields
      • getField

        public java.lang.String getField​(java.lang.String field)
        Gets the field value.
        Parameters:
        field - the field name
        Returns:
        the field value or null if not found
      • setFieldAsName

        public boolean setFieldAsName​(java.lang.String field,
                                      java.lang.String value)
        Sets the field value as a name.
        Parameters:
        field - the fully qualified field name
        value - the value
        Returns:
        true if the value was inserted, false if the name is incompatible with an existing field
      • setFieldAsString

        public boolean setFieldAsString​(java.lang.String field,
                                        java.lang.String value)
        Sets the field value as a string.
        Parameters:
        field - the fully qualified field name
        value - the value
        Returns:
        true if the value was inserted, false if the name is incompatible with an existing field
      • setFieldAsAction

        public boolean setFieldAsAction​(java.lang.String field,
                                        PdfAction action)
        Sets the field value as a PDFAction. For example, this method allows setting a form submit button action using PdfAction.createSubmitForm(String, Object[], int). This method creates an A entry for the specified field in the underlying FDF file. Method contributed by Philippe Laflamme (plaflamme)
        Parameters:
        field - the fully qualified field name
        action - the field's action
        Returns:
        true if the value was inserted, false if the name is incompatible with an existing field
        Since:
        2.1.5
      • setFieldAsTemplate

        public boolean setFieldAsTemplate​(java.lang.String field,
                                          PdfTemplate template)
      • setFieldAsImage

        public boolean setFieldAsImage​(java.lang.String field,
                                       Image image)
      • setFieldAsJavascript

        public boolean setFieldAsJavascript​(java.lang.String field,
                                            PdfName jsTrigName,
                                            java.lang.String js)
      • createTemplate

        public PdfTemplate createTemplate​(float width,
                                          float height)
      • setFields

        public void setFields​(FdfReader fdf)
        Sets all the fields from this FdfReader
        Parameters:
        fdf - the FdfReader
      • setFields

        public void setFields​(PdfReader pdf)
        Sets all the fields from this PdfReader
        Parameters:
        pdf - the PdfReader
      • setFields

        public void setFields​(AcroFields af)
        Sets all the fields from this AcroFields
        Parameters:
        af - the AcroFields
      • getFile

        public java.lang.String getFile()
        Gets the PDF file name associated with the FDF.
        Returns:
        the PDF file name associated with the FDF
      • setFile

        public void setFile​(java.lang.String file)
        Sets the PDF file name associated with the FDF.
        Parameters:
        file - the PDF file name associated with the FDF
      • getCounter

        protected Counter getCounter()