List of usage examples for com.lowagie.text.pdf PdfReader getAcroForm
public PRAcroForm getAcroForm()
From source file:lucee.runtime.text.pdf.PDFUtil.java
License:Open Source License
public static void encrypt(PDFDocument doc, OutputStream os, String newUserPassword, String newOwnerPassword, int permissions, int encryption) throws ApplicationException, DocumentException, IOException { byte[] user = newUserPassword == null ? null : newUserPassword.getBytes(); byte[] owner = newOwnerPassword == null ? null : newOwnerPassword.getBytes(); PdfReader pr = doc.getPdfReader(); List bookmarks = SimpleBookmark.getBookmark(pr); int n = pr.getNumberOfPages(); Document document = new Document(pr.getPageSizeWithRotation(1)); PdfCopy writer = new PdfCopy(document, os); if (encryption != ENCRYPT_NONE) writer.setEncryption(user, owner, permissions, encryption); document.open();/* ww w .j a v a2 s. c o m*/ PdfImportedPage page; for (int i = 1; i <= n; i++) { page = writer.getImportedPage(pr, i); writer.addPage(page); } PRAcroForm form = pr.getAcroForm(); if (form != null) writer.copyAcroForm(pr); if (bookmarks != null) writer.setOutlines(bookmarks); document.close(); }
From source file:org.fenixedu.idcards.ui.candidacydocfiller.BPIPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfBPICardAEIST(Person person) throws IOException, DocumentException { InputStream istream = getClass().getResourceAsStream(BPI_AEIST_CARD_PDF_PATH); PdfReader reader = new PdfReader(istream); reader.getAcroForm().remove(PdfName.SIGFLAGS); ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();// w ww . java2 s. co m setField("BI/CC", person.getDocumentIdNumber()); setField("Nome", person.getName()); setField("topmostSubform[0].Page1[0].Datavalidade[0]", person.getExpirationDateOfDocumentIdYearMonthDay() .toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); setField("dia", String.format("%02d", person.getExpirationDateOfDocumentIdYearMonthDay().getDayOfMonth())); setField("Ms", String.format("%02d", person.getExpirationDateOfDocumentIdYearMonthDay().getMonthOfYear())); setField("Ano", String.valueOf(person.getExpirationDateOfDocumentIdYearMonthDay().getYear())); stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.fenixedu.idcards.ui.candidacydocfiller.BPIPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfBPIDigitalDoc(Person person) throws IOException, DocumentException { InputStream istream = getClass().getResourceAsStream(BPI_DIGITAL_DOCUMENTATION_PDF_PATH); PdfReader reader = new PdfReader(istream); reader.getAcroForm().remove(PdfName.SIGFLAGS); //reader.selectPages("1"); ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();//from www . ja v a2 s .c o m setField("Text1", person.getName()); stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.fenixedu.idcards.ui.candidacydocfiller.BPIPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfBPIPersonalInformation(Person person) throws IOException, DocumentException { InputStream istream = getClass().getResourceAsStream(BPI_PERSONAL_INFORMATION_PDF_PATH); PdfReader reader = new PdfReader(istream); reader.getAcroForm().remove(PdfName.SIGFLAGS); reader.selectPages("1,2"); ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();//from w ww.ja v a 2 s .c o m setField("NomeCompleto_1", person.getName()); if (person.isFemale()) { setField("Sexo_F", "Yes"); // female } else { setField("Sexo_M", "Yes"); // male } setField("NIF", person.getSocialSecurityNumber()); setField("Numero", person.getDocumentIdNumber()); setField("Nacionalidade", person.getCountryOfBirth().getCountryNationality().toString()); setField("Naturalidade", person.getCountryOfBirth().getName()); setField("Distrito", person.getDistrictOfBirth()); setField("Concelho", person.getDistrictSubdivisionOfBirth()); setField("Freguesia", person.getParishOfBirth()); setField("NomedoPai", person.getNameOfFather()); setField("NomedaMae", person.getNameOfMother()); switch (person.getMaritalStatus()) { case CIVIL_UNION: setField("EstadoCivil_UniaodeFacto", "Yes"); break; case DIVORCED: setField("EstadoCivil_Divorciado", "Yes"); break; case MARRIED: setField("EstadoCivil_Casado", "Yes"); break; case SEPARATED: setField("EstadoCivil_Separado Judicialmente", "Yes"); break; case SINGLE: setField("EstadoCivil_Solteiro", "Yes"); break; case WIDOWER: setField("EstadoCivil_Viuvo", "Yes"); break; } setField("MoradadeResidenciaPermanente_1", person.getAddress()); setField("MoradadeResidenciaPermanente_Localidade", person.getAreaOfAreaCode()); setField("MoradadeResidenciaPermanente_DesignacaoPostal", person.getAreaOfAreaCode()); setField("MoradadeResidenciaPermanente_Pais", person.getCountryOfResidence().getName()); String postalCode = person.getPostalCode(); int dashIndex = postalCode.indexOf('-'); setField("CodigoPostal_1_1", postalCode.substring(0, 4)); String last3Numbers = postalCode.substring(dashIndex + 1, dashIndex + 4); setField("CodigoPostal_1_2", last3Numbers); setField("Contactos_Movel_Pessoal", person.getDefaultMobilePhoneNumber()); setField("Contactos_Email", getMail(person)); YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay(); if (emissionDate != null) { setField("DataEmissao_1", String.format("%02d", emissionDate.getDayOfMonth())); setField("DataEmissao_2", String.format("%02d", emissionDate.getMonthOfYear())); setField("DataEmissao_3", String.valueOf(emissionDate.getYear())); } YearMonthDay expirationDate = person.getExpirationDateOfDocumentIdYearMonthDay(); setField("Valido_1", String.format("%02d", expirationDate.getDayOfMonth())); setField("Valido_2", String.format("%02d", expirationDate.getMonthOfYear())); setField("Valido_3", String.valueOf(expirationDate.getYear())); YearMonthDay birthdayDate = person.getDateOfBirthYearMonthDay(); setField("DataNascimento_1", String.format("%02d", birthdayDate.getDayOfMonth())); setField("DataNascimento_2", String.format("%02d", birthdayDate.getMonthOfYear())); setField("DataNascimento_3", String.valueOf(birthdayDate.getYear())); stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.fenixedu.idcards.ui.candidacydocfiller.BPIPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfBPIProductsandServices(Person person) throws IOException, DocumentException { InputStream istream = getClass().getResourceAsStream(BPI_PRODUCTS_SERVICES_PDF_PATH); PdfReader reader = new PdfReader(istream); reader.getAcroForm().remove(PdfName.SIGFLAGS); reader.selectPages("1"); ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();//from www. ja v a 2s.com setField("IdentificacaoIntervenientes_1Titular", person.getName()); stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.fenixedu.idcards.ui.candidacydocfiller.CGDPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfCGDPersonalInformation(Person person) throws IOException, DocumentException { InputStream istream = getClass().getResourceAsStream(CGD_PERSONAL_INFORMATION_PDF_PATH); PdfReader reader = new PdfReader(istream); reader.getAcroForm().remove(PdfName.SIGFLAGS); reader.selectPages("1"); ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();//from w w w. j a v a 2s.com setField("T_NomeComp", person.getName()); setField("T_Email", getMail(person)); if (person.isFemale()) { setField("CB_0_1", "Yes"); // female } else { setField("CB_0_0", "Yes"); // male } setField("Cod_data_1", person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("yyyy/MM/dd"))); setField("NIF1", person.getSocialSecurityNumber()); setField("T_DocIdent", person.getDocumentIdNumber()); switch (person.getMaritalStatus()) { case CIVIL_UNION: setField("CB_EstCivil01", MARITAL_STATUS_CIVIL_UNION); break; case DIVORCED: setField("CB_EstCivil01", MARITAL_STATUS_DIVORCED); break; case MARRIED: setField("CB_EstCivil01", ""); break; case SEPARATED: setField("CB_EstCivil01", MARITAL_STATUS_SEPARATED); break; case SINGLE: setField("CB_EstCivil01", MARITAL_STATUS_SINGLE); break; case WIDOWER: setField("CB_EstCivil01", MARITAL_STATUS_WIDOWER); break; } YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay(); if (emissionDate != null) { setField("Cod_data_2", emissionDate.toString(DateTimeFormat.forPattern("yyyy/MM/dd"))); } YearMonthDay expirationDate = person.getExpirationDateOfDocumentIdYearMonthDay(); if (expirationDate != null) { setField("Cod_data_3", expirationDate.toString(DateTimeFormat.forPattern("yyyy/MM/dd"))); } setField("T_NomePai", person.getNameOfFather()); setField("T_NomeMae", person.getNameOfMother()); setField("T_NatPais", person.getCountryOfBirth().getName()); setField("T_Naturali", person.getDistrictOfBirth()); setField("T_NatConc", person.getDistrictSubdivisionOfBirth()); setField("T_NatFreg", person.getParishOfBirth()); setField("T_PaisRes", person.getCountryOfBirth().getCountryNationality().toString()); setField("T_Morada01", person.getAddress()); setField("T_Localid01", person.getAreaOfAreaCode()); setField("T_Telef", person.getDefaultMobilePhoneNumber()); String postalCode = person.getPostalCode(); int dashIndex = postalCode.indexOf('-'); setField("T_CodPos01", postalCode.substring(0, 4)); String last3Numbers = postalCode.substring(dashIndex + 1, dashIndex + 4); setField("T_CodPos03_1", last3Numbers); setField("T_Localid02_1", person.getAreaOfAreaCode()); setField("T_Distrito", person.getDistrictOfResidence()); setField("T_Conc", person.getDistrictSubdivisionOfResidence()); setField("T_Freguesia", person.getParishOfResidence()); setField("T_PaisResid", person.getCountryOfResidence().getName()); stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.fenixedu.idcards.ui.candidacydocfiller.SantanderPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfSantanderApplication(Person person) throws IOException, DocumentException { InputStream istream = getClass().getResourceAsStream(SANTANDER_APPLICATION_PDF_PATH); PdfReader reader = new PdfReader(istream); reader.getAcroForm().remove(PdfName.SIGFLAGS); reader.selectPages("1,2"); ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();//w ww.j a v a2 s. c om setField("topmostSubform[0].Page1[0].Nomecompleto[0]", person.getName()); String documentIdNumber = person.getDocumentIdNumber(); if (person.getIdDocumentType().equals(IDDocumentType.CITIZEN_CARD) || person.getIdDocumentType().equals(IDDocumentType.IDENTITY_CARD)) { setField("topmostSubform[0].Page1[0].NumBICartaoCidadaooutro[0]", documentIdNumber); setField("topmostSubform[0].Page1[0].Checkdigit[0]", person.getIdentificationDocumentSeriesNumberValue()); } else { setField("topmostSubform[0].Page1[0].Outrotipodocidentificacao[0]", documentIdNumber); } YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay(); if (emissionDate != null) { setField("topmostSubform[0].Page1[0].Dataemissao[0]", emissionDate.toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); } setField("topmostSubform[0].Page1[0].Datavalidade[0]", person.getExpirationDateOfDocumentIdYearMonthDay() .toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); setField("topmostSubform[0].Page1[0].NIF[0]", person.getSocialSecurityNumber()); setField("topmostSubform[0].Page1[0].Datanascimento[0]", person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("dd/MM/yyyy"))); YearMonthDay dateOfBirthYearMonthDay = person.getDateOfBirthYearMonthDay(); Period periodBetween = new Period(dateOfBirthYearMonthDay, new YearMonthDay()); setField("topmostSubform[0].Page1[0].Idadeactual[0]", String.valueOf(periodBetween.get(DurationFieldType.years()))); if (person.isFemale()) { setField("topmostSubform[0].Page1[0].Sexo[0]", "F"); // female } else if (person.isMale()) { setField("topmostSubform[0].Page1[0].Sexo[0]", "M"); // male } switch (person.getMaritalStatus()) { case CIVIL_UNION: setField("topmostSubform[0].Page1[0].Uniaofacto[0]", "1"); break; case DIVORCED: setField("topmostSubform[0].Page1[0].Divorciado[0]", "1"); break; case MARRIED: setField("topmostSubform[0].Page1[0].Casado[0]", "1"); break; case SEPARATED: setField("topmostSubform[0].Page1[0].Separado[0]", "1"); break; case SINGLE: setField("topmostSubform[0].Page1[0].Solteiro[0]", "1"); break; case WIDOWER: setField("topmostSubform[0].Page1[0].Viuvo[0]", "1"); break; } setField("topmostSubform[0].Page1[0].Telemovel[0]", person.getDefaultMobilePhoneNumber()); setField("topmostSubform[0].Page1[0].E-mail[0]", getMail(person)); setField("topmostSubform[0].Page1[0].Moradaresidenciapermanente[0]", person.getAddress()); setField("topmostSubform[0].Page1[0].localidade[0]", person.getAreaOfAreaCode()); String postalCode = person.getPostalCode(); int dashIndex = postalCode.indexOf('-'); setField("topmostSubform[0].Page1[0].CodPostal[0]", postalCode.substring(0, 4)); String last3Numbers = person.getPostalCode().substring(dashIndex + 1, dashIndex + 4); setField("topmostSubform[0].Page1[0].ExtensaoCodPostal[0]", last3Numbers); setField("topmostSubform[0].Page1[0].Paisnacionalidade", person.getCountry().getCountryNationality().getPreferedContent()); setField("topmostSubform[0].Page1[0].Paisnascimento", person.getCountryOfBirth().getName()); setField("topmostSubform[0].Page1[0].Paisresidencia", person.getCountryOfResidence().getName()); setField("topmostSubform[0].Page2[0].InstituioEnsinoSuperior[0]", UniversityUnit.getInstitutionsUniversityUnit().getName()); setField("topmostSubform[0].Page2[0].FaculdadeEscola[0]", Bennu.getInstance().getInstitutionUnit().getName()); Registration registration = getRegistration(person); if (registration != null) { setField("topmostSubform[0].Page2[0].Curso[0]", registration.getDegree().getSigla()); setField("topmostSubform[0].Page2[0].AnoIncioCurso[0]", String.valueOf(registration.getStartDate().getYear())); } stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.fenixedu.ulisboa.specifications.ui.firstTimeCandidacy.util.CGDPdfFiller.java
License:Open Source License
private ByteArrayOutputStream getFilledPdfCGDPersonalInformation(Person person, InputStream pdfTemplateStream) throws IOException, DocumentException { PdfReader reader = new PdfReader(pdfTemplateStream); reader.getAcroForm().remove(PdfName.SIGFLAGS); reader.selectPages("1,3,4"); // The template we are using has a blank page after the front sheet. ByteArrayOutputStream output = new ByteArrayOutputStream(); PdfStamper stamper = new PdfStamper(reader, output); form = stamper.getAcroFields();/*from ww w . java 2 s . c o m*/ setField("T_NomeComp", person.getName()); setField("T_Email", getMail(person)); if (person.isFemale()) { setField("CB_0_1", "Yes"); // female } else { setField("CB_0_0", "Yes"); // male } if (person.getDateOfBirthYearMonthDay() != null) { setField("Cod_data_1", person.getDateOfBirthYearMonthDay().toString(DateTimeFormat.forPattern("yyyy/MM/dd"))); } setField("NIF1", person.getSocialSecurityNumber()); setField("T_DocIdent", person.getDocumentIdNumber()); switch (person.getMaritalStatus()) { case CIVIL_UNION: setField("CB_EstCivil01", MARITAL_STATUS_CIVIL_UNION); break; case DIVORCED: setField("CB_EstCivil01", MARITAL_STATUS_DIVORCED); break; case MARRIED: setField("CB_EstCivil01", ""); break; case SEPARATED: setField("CB_EstCivil01", MARITAL_STATUS_SEPARATED); break; case SINGLE: setField("CB_EstCivil01", MARITAL_STATUS_SINGLE); break; case WIDOWER: setField("CB_EstCivil01", MARITAL_STATUS_WIDOWER); break; } YearMonthDay emissionDate = person.getEmissionDateOfDocumentIdYearMonthDay(); if (emissionDate != null) { setField("Cod_data_2", emissionDate.toString(DateTimeFormat.forPattern("yyyy/MM/dd"))); } YearMonthDay expirationDate = person.getExpirationDateOfDocumentIdYearMonthDay(); if (expirationDate != null) { setField("Cod_data_3", expirationDate.toString(DateTimeFormat.forPattern("yyyy/MM/dd"))); } setField("T_NomePai", person.getNameOfFather()); setField("T_NomeMae", person.getNameOfMother()); if (person.getCountryOfBirth() != null) { setField("T_NatPais", person.getCountryOfBirth().getName()); setField("T_Naturali", person.getDistrictOfBirth()); setField("T_NatConc", person.getDistrictSubdivisionOfBirth()); setField("T_NatFreg", person.getParishOfBirth()); setField("T_PaisRes", person.getCountryOfBirth().getCountryNationality().toString()); } setField("T_Morada01", person.getAddress()); setField("T_Localid01", person.getAreaOfAreaCode()); setField("T_Telef", person.getDefaultMobilePhoneNumber()); String postalCode = person.getPostalCode(); int dashIndex = postalCode.indexOf('-'); if (postalCode != null && postalCode.length() >= dashIndex + 4) { setField("T_CodPos01", postalCode.substring(0, 4)); String last3Numbers = postalCode.substring(dashIndex + 1, dashIndex + 4); setField("T_CodPos03_1", last3Numbers); setField("T_Localid02_1", person.getAreaOfAreaCode()); } if (person.getCountryOfResidence() != null) { setField("T_Distrito", person.getDistrictOfResidence()); setField("T_Conc", person.getDistrictSubdivisionOfResidence()); setField("T_Freguesia", person.getParishOfResidence()); setField("T_PaisResid", person.getCountryOfResidence().getName()); } stamper.setFormFlattening(true); stamper.close(); return output; }
From source file:org.jaffa.modules.printing.services.MultiFormPrintEngine.java
License:Open Source License
/** * Merge a list of generated Pdf Documents together * @param documents /*from ww w.j a v a2 s.co m*/ * @throws java.io.IOException * @throws com.lowagie.text.DocumentException * @return byte[] */ public static byte[] mergePdf(List<byte[]> documents) throws IOException, DocumentException { int pageOffset = 0; ArrayList master = new ArrayList(); ByteArrayOutputStream output = new ByteArrayOutputStream(); Document document = null; PdfCopy writer = null; boolean first = true; for (Iterator<byte[]> it = documents.iterator(); it.hasNext();) { // we create a reader for a certain document PdfReader reader = new PdfReader(it.next()); reader.consolidateNamedDestinations(); // we retrieve the total number of pages int n = reader.getNumberOfPages(); List bookmarks = SimpleBookmark.getBookmark(reader); if (bookmarks != null) { if (pageOffset != 0) SimpleBookmark.shiftPageNumbers(bookmarks, pageOffset, null); master.addAll(bookmarks); } pageOffset += n; if (first) { first = false; // step 1: creation of a document-object document = new Document(reader.getPageSizeWithRotation(1)); // step 2: we create a writer that listens to the document writer = new PdfCopy(document, output); // step 3: we open the document document.open(); } // step 4: we add content PdfImportedPage page; for (int i = 0; i < n;) { ++i; page = writer.getImportedPage(reader, i); writer.addPage(page); } PRAcroForm form = reader.getAcroForm(); if (form != null) writer.copyAcroForm(reader); } if (master.size() > 0) writer.setOutlines(master); // step 5: we close the document if (document != null) document.close(); return output.toByteArray(); }
From source file:org.jpedal.examples.simpleviewer.utils.ItextFunctions.java
License:Open Source License
public void extractPagesToNewPDF(SavePDF current_selection) { final boolean exportIntoMultiplePages = current_selection.getExportType(); final int[] pgsToExport = current_selection.getExportPages(); if (pgsToExport == null) return;/*from ww w .j a v a 2 s .c o m*/ final int noOfPages = pgsToExport.length; // get user choice final String output_dir = current_selection.getRootDir() + separator + fileName + separator + "PDFs" + separator; File testDirExists = new File(output_dir); if (!testDirExists.exists()) testDirExists.mkdirs(); final ProgressMonitor status = new ProgressMonitor(currentGUI.getFrame(), Messages.getMessage("PdfViewerMessage.GeneratingPdfs"), "", 0, noOfPages); final SwingWorker worker = new SwingWorker() { public Object construct() { if (exportIntoMultiplePages) { boolean yesToAll = false; for (int i = 0; i < noOfPages; i++) { int page = pgsToExport[i]; if (status.isCanceled()) { currentGUI.showMessageDialog(Messages.getMessage("PdfViewerError.UserStoppedExport") + i + " " + Messages.getMessage("PdfViewerError.ReportNumberOfPagesExported")); return null; } try { PdfReader reader = new PdfReader(selectedFile); File fileToSave = new File(output_dir + fileName + "_pg_" + page + ".pdf"); if (fileToSave.exists() && !yesToAll) { if (pgsToExport.length > 1) { int n = currentGUI.showOverwriteDialog(fileToSave.getAbsolutePath(), true); if (n == 0) { // clicked yes so just carry on for this // once } else if (n == 1) { // clicked yes to all, so set flag yesToAll = true; } else if (n == 2) { // clicked no, so loop round again status.setProgress(page); continue; } else { currentGUI.showMessageDialog( Messages.getMessage("PdfViewerError.UserStoppedExport") + i + " " + Messages.getMessage( "PdfViewerError.ReportNumberOfPagesExported")); status.close(); return null; } } else { int n = currentGUI.showOverwriteDialog(fileToSave.getAbsolutePath(), false); if (n == 0) { // clicked yes so just carry on } else { // clicked no, so exit return null; } } } Document document = new Document(); PdfCopy writer = new PdfCopy(document, new FileOutputStream(fileToSave)); document.open(); PdfImportedPage pip = writer.getImportedPage(reader, page); writer.addPage(pip); PRAcroForm form = reader.getAcroForm(); if (form != null) { writer.copyAcroForm(reader); } document.close(); } catch (Exception de) { de.printStackTrace(); } status.setProgress(i + 1); } } else { try { PdfReader reader = new PdfReader(selectedFile); File fileToSave = new File(output_dir + "export_" + fileName + ".pdf"); if (fileToSave.exists()) { int n = currentGUI.showOverwriteDialog(fileToSave.getAbsolutePath(), false); if (n == 0) { // clicked yes so just carry on } else { // clicked no, so exit return null; } } Document document = new Document(); PdfCopy copy = new PdfCopy(document, new FileOutputStream(fileToSave.getAbsolutePath())); document.open(); PdfImportedPage pip; for (int i = 0; i < noOfPages; i++) { int page = pgsToExport[i]; pip = copy.getImportedPage(reader, page); copy.addPage(pip); } PRAcroForm form = reader.getAcroForm(); if (form != null) { copy.copyAcroForm(reader); } List bookmarks = SimpleBookmark.getBookmark(reader); copy.setOutlines(bookmarks); document.close(); } catch (Exception de) { de.printStackTrace(); } } status.close(); currentGUI.showMessageDialog( Messages.getMessage("PdfViewerMessage.PagesSavedAsPdfTo") + " " + output_dir); return null; } }; worker.start(); }