| Method from com.lowagie.text.pdf.PdfFileSpecification Detail: |
public void addCollectionItem(PdfCollectionItem ci) {
put(PdfName.CI, ci);
}
Adds the Collection item dictionary. |
public void addDescription(String description,
boolean unicode) {
put(PdfName.DESC, new PdfString(description, unicode ? PdfObject.TEXT_UNICODE : PdfObject.TEXT_PDFDOCENCODING));
}
Adds a description for the file that is specified here. |
public static PdfFileSpecification fileEmbedded(PdfWriter writer,
String filePath,
String fileDisplay,
byte[] fileStore) throws IOException {
return fileEmbedded(writer, filePath, fileDisplay, fileStore, PdfStream.BEST_COMPRESSION);
}
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. |
public static PdfFileSpecification fileEmbedded(PdfWriter writer,
String filePath,
String fileDisplay,
byte[] fileStore,
int compressionLevel) throws IOException {
return fileEmbedded(writer, filePath, fileDisplay, fileStore, null, null, compressionLevel);
}
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. |
public static PdfFileSpecification fileEmbedded(PdfWriter writer,
String filePath,
String fileDisplay,
byte[] fileStore,
boolean compress) throws IOException {
return fileEmbedded(writer, filePath, fileDisplay, fileStore, null, null, compress ? PdfStream.BEST_COMPRESSION : PdfStream.NO_COMPRESSION);
}
Creates a file specification with the file embedded. The file may
come from the file system or from a byte array. |
public static PdfFileSpecification fileEmbedded(PdfWriter writer,
String filePath,
String fileDisplay,
byte[] fileStore,
boolean compress,
String mimeType,
PdfDictionary fileParameter) throws IOException {
return fileEmbedded(writer, filePath, fileDisplay, fileStore, null, null, compress ? PdfStream.BEST_COMPRESSION : PdfStream.NO_COMPRESSION);
}
Creates a file specification with the file embedded. The file may
come from the file system or from a byte array. |
public static PdfFileSpecification fileEmbedded(PdfWriter writer,
String filePath,
String fileDisplay,
byte[] fileStore,
String mimeType,
PdfDictionary fileParameter,
int compressionLevel) throws IOException {
PdfFileSpecification fs = new PdfFileSpecification();
fs.writer = writer;
fs.put(PdfName.F, new PdfString(fileDisplay));
fs.setUnicodeFileName(fileDisplay, false);
PdfEFStream stream;
InputStream in = null;
PdfIndirectReference ref;
PdfIndirectReference refFileLength;
try {
refFileLength = writer.getPdfIndirectReference();
if (fileStore == null) {
File file = new File(filePath);
if (file.canRead()) {
in = new FileInputStream(filePath);
}
else {
if (filePath.startsWith("file:/") || filePath.startsWith("http://") || filePath.startsWith("https://") || filePath.startsWith("jar:")) {
in = new URL(filePath).openStream();
}
else {
in = BaseFont.getResourceStream(filePath);
if (in == null)
throw new IOException(filePath + " not found as file or resource.");
}
}
stream = new PdfEFStream(in, writer);
}
else
stream = new PdfEFStream(fileStore);
stream.put(PdfName.TYPE, PdfName.EMBEDDEDFILE);
stream.flateCompress(compressionLevel);
stream.put(PdfName.PARAMS, refFileLength);
if (mimeType != null)
stream.put(PdfName.SUBTYPE, new PdfName(mimeType));
ref = writer.addToBody(stream).getIndirectReference();
if (fileStore == null) {
stream.writeLength();
}
PdfDictionary params = new PdfDictionary();
if (fileParameter != null)
params.merge(fileParameter);
params.put(PdfName.SIZE, new PdfNumber(stream.getRawLength()));
writer.addToBody(params, refFileLength);
}
finally {
if (in != null)
try{in.close();}catch(Exception e){}
}
PdfDictionary f = new PdfDictionary();
f.put(PdfName.F, ref);
f.put(PdfName.UF, ref);
fs.put(PdfName.EF, f);
return fs;
}
Creates a file specification with the file embedded. The file may
come from the file system or from a byte array. |
public static PdfFileSpecification fileExtern(PdfWriter writer,
String filePath) {
PdfFileSpecification fs = new PdfFileSpecification();
fs.writer = writer;
fs.put(PdfName.F, new PdfString(filePath));
fs.setUnicodeFileName(filePath, false);
return fs;
}
Creates a file specification for an external file. |
public PdfIndirectReference getReference() throws IOException {
if (ref != null)
return ref;
ref = writer.addToBody(this).getIndirectReference();
return ref;
}
Gets the indirect reference to this file specification.
Multiple invocations will retrieve the same value. |
public void setMultiByteFileName(byte[] fileName) {
put(PdfName.F, new PdfString(fileName).setHexWriting(true));
}
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 |
public void setUnicodeFileName(String filename,
boolean unicode) {
put(PdfName.UF, new PdfString(filename, unicode ? PdfObject.TEXT_UNICODE : PdfObject.TEXT_PDFDOCENCODING));
}
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. |
public void setVolatile(boolean volatile_file) {
put(PdfName.V, new PdfBoolean(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. |
public static PdfFileSpecification url(PdfWriter writer,
String url) {
PdfFileSpecification fs = new PdfFileSpecification();
fs.writer = writer;
fs.put(PdfName.FS, PdfName.URL);
fs.put(PdfName.F, new PdfString(url));
return fs;
}
Creates a file specification of type URL. |