Class PdfFileSpecification


public class PdfFileSpecification extends PdfDictionary
Specifies a file or an URL. The file can be extern or embedded.
  • Field Details

  • Constructor Details

    • PdfFileSpecification

      public PdfFileSpecification()
      Creates a new instance of PdfFileSpecification. The static methods are preferred.
  • Method Details

    • url

      public static PdfFileSpecification url(PdfWriter writer, String url)
      Creates a file specification of type URL.
      Parameters:
      writer - the PdfWriter
      url - the URL
      Returns:
      the file specification
    • fileEmbedded

      public static PdfFileSpecification fileEmbedded(PdfWriter writer, String filePath, String fileDisplay, byte[] fileStore) throws IOException
      Creates a file specification with the file embedded. The file may come from the file system or from a byte array. The data is flate compressed.
      Parameters:
      writer - the PdfWriter
      filePath - the file path
      fileDisplay - the file information that is presented to the user
      fileStore - the byte array with the file. If it is not null it takes precedence over filePath
      Returns:
      the file specification
      Throws:
      IOException - on error
    • fileEmbedded

      public static PdfFileSpecification fileEmbedded(PdfWriter writer, String filePath, String fileDisplay, byte[] fileStore, boolean compress) throws IOException
      Creates a file specification with the file embedded. The file may come from the file system or from a byte array.
      Parameters:
      writer - the PdfWriter
      filePath - the file path
      fileDisplay - the file information that is presented to the user
      fileStore - the byte array with the file. If it is not null it takes precedence over filePath
      compress - sets the compression on the data. Multimedia content will benefit little from compression
      Returns:
      the file specification
      Throws:
      IOException - on error
    • fileExtern

      public static PdfFileSpecification fileExtern(PdfWriter writer, String filePath)
      Creates a file specification for an external file.
      Parameters:
      writer - the PdfWriter
      filePath - the file path
      Returns:
      the file specification
    • getReference

      public PdfIndirectReference getReference() throws IOException
      Gets the indirect reference to this file specification. Multiple invocations will retrieve the same value.
      Returns:
      the indirect reference
      Throws:
      IOException - on error