List of usage examples for com.itextpdf.text Rectangle Rectangle
public Rectangle(com.itextpdf.awt.geom.Rectangle rect)
Rectangle
-object based on a com.itextpdf.awt.geom.Rectangle
object From source file:src.GUI.PDFGEN.java
License:Open Source License
private void PDFLB(int AmountExer, GUISETTINGSPDF k) { Document Doc = new Document(); Rectangle Rec = new Rectangle(PageSize.A4); Doc.setPageSize(Rec);//from www . ja v a 2s .c om try { G = File.createTempFile("Blatt", ".pdf"); PdfWriter.getInstance(Doc, new FileOutputStream(G)); Doc.open(); Paragraph Para = new Paragraph("Lsungsblatt", FONTS.FontHeader()); Para.setAlignment(Element.ALIGN_CENTER); Doc.add(Para); for (int i = 1; i <= AmountExer; i++) { List = new List(List.ORDERED, List.ALPHABETICAL); for (int c = 0; c < k.taskNumber; c++) { String S = First.readExercise() + First.readSolution(); List.add(new ListItem(S)); First = First.Next; } Doc.add(new Paragraph(" \n Aufgabe" + i, FONTS.Font())); Doc.add(List); k = k.next; } Doc.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:storybook.export.ExportPDF.java
public void open() { SbApp.trace("ExportPDF.open()"); outDoc = new Document(); Rectangle rectangle = new Rectangle(PageSize.getRectangle(parent.parent.paramExport.pdfPageSize)); if (parent.parent.paramExport.pdfLandscape) { rectangle = new Rectangle(PageSize.getRectangle(parent.parent.paramExport.pdfPageSize).rotate()); }/*from w w w. j ava 2 s.c o m*/ outDoc.setPageSize(rectangle); try { writer = PdfWriter.getInstance(outDoc, new FileOutputStream(fileName)); } catch (FileNotFoundException | DocumentException ex) { SbApp.error(ExportPDF.class.getName(), ex); } outDoc.open(); addMetaData(); try { outDoc.add(new Phrase(parent.bookTitle + " - " + parent.exportData.getKey() + "\n", FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD))); } catch (DocumentException ex) { SbApp.error("ExportPDF.open()", ex); } if (headers == null) return; float hsize[] = new float[headers.size()]; int i = 0; for (ExportHeader header : headers) { hsize[i] = header.getSize(); i++; } table = new PdfPTable(hsize); for (ExportHeader header : headers) { table.addCell(new Phrase(header.getName(), FontFactory.getFont(FontFactory.HELVETICA, 10, Font.BOLD))); } }
From source file:voedselbank.OverzichtScherm.java
private void exporteerKnopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exporteerKnopActionPerformed try {/* w w w .ja v a 2 s. co m*/ JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(".")); chooser.setDialogTitle("Kies een locatie"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) { Document doc = new Document(); Rectangle rect = new Rectangle(PageSize.A4.rotate()); PdfWriter.getInstance(doc, new FileOutputStream(chooser.getSelectedFile() + "/overzicht.pdf")); doc.setPageSize(rect); doc.open(); PdfPTable pdfTable = new PdfPTable(overzichtTabel.getColumnCount()); pdfTable.setWidthPercentage(108); pdfTable.setHorizontalAlignment(Element.ALIGN_CENTER); //adding table headers for (int i = 0; i < overzichtTabel.getColumnCount(); i++) { PdfPCell head = new PdfPCell(new Paragraph(overzichtTabel.getColumnName(i))); head.setHorizontalAlignment(Element.ALIGN_CENTER); head.setBackgroundColor(new BaseColor(236, 116, 4)); pdfTable.addCell(head); } //extracting data from the JTable and inserting it to PdfPTable for (int rows = 0; rows < overzichtTabel.getRowCount(); rows++) { for (int cols = 0; cols < overzichtTabel.getColumnCount(); cols++) { pdfTable.addCell(overzichtTabel.getModel().getValueAt(rows, cols).toString()); } } doc.add(pdfTable); doc.close(); System.out.println("Done"); } else { System.out.println("U heeft niks geselecteerd."); } } catch (FileNotFoundException | DocumentException e) { e.printStackTrace(); } }