/** * Creates a new instance initializing the inner {@link PdfStamper} instance. * * @param reader * input reader * @param ouputFile * {@link File} to stamp on * @param version * version for the created stamper, if null the version number is taken from the input {@link PdfReader} * @throws TaskException * in case of error */ public PdfStamperHandler(PdfReader reader, File ouputFile, PdfVersion version) throws TaskException { try { ouputStream = new FileOutputStream(ouputFile); if (version != null) { stamper = new PdfStamper(reader, ouputStream, version.getVersionAsCharacter()); } else { stamper = new PdfStamper(reader, ouputStream, reader.getPdfVersion()); } } catch (DocumentException e) { throw new TaskException("An error occurred opening the PdfStamper.", e); } catch (IOException e) { throw new TaskIOException("An IO error occurred opening the PdfStamper.", e); } }
/** * Opens the copier using the given reader and the given output version. * * @param reader * @param outputStream * the output stream to write to. * @param version * version for the created pdf copy, if null the version number is taken from the input {@link PdfReader} */ void open(PdfReader reader, OutputStream outputStream, PdfVersion version) throws TaskException { try { pdfDocument = new Document(reader.getPageSizeWithRotation(1)); pdfCopy = new PdfSmartCopy(pdfDocument, outputStream); if (version == null) { pdfCopy.setPdfVersion(reader.getPdfVersion()); } else { pdfCopy.setPdfVersion(version.getVersionAsCharacter()); } pdfDocument.addCreator(Sejda.CREATOR); pdfDocument.open(); } catch (DocumentException e) { throw new TaskException("An error occurred opening the PdfSmartCopy.", e); } }
super.setPdfVersion(reader.getPdfVersion()); else super.setPdfVersion(pdfVersion);
super.setPdfVersion(reader.getPdfVersion()); else super.setPdfVersion(pdfVersion);
super.setPdfVersion(reader.getPdfVersion()); else super.setPdfVersion(pdfVersion);