public class PdfCopyFields extends Object implements PdfViewerPreferences, PdfEncryptionSettings
Constructor and Description |
---|
PdfCopyFields(OutputStream os)
Creates a new instance.
|
PdfCopyFields(OutputStream os,
char pdfVersion)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addDocument(PdfReader reader)
Concatenates a PDF document.
|
void |
addDocument(PdfReader reader,
List pagesToKeep)
Concatenates a PDF document selecting the pages to keep.
|
void |
addDocument(PdfReader reader,
String ranges)
Concatenates a PDF document selecting the pages to keep.
|
void |
addJavaScript(String js)
Adds JavaScript to the global document
|
void |
addViewerPreference(PdfName key,
PdfObject value)
Adds a viewer preference.
|
void |
close()
Closes the output document.
|
PdfWriter |
getWriter()
Gets the underlying PdfWriter.
|
boolean |
isFullCompression()
Gets the 1.5 compression status.
|
void |
open()
Opens the document.
|
void |
setEncryption(boolean strength,
String userPassword,
String ownerPassword,
int permissions)
Sets the encryption options for this document.
|
void |
setEncryption(byte[] userPassword,
byte[] ownerPassword,
int permissions,
boolean strength128Bits)
Sets the encryption options for this document.
|
void |
setEncryption(byte[] userPassword,
byte[] ownerPassword,
int permissions,
int encryptionType)
Sets the encryption options for this document.
|
void |
setEncryption(Certificate[] certs,
int[] permissions,
int encryptionType)
Sets the certificate encryption options for this document.
|
void |
setFullCompression()
Sets the document's compression to the new 1.5 mode with object streams and xref
streams.
|
void |
setOutlines(List outlines)
Sets the bookmarks.
|
void |
setViewerPreferences(int preferences)
Sets the page layout and page mode preferences by ORing one or two of these constants.
|
public PdfCopyFields(OutputStream os) throws DocumentException
os
- the output streamDocumentException
- on errorpublic PdfCopyFields(OutputStream os, char pdfVersion) throws DocumentException
os
- the output streampdfVersion
- the pdf version the output will haveDocumentException
- on errorpublic void addDocument(PdfReader reader) throws DocumentException, IOException
reader
- the PDF documentDocumentException
- on errorIOException
public void addDocument(PdfReader reader, List pagesToKeep) throws DocumentException, IOException
List
of Integer
. The page ordering can be changed but
no page repetitions are allowed.reader
- the PDF documentpagesToKeep
- the pages to keepDocumentException
- on errorIOException
public void addDocument(PdfReader reader, String ranges) throws DocumentException, IOException
reader
- the PDF documentranges
- the comma separated ranges as described in SequenceList
DocumentException
- on errorIOException
public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, boolean strength128Bits) throws DocumentException
userPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsstrength128Bits
- true
for 128 bit key length, false
for 40 bit key lengthDocumentException
- if the document is already openpublic void setEncryption(boolean strength, String userPassword, String ownerPassword, int permissions) throws DocumentException
strength
- true for 128 bit key length. false for 40 bit key lengthuserPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsDocumentException
- if the document is already openpublic void close()
public void open()
public void addJavaScript(String js)
js
- the JavaScriptpublic void setOutlines(List outlines)
SimpleBookmark#
.outlines
- the bookmarks or null
to remove anypublic PdfWriter getWriter()
public boolean isFullCompression()
true
if the 1.5 compression is onpublic void setFullCompression()
If set before opening the document it will also set the pdf version to 1.5.
public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) throws DocumentException
PdfEncryptionSettings
setEncryption
in interface PdfEncryptionSettings
userPassword
- the user password. Can be null or emptyownerPassword
- the owner password. Can be null or emptypermissions
- the user permissionsencryptionType
- the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartextDocumentException
- if the document is already openPdfEncryptionSettings.setEncryption(byte[], byte[], int, int)
public void addViewerPreference(PdfName key, PdfObject value)
PdfViewerPreferences
addViewerPreference
in interface PdfViewerPreferences
key
- the name of the viewer preferencevalue
- the value of the viewer preferencePdfViewerPreferences.addViewerPreference(com.lowagie.text.pdf.PdfName, com.lowagie.text.pdf.PdfObject)
public void setViewerPreferences(int preferences)
PdfViewerPreferences
addViewerPreference(key, value)
if you want to change the following preferences:
setViewerPreferences
in interface PdfViewerPreferences
preferences
- the viewer preferencesPdfViewerPreferences.setViewerPreferences(int)
public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType) throws DocumentException
PdfEncryptionSettings
setEncryption
in interface PdfEncryptionSettings
certs
- the public certificates to be used for the encryptionpermissions
- the user permissions for each of the certificatesencryptionType
- the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.DocumentException
- if the document is already openPdfEncryptionSettings.setEncryption(java.security.cert.Certificate[], int[], int)
Copyright © 2018. All rights reserved.