Beispiel #1
0
 public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType)
     throws DocumentException {
   if (stamper.isAppend())
     throw new DocumentException("Append mode does not support changing the encryption status.");
   if (stamper.isContentWritten())
     throw new DocumentException("Content was already written to the output.");
   stamper.setEncryption(certs, permissions, encryptionType);
 }
Beispiel #2
0
 public void setEncryption(
     byte userPassword[], byte ownerPassword[], int permissions, int encryptionType)
     throws DocumentException {
   if (stamper.isAppend())
     throw new DocumentException("Append mode does not support changing the encryption status.");
   if (stamper.isContentWritten())
     throw new DocumentException("Content was already written to the output.");
   stamper.setEncryption(userPassword, ownerPassword, permissions, encryptionType);
 }
Beispiel #3
0
 public void setEncryption(
     byte userPassword[], byte ownerPassword[], int permissions, boolean strength128Bits)
     throws DocumentException {
   if (stamper.isAppend())
     throw new DocumentException("Append mode does not support changing the encryption status.");
   if (stamper.isContentWritten())
     throw new DocumentException("Content was already written to the output.");
   stamper.setEncryption(
       userPassword,
       ownerPassword,
       permissions,
       strength128Bits ? PdfWriter.STANDARD_ENCRYPTION_128 : PdfWriter.STANDARD_ENCRYPTION_40);
 }
Beispiel #4
0
 public void close() throws DocumentException, IOException {
   if (!hasSignature) {
     stamper.close(moreInfo);
     return;
   }
   sigApp.preClose();
   PdfSigGenericPKCS sig = sigApp.getSigStandard();
   PdfLiteral lit = (PdfLiteral) sig.get(PdfName.CONTENTS);
   int totalBuf = (lit.getPosLength() - 2) / 2;
   byte buf[] = new byte[8192];
   int n;
   InputStream inp = sigApp.getRangeStream();
   try {
     while ((n = inp.read(buf)) > 0) {
       sig.getSigner().update(buf, 0, n);
     }
   } catch (SignatureException se) {
     throw new ExceptionConverter(se);
   }
   buf = new byte[totalBuf];
   byte[] bsig = sig.getSignerContents();
   System.arraycopy(bsig, 0, buf, 0, bsig.length);
   PdfString str = new PdfString(buf);
   str.setHexWriting(true);
   PdfDictionary dic = new PdfDictionary();
   dic.put(PdfName.CONTENTS, str);
   sigApp.close(dic);
   stamper.reader.close();
 }
Beispiel #5
0
 public PdfFormField addSignature(
     String name, int page, float llx, float lly, float urx, float ury) {
   PdfAcroForm acroForm = stamper.getAcroForm();
   PdfFormField signature = PdfFormField.createSignature(stamper);
   acroForm.setSignatureParams(signature, name, llx, lly, urx, ury);
   acroForm.drawSignatureAppearences(signature, llx, lly, urx, ury);
   addAnnotation(signature, page);
   return signature;
 }
 static void mergeResources(PdfDictionary result, PdfDictionary source, PdfStamperImp writer) {
   PdfDictionary dic = null;
   PdfDictionary res = null;
   PdfName target = null;
   for (int k = 0; k < mergeTarget.length; ++k) {
     target = mergeTarget[k];
     PdfDictionary pdfDict = source.getAsDict(target);
     if ((dic = pdfDict) != null) {
       if ((res = (PdfDictionary) PdfReader.getPdfObject(result.get(target), result)) == null) {
         res = new PdfDictionary();
       }
       res.mergeDifferent(dic);
       result.put(target, res);
       if (writer != null) writer.markUsed(res);
     }
   }
 }
Beispiel #7
0
 public void setTransition(PdfTransition transition, int page) {
   stamper.setTransition(transition, page);
 }
Beispiel #8
0
 public void setPageAction(PdfName actionType, PdfAction action, int page) throws PdfException {
   stamper.setPageAction(actionType, action, page);
 }
Beispiel #9
0
 public void setDuration(int seconds, int page) {
   stamper.setDuration(seconds, page);
 }
Beispiel #10
0
 void addAnnotation(PdfAnnotation annot) {
   ((PdfStamperImp) writer).addAnnotation(annot, ps.pageN);
 }
Beispiel #11
0
 public void setOutlines(List outlines) {
   stamper.setOutlines(outlines);
 }
Beispiel #12
0
 public void insertPage(int pageNumber, Rectangle mediabox) {
   stamper.insertPage(pageNumber, mediabox);
 }
Beispiel #13
0
 public PdfContentByte getOverContent(int pageNum) {
   return stamper.getOverContent(pageNum);
 }
Beispiel #14
0
 public void makePackage(PdfCollection collection) {
   stamper.makePackage(collection);
 }
Beispiel #15
0
 public void setViewerPreferences(int preferences) {
   stamper.setViewerPreferences(preferences);
 }
Beispiel #16
0
 public void addFileAttachment(String description, PdfFileSpecification fs) throws IOException {
   stamper.addFileAttachment(description, fs);
 }
Beispiel #17
0
 public void makePackage(PdfName initialView) {
   PdfCollection collection = new PdfCollection(0);
   collection.put(PdfName.VIEW, initialView);
   stamper.makePackage(collection);
 }
Beispiel #18
0
 public void addJavaScript(String js) {
   stamper.addJavaScript(js, !PdfEncodings.isPdfDocEncoding(js));
 }
Beispiel #19
0
 public boolean partialFormFlattening(String name) {
   return stamper.partialFormFlattening(name);
 }
Beispiel #20
0
 public void setThumbnail(Image image, int page) throws PdfException, DocumentException {
   stamper.setThumbnail(image, page);
 }
Beispiel #21
0
 public Map getPdfLayers() {
   return stamper.getPdfLayers();
 }
Beispiel #22
0
 public void addAnnotation(PdfAnnotation annot, int page) {
   stamper.addAnnotation(annot, page);
 }
Beispiel #23
0
 public void replacePage(PdfReader r, int pageImported, int pageReplaced) {
   stamper.replacePage(r, pageImported, pageReplaced);
 }
Beispiel #24
0
 public void setXmpMetadata(byte[] xmp) {
   stamper.setXmpMetadata(xmp);
 }
Beispiel #25
0
 public void setFreeTextFlattening(boolean flat) {
   stamper.setFreeTextFlattening(flat);
 }
Beispiel #26
0
 public boolean isFullCompression() {
   return stamper.isFullCompression();
 }
Beispiel #27
0
 public void setAction(PdfAction action, float llx, float lly, float urx, float ury) {
   ((PdfStamperImp) writer)
       .addAnnotation(new PdfAnnotation(writer, llx, lly, urx, ury, action), ps.pageN);
 }
Beispiel #28
0
 public void setFullCompression() {
   if (stamper.isAppend()) return;
   stamper.setFullCompression();
 }
Beispiel #29
0
 public void addViewerPreference(PdfName key, PdfObject value) {
   stamper.addViewerPreference(key, value);
 }
Beispiel #30
0
 public void addComments(FdfReader fdf) throws IOException {
   stamper.addComments(fdf);
 }