1 47 package com.lowagie.text.pdf; 48 49 import java.io.OutputStream ; 50 import java.security.cert.Certificate ; 51 import java.util.List ; 52 53 import com.lowagie.text.DocWriter; 54 import com.lowagie.text.DocumentException; 55 import com.lowagie.text.pdf.interfaces.PdfEncryptionSettings; 56 import com.lowagie.text.pdf.interfaces.PdfViewerPreferences; 57 58 64 public class PdfCopyFields 65 implements PdfViewerPreferences, PdfEncryptionSettings { 66 67 private PdfCopyFieldsImp fc; 68 69 74 public PdfCopyFields(OutputStream os) throws DocumentException { 75 fc = new PdfCopyFieldsImp(os); 76 } 77 78 84 public PdfCopyFields(OutputStream os, char pdfVersion) throws DocumentException { 85 fc = new PdfCopyFieldsImp(os, pdfVersion); 86 } 87 88 93 public void addDocument(PdfReader reader) throws DocumentException { 94 fc.addDocument(reader); 95 } 96 97 105 public void addDocument(PdfReader reader, List pagesToKeep) throws DocumentException { 106 fc.addDocument(reader, pagesToKeep); 107 } 108 109 117 public void addDocument(PdfReader reader, String ranges) throws DocumentException { 118 fc.addDocument(reader, SequenceList.expand(ranges, reader.getNumberOfPages())); 119 } 120 121 133 public void setEncryption(byte userPassword[], byte ownerPassword[], int permissions, boolean strength128Bits) throws DocumentException { 134 fc.setEncryption(userPassword, ownerPassword, permissions, strength128Bits ? PdfWriter.STANDARD_ENCRYPTION_128 : PdfWriter.STANDARD_ENCRYPTION_40); 135 } 136 137 150 public void setEncryption(boolean strength, String userPassword, String ownerPassword, int permissions) throws DocumentException { 151 setEncryption(DocWriter.getISOBytes(userPassword), DocWriter.getISOBytes(ownerPassword), permissions, strength); 152 } 153 154 157 public void close() { 158 fc.close(); 159 } 160 161 165 public void open() { 166 fc.openDoc(); 167 } 168 169 173 public void addJavaScript(String js) { 174 fc.addJavaScript(js, !PdfEncodings.isPdfDocEncoding(js)); 175 } 176 177 182 public void setOutlines(List outlines) { 183 fc.setOutlines(outlines); 184 } 185 186 189 public PdfWriter getWriter() { 190 return fc; 191 } 192 193 197 public boolean isFullCompression() { 198 return fc.isFullCompression(); 199 } 200 201 207 public void setFullCompression() { 208 fc.setFullCompression(); 209 } 210 211 214 public void setEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) throws DocumentException { 215 fc.setEncryption(userPassword, ownerPassword, permissions, encryptionType); 216 } 217 218 221 public void addViewerPreference(PdfName key, PdfObject value) { 222 fc.addViewerPreference(key, value); 223 } 224 225 228 public void setViewerPreferences(int preferences) { 229 fc.setViewerPreferences(preferences); 230 } 231 232 235 public void setEncryption(Certificate [] certs, int[] permissions, int encryptionType) throws DocumentException { 236 fc.setEncryption(certs, permissions, encryptionType); 237 } 238 } | Popular Tags |