List of usage examples for org.apache.pdfbox.pdmodel PDPage PDPage
public PDPage()
From source file:mail.java
private void ImprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ImprimirActionPerformed try {// w w w.j av a2s.c o m // TODO add your handling code here: PDDocument documento = new PDDocument(); PDPage paginablanco = new PDPage(); documento.addPage(paginablanco); PDPageContentStream content; try { content = new PDPageContentStream(documento, paginablanco); content.beginText(); content.setFont(PDType1Font.HELVETICA, 9); content.newLineAtOffset(50, 780); content.showText("Consejo Profesional de Abogacia"); content.endText(); content.beginText(); content.setFont(PDType1Font.HELVETICA, 9); content.newLineAtOffset(450, 780); Locale espanol = new Locale("es", "ES"); SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE MMMM d HH:mm:ss z yyyy", espanol); String fecha = dateFormat.format(new Date()); content.showText(fecha); content.endText(); content.beginText(); content.setFont(PDType1Font.HELVETICA, 6); content.newLineAtOffset(50, 770); content.showText("Direccin: San Martin 457 - Formosa"); content.endText(); content.beginText(); content.setFont(PDType1Font.HELVETICA, 10); content.newLineAtOffset(200, 750); content.showText("Estado de Cuenta de Matricula"); content.endText(); content.beginText(); content.setFont(PDType1Font.HELVETICA, 10); content.newLineAtOffset(50, 735); content.showText("Matricula N " + idmatricula + " Nombre: " + nombre + "," + apellido);// content.endText(); content.beginText(); content.setFont(PDType1Font.HELVETICA, 10); content.newLineAtOffset(100, 705); content.showText( "Items Periodo Vencimiento Importe"); content.endText(); content.addRect(50, 10, 400, 700); int j = 0; int renglon = 685; System.out.println(itemsList.size()); for (int i = 1; i < itemsList.size(); i++) { content.beginText(); content.setFont(PDType1Font.HELVETICA, 10); j++; content.newLineAtOffset(100, renglon); content.showText(" " + i + " " + itemsList.get(i).getVencimiento() + " " + itemsList.get(i).getPeriodo() + " " + String.valueOf(itemsList.get(i).getImporte())); renglon = renglon - 13; content.endText(); } content.beginText(); content.newLineAtOffset(100, renglon - 20); DecimalFormatSymbols simbolos = new DecimalFormatSymbols(); simbolos.setDecimalSeparator('.'); DecimalFormat decim = new DecimalFormat("0.00", simbolos); content.showText("Total Adeudado :$ " + String.valueOf(decim.format(total))); content.endText(); content.close(); documento.save("matricula_" + idmatricula + ".pdf"); documento.close(); System.out.println("guardo archivo matricula_" + idmatricula + ".pdf"); EnviarMail.setEnabled(true); } catch (IOException ex) { EnviarMail.setEnabled(false); Logger.getLogger(mail.class.getName()).log(Level.SEVERE, null, ex); } bonos(); } catch (SQLException ex) { Logger.getLogger(mail.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:PDFUtil.java
License:Apache License
boolean create() { PDDocument doc = new PDDocument(); doc.addPage(new PDPage()); File testExist = new File(path); if (!testExist.exists()) { try {/*from www . jav a 2 s . c o m*/ doc.save(path); } catch (IOException e) { System.out.println("Path doesn't existed"); String dir = path.substring(0, path.lastIndexOf('\\')); File temp = new File(dir); //noinspection ResultOfMethodCallIgnored temp.mkdirs(); try { doc.save(path); } catch (IOException ignored) { } return false; } finally { try { doc.close(); } catch (IOException ignored) { } } } else { System.out.println("File existed, can't create file"); return false; } return true; }
From source file:app.Instance.java
/** * Ajoute un nouveau fichier/* w ww. jav a 2s . c o m*/ * * @param fileName * @return * @throws IOException */ public static DocFile addNewFile(String fileName) { DocFile docFile = null; File file = new File(fileName); PDDocument document = new PDDocument(); document.addPage(new PDPage()); docFile = new DocFile(docFiles.size(), document, file); opened = docFile.getId(); docFiles.add(docFile); return docFile; }
From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFAsVisualSignatureBuilder.java
License:EUPL
public void createMyPage(PDFAsVisualSignatureDesigner properties) { PDPage page = properties.getSignaturePage(); if (page == null) { page = new PDPage(); page.setMediaBox(new PDRectangle(properties.getPageWidth(), properties.getPageHeight())); }// w w w . jav a2 s.com getStructure().setPage(page); logger.info("PDF page has been created"); }
From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFAsVisualSignatureBuilder.java
License:EUPL
public void createPage(PDFAsVisualSignatureDesigner properties) { PDPage page = new PDPage(); page.setMediaBox(new PDRectangle(properties.getPageWidth(), properties.getPageHeight())); page.setRotation(properties.getPageRotation()); getStructure().setPage(page);/*from ww w. ja v a 2 s .c o m*/ logger.debug("PDF page has been created"); }
From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFAsVisualSignatureDesigner.java
License:EUPL
public PDPage getSignaturePage() { if (page < 1) { throw new IllegalArgumentException("First page of pdf is 1, not " + page); }//from ww w . j a va 2 s. c o m PDPage pdPage = null; List<?> pages = document.getDocumentCatalog().getAllPages(); if (newpage) { pdPage = new PDPage(); } else { pdPage = (PDPage) pages.get(page - 1); } return pdPage; }
From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2.PDFAsVisualSignatureDesigner.java
License:EUPL
public PDPage getSignaturePage() { if (page < 1) { throw new IllegalArgumentException("First page of pdf is 1, not " + page); }//from w ww .ja va2s. com PDPage pdPage = null; PDPageTree pages = document.getDocumentCatalog().getPages(); if (newpage) { pdPage = new PDPage(); } else { pdPage = (PDPage) pages.get(page - 1); } return pdPage; }
From source file:at.medevit.elexis.impfplan.ui.handlers.PrintVaccinationEntriesHandler.java
License:Open Source License
private void createPDF(Patient patient, Image image) throws IOException, COSVisitorException { PDDocumentInformation pdi = new PDDocumentInformation(); Mandant mandant = (Mandant) ElexisEventDispatcher.getSelected(Mandant.class); pdi.setAuthor(mandant.getName() + " " + mandant.getVorname()); pdi.setCreationDate(new GregorianCalendar()); pdi.setTitle("Impfausweis " + patient.getLabel()); PDDocument document = new PDDocument(); document.setDocumentInformation(pdi); PDPage page = new PDPage(); page.setMediaBox(PDPage.PAGE_SIZE_A4); document.addPage(page);/* w ww . jav a 2s . c om*/ PDRectangle pageSize = page.findMediaBox(); PDFont font = PDType1Font.HELVETICA_BOLD; PDFont subFont = PDType1Font.HELVETICA; PDPageContentStream contentStream = new PDPageContentStream(document, page); contentStream.beginText(); contentStream.setFont(font, 14); contentStream.moveTextPositionByAmount(40, pageSize.getUpperRightY() - 40); contentStream.drawString(patient.getLabel()); contentStream.endText(); String dateLabel = sdf.format(Calendar.getInstance().getTime()); String title = Person.load(mandant.getId()).get(Person.TITLE); String mandantLabel = title + " " + mandant.getName() + " " + mandant.getVorname(); contentStream.beginText(); contentStream.setFont(subFont, 10); contentStream.moveTextPositionByAmount(40, pageSize.getUpperRightY() - 55); contentStream.drawString("Ausstellung " + dateLabel + ", " + mandantLabel); contentStream.endText(); BufferedImage imageAwt = convertToAWT(image.getImageData()); PDXObjectImage pdPixelMap = new PDPixelMap(document, imageAwt); contentStream.drawXObject(pdPixelMap, 40, 30, pageSize.getWidth() - 80, pageSize.getHeight() - 100); contentStream.close(); String outputPath = CoreHub.userCfg.get(PreferencePage.VAC_PDF_OUTPUTDIR, CoreHub.getWritableUserDir().getAbsolutePath()); if (outputPath.equals(CoreHub.getWritableUserDir().getAbsolutePath())) { SWTHelper.showInfo("Kein Ausgabeverzeichnis definiert", "Ausgabe erfolgt in: " + outputPath + "\nDas Ausgabeverzeichnis kann unter Einstellungen\\Klinische Hilfsmittel\\Impfplan definiert werden."); } File outputDir = new File(outputPath); File pdf = new File(outputDir, "impfplan_" + patient.getPatCode() + ".pdf"); document.save(pdf); document.close(); Desktop.getDesktop().open(pdf); }
From source file:au.org.alfred.icu.pdf.services.factories.ICUDischargeSummaryFactory.java
public static void createDischargeSummaryPDF(PDDocument pdf) { PDPage front = new PDPage(); pdf.addPage(front); }
From source file:barcode.printer.view.PrintForm.java
License:Apache License
public void buttonPrintAction() { if (listModel.isEmpty()) { return;/*ww w. j a va 2 s . co m*/ } try (PDDocument document = new PDDocument()) { PDPage page = new PDPage(); document.addPage(page); PDFont font = PDType1Font.COURIER_BOLD; float fontSize = 10f; float fontWidth = font.getStringWidth("W") / 1000 * fontSize; float fontHeight = font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontSize; float startXOrigin = fontWidth * 0.3f; float startYOrigin = page.findMediaBox().getUpperRightY(); float startX = startXOrigin; float startY; try (PDPageContentStream cs = new PDPageContentStream(document, page)) { int bcWidth = 80; int bcHeight = 20; int row = 1; for (int idx = 0; idx < listModel.getSize(); idx++) { BitMatrix bitMatrix; String strBarCode = listModel.get(idx); switch (comboCode.getSelectedIndex()) { case 0: bitMatrix = new CodaBarWriter().encode(strBarCode, BarcodeFormat.CODABAR, bcWidth, bcHeight); break; case 1: bitMatrix = new Code128Writer().encode(strBarCode, BarcodeFormat.CODE_128, bcWidth, bcHeight); break; case 2: bitMatrix = new Code39Writer().encode(strBarCode, BarcodeFormat.CODE_39, bcWidth, bcHeight); break; case 3: bitMatrix = new EAN13Writer().encode(strBarCode, BarcodeFormat.EAN_13, bcWidth, bcHeight); break; case 4: bitMatrix = new EAN8Writer().encode(strBarCode, BarcodeFormat.EAN_8, bcWidth, bcHeight); break; case 5: bitMatrix = new ITFWriter().encode(strBarCode, BarcodeFormat.ITF, bcWidth, bcHeight); break; default: bitMatrix = new CodaBarWriter().encode(strBarCode, BarcodeFormat.CODABAR, bcWidth, bcHeight); break; } BufferedImage bufferedImage = MatrixToImageWriter.toBufferedImage(bitMatrix); PDXObjectImage pdxoi = new PDJpeg(document, bufferedImage); startY = startYOrigin - (bitMatrix.getHeight() * row * 1.6f); row++; cs.beginText(); cs.setFont(font, fontSize); cs.moveTextPositionByAmount(startX + fontWidth, startY + fontHeight); cs.drawString(strBarCode); cs.endText(); cs.drawImage(pdxoi, startX, startY - fontHeight); } } document.silentPrint(); listModel.clear(); buttonDelete.setEnabled(false); } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage()); LOGGER.log(Level.SEVERE, null, ex); } }