Package com.aowagie.text.pdf
Class PdfFileSpecification
- java.lang.Object
-
- com.aowagie.text.pdf.PdfObject
-
- com.aowagie.text.pdf.PdfDictionary
-
- com.aowagie.text.pdf.PdfFileSpecification
-
public class PdfFileSpecification extends PdfDictionary
Specifies a file or an URL. The file can be extern or embedded.
-
-
Field Summary
Fields Modifier and Type Field Description private PdfIndirectReferencerefprivate PdfWriterwriter-
Fields inherited from class com.aowagie.text.pdf.PdfDictionary
CATALOG, hashMap, OUTLINES, PAGE
-
Fields inherited from class com.aowagie.text.pdf.PdfObject
ARRAY, BOOLEAN, bytes, DICTIONARY, INDIRECT, NAME, NOTHING, NULL, NUMBER, STREAM, STRING, TEXT_PDFDOCENCODING, TEXT_UNICODE, type
-
-
Constructor Summary
Constructors Constructor Description PdfFileSpecification()Creates a new instance of PdfFileSpecification.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidaddDescription(java.lang.String description, boolean unicode)Adds a description for the file that is specified here.static PdfFileSpecificationfileEmbedded(PdfWriter writer, java.lang.String filePath, java.lang.String fileDisplay, byte[] fileStore)Creates a file specification with the file embedded.private static PdfFileSpecificationfileEmbedded(PdfWriter writer, java.lang.String filePath, java.lang.String fileDisplay, byte[] fileStore, int compressionLevel)Creates a file specification with the file embedded.private static PdfFileSpecificationfileEmbedded(PdfWriter writer, java.lang.String filePath, java.lang.String fileDisplay, byte[] fileStore, java.lang.String mimeType, PdfDictionary fileParameter, int compressionLevel)Creates a file specification with the file embedded.static PdfFileSpecificationfileExtern(PdfWriter writer, java.lang.String filePath)Creates a file specification for an external file.PdfIndirectReferencegetReference()Gets the indirect reference to this file specification.voidsetMultiByteFileName(byte[] fileName)Sets the file name (the key /F) string as an hex representation to support multi byte file names.private voidsetUnicodeFileName(java.lang.String filename, boolean unicode)Adds the unicode file name (the key /UF).voidsetVolatile(boolean volatile_file)Sets a flag that indicates whether an external file referenced by the file specification is volatile.-
Methods inherited from class com.aowagie.text.pdf.PdfDictionary
contains, get, getAsArray, getAsBoolean, getAsDict, getAsIndirectObject, getAsName, getAsNumber, getAsString, getDirectObject, getKeys, isCatalog, isFont, isOutlineTree, isPage, isPages, merge, mergeDifferent, put, putAll, remove, size, toPdf, toString
-
Methods inherited from class com.aowagie.text.pdf.PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, setContent, setIndRef, type
-
-
-
-
Field Detail
-
writer
private PdfWriter writer
-
ref
private PdfIndirectReference ref
-
-
Method Detail
-
fileEmbedded
public static PdfFileSpecification fileEmbedded(PdfWriter writer, java.lang.String filePath, java.lang.String fileDisplay, byte[] fileStore) throws java.io.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- thePdfWriterfilePath- the file pathfileDisplay- the file information that is presented to the userfileStore- the byte array with the file. If it is notnullit takes precedence overfilePath- Returns:
- the file specification
- Throws:
java.io.IOException- on error
-
fileEmbedded
private static PdfFileSpecification fileEmbedded(PdfWriter writer, java.lang.String filePath, java.lang.String fileDisplay, byte[] fileStore, int compressionLevel) throws java.io.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- thePdfWriterfilePath- the file pathfileDisplay- the file information that is presented to the userfileStore- the byte array with the file. If it is notnullit takes precedence overfilePathcompressionLevel- the compression level to be used for compressing the file it takes precedence overfilePath- Returns:
- the file specification
- Throws:
java.io.IOException- on error- Since:
- 2.1.3
-
fileEmbedded
private static PdfFileSpecification fileEmbedded(PdfWriter writer, java.lang.String filePath, java.lang.String fileDisplay, byte[] fileStore, java.lang.String mimeType, PdfDictionary fileParameter, int compressionLevel) throws java.io.IOException
Creates a file specification with the file embedded. The file may come from the file system or from a byte array.- Parameters:
writer- thePdfWriterfilePath- the file pathfileDisplay- the file information that is presented to the userfileStore- the byte array with the file. If it is notnullit takes precedence overfilePathmimeType- the optional mimeTypefileParameter- the optional extra file parameters such as the creation or modification datecompressionLevel- the level of compression- Returns:
- the file specification
- Throws:
java.io.IOException- on error- Since:
- 2.1.3
-
fileExtern
public static PdfFileSpecification fileExtern(PdfWriter writer, java.lang.String filePath)
Creates a file specification for an external file.- Parameters:
writer- thePdfWriterfilePath- the file path- Returns:
- the file specification
-
getReference
public PdfIndirectReference getReference() throws java.io.IOException
Gets the indirect reference to this file specification. Multiple invocations will retrieve the same value.- Returns:
- the indirect reference
- Throws:
java.io.IOException- on error
-
setMultiByteFileName
public void setMultiByteFileName(byte[] fileName)
Sets the file name (the key /F) string as an hex representation to support multi byte file names. The name must have the slash and backslash escaped according to the file specification rules- Parameters:
fileName- the file name as a byte array
-
setUnicodeFileName
private void setUnicodeFileName(java.lang.String filename, boolean unicode)Adds the unicode file name (the key /UF). This entry was introduced in PDF 1.7. The filename must have the slash and backslash escaped according to the file specification rules.- Parameters:
filename- the filenameunicode- if true, the filename is UTF-16BE encoded; otherwise PDFDocEncoding is used;
-
setVolatile
public void setVolatile(boolean volatile_file)
Sets a flag that indicates whether an external file referenced by the file specification is volatile. If the value is true, applications should never cache a copy of the file.- Parameters:
volatile_file- if true, the external file should not be cached
-
addDescription
void addDescription(java.lang.String description, boolean unicode)Adds a description for the file that is specified here.- Parameters:
description- some textunicode- if true, the text is added as a unicode string
-
-