Class PdfFileSpec

java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfObject>
com.itextpdf.kernel.pdf.filespec.PdfFileSpec
Direct Known Subclasses:
PdfDictionaryFS, PdfStringFS

public class PdfFileSpec extends PdfObjectWrapper<PdfObject>
  • Constructor Details

    • PdfFileSpec

      protected PdfFileSpec (PdfObject pdfObject)
  • Method Details

    • wrapFileSpecObject

      public static PdfFileSpec wrapFileSpecObject (PdfObject fileSpecObject)
      Wrap the passed PdfObject to the specific PdfFileSpec object, according to the type of the passed pdf object.
      Parameters:
      fileSpecObject - object to wrap
      Returns:
      wrapped PdfFileSpec instance
    • createExternalFileSpec

      public static PdfFileSpec createExternalFileSpec (PdfDocument doc, String filePath, PdfName afRelationshipValue)
      Create an external file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      filePath - file specification string, describing the path to the external file
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • createExternalFileSpec

      public static PdfFileSpec createExternalFileSpec (PdfDocument doc, String filePath)
      Create an external file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      filePath - file specification string, describing the path to the external file
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, byte[] fileStore, String description, String fileDisplay, PdfName mimeType, PdfDictionary fileParameter, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      fileStore - byte[] containing the file
      description - file description
      fileDisplay - actual file name stored in the pdf
      mimeType - subtype of the embedded file. The value of this entry shall conform to the MIME media type names
      fileParameter - PdfDictionary containing fil parameters
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, byte[] fileStore, String description, String fileDisplay, PdfDictionary fileParameter, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      fileStore - byte[] containing the file
      fileDisplay - actual file name stored in the pdf
      fileParameter - PdfDictionary containing fil parameters
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      description - the file description
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, byte[] fileStore, String fileDisplay, PdfDictionary fileParameter, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      fileStore - byte[] containing the file
      fileDisplay - actual file name stored in the pdf
      fileParameter - PdfDictionary containing fil parameters
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, byte[] fileStore, String fileDisplay, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      fileStore - byte[] containing the file
      fileDisplay - actual file name stored in the pdf
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, byte[] fileStore, String description, String fileDisplay, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      fileStore - byte[] containing the file
      description - file description
      fileDisplay - actual file name stored in the pdf
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, String filePath, String description, String fileDisplay, PdfName mimeType, PdfDictionary fileParameter, PdfName afRelationshipValue) throws IOException
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      filePath - file specification string, describing the path to the file to embed
      description - file description
      fileDisplay - actual file name stored in the pdf
      mimeType - subtype of the embedded file. The value of this entry shall conform to the MIME media type names
      fileParameter - dictionary with file parameters
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
      Throws:
      IOException - if there are errors while creating an URL from the passed file path.
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, String filePath, String description, String fileDisplay, PdfName mimeType, PdfName afRelationshipValue) throws IOException
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      filePath - file specification string, describing the path to the file to embed
      description - file description
      fileDisplay - actual file name stored in the pdf
      mimeType - subtype of the embedded file. The value of this entry shall conform to the MIME media type names
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
      Throws:
      IOException - if there are errors while creating an URL from the passed file path.
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, String filePath, String description, String fileDisplay, PdfName afRelationshipValue) throws IOException
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      filePath - file specification string, describing the path to the file to embed
      description - file description
      fileDisplay - actual file name stored in the pdf
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
      Throws:
      IOException - if there are errors while creating an URL from the passed file path.
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, String filePath, String fileDisplay, PdfName afRelationshipValue) throws IOException
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      filePath - path to the file to embed
      fileDisplay - actual file name stored in the pdf
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
      Throws:
      IOException - if there are errors while creating an URL from the passed file path.
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, InputStream is, String description, String fileDisplay, PdfName mimeType, PdfDictionary fileParameter, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      is - stream containing the file to embed
      description - file description
      fileDisplay - actual file name stored in the pdf
      mimeType - subtype of the embedded file. The value of this entry shall conform to the MIME media type names
      fileParameter - dictionary with file parameters
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • createEmbeddedFileSpec

      public static PdfFileSpec createEmbeddedFileSpec (PdfDocument doc, InputStream is, String description, String fileDisplay, PdfName mimeType, PdfName afRelationshipValue)
      Create an embedded file specification.
      Parameters:
      doc - PdfDocument instance to make this file specification indirect
      is - stream containing the file to embed
      description - file description
      fileDisplay - actual file name stored in the pdf
      mimeType - subtype of the embedded file. The value of this entry shall conform to the MIME media type names
      afRelationshipValue - value that represents the relationship between the component of the passed PDF document that refers to this file specification and the associated file. If null, PdfName.Unspecified will be added.
      Returns:
      PdfFileSpec containing the file specification of the file
    • setFileIdentifier

      public PdfFileSpec setFileIdentifier (PdfArray fileIdentifier)
    • getFileIdentifier

      public PdfArray getFileIdentifier()
    • setVolatile

      public PdfFileSpec setVolatile (PdfBoolean isVolatile)
    • isVolatile

      public PdfBoolean isVolatile()
    • setCollectionItem

      public PdfFileSpec setCollectionItem (PdfCollectionItem item)
    • setThumbnailImage

      public PdfFileSpec setThumbnailImage (PdfImageXObject thumbnailImage)
      PDF 2.0. Sets a stream object defining the thumbnail image for the file specification.
      Parameters:
      thumbnailImage - image used as a thumbnail
      Returns:
      this PdfFileSpec instance
    • getThumbnailImage

      public PdfImageXObject getThumbnailImage()
      PDF 2.0. Gets a stream object defining the thumbnail image for the file specification.
      Returns:
      image used as a thumbnail, or null if it is not set
    • put

      public PdfFileSpec put (PdfName key, PdfObject value)
    • isWrappedObjectMustBeIndirect

      protected boolean isWrappedObjectMustBeIndirect()
      Description copied from class: PdfObjectWrapper
      Defines if the object behind this wrapper must be an indirect object in the resultant document.

      If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.

      Return value of this method shouldn't depend on any logic, it should return always true or false.
      Specified by:
      isWrappedObjectMustBeIndirect in class PdfObjectWrapper<PdfObject>
      Returns:
      true if in the resultant document the object behind the wrapper must be indirect, otherwise false.