List of usage examples for com.itextpdf.text PageSize A5
Rectangle A5
To view the source code for com.itextpdf.text PageSize A5.
Click Source Link
From source file:br.com.ifrn.panfleto.gui.PainelCadastrar.java
public Rectangle tamanhoDaPagina() { if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A0")) { return new Rectangle(PageSize.A0); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A1")) { return new Rectangle(PageSize.A1); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A2")) { return new Rectangle(PageSize.A2); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A3")) { return new Rectangle(PageSize.A3); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A4")) { return new Rectangle(PageSize.A4); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("A5")) { return new Rectangle(PageSize.A5); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B0")) { return new Rectangle(PageSize.B0); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B1")) { return new Rectangle(PageSize.B1); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B2")) { return new Rectangle(PageSize.B2); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B3")) { return new Rectangle(PageSize.B3); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B4")) { return new Rectangle(PageSize.B4); } else if (comboxSelecionarTamanhoPaginaPainelGerarPdf.getSelectedItem().equals("B5")) { return new Rectangle(PageSize.B5); }//w ww .jav a2 s. c o m //caso erro, retorna o tamanho a4 como padrao return new Rectangle(PageSize.A4); }
From source file:co.ordinate.printer.NewJFrame.java
private void printA6Sheet() { new SwingWorker<Object, Object>() { String filename;/*from ww w .j a v a2 s . co m*/ @Override protected void done() { ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); System.err.println("Printing Done"); } @Override protected Object doInBackground() throws Exception { Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("A6.pdf")); doc.open(); doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : "); doc.addSubject("Confidential Report Eyes Only"); doc.addKeywords(""); doc.addAuthor("SOS"); doc.addCreator("SOS"); // A4 = 210mm x 297mm ~ 605points x 855points doc.setPageSize(PageSize.A5); doc.setMargins(10f, 10f, 10f, 10f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); int i = 1; while (i <= pageno) { doc.newPage(); i++; } BaseFont labelFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, "Cp1252", true); float width = doc.getPageSize().getWidth(); float height = doc.getPageSize().getHeight(); for (float h = 0; h <= height; h++) { for (float w = 0; w <= width; w++) { cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(w, h); cb.showText(String.valueOf(h) + ":" + String.valueOf(w)); cb.endText(); w += 30; } h += 8; } cb.beginText(); // cb.setColorFill(TITLE_COLOR); cb.setFontAndSize(labelFont, 4); cb.setTextMatrix(20f, 220f); cb.showText("abcd"); cb.endText(); } catch (Exception e) { System.err.println(e.getMessage()); ConsoleMsg(e.getMessage()); } finally { doc.close(); } ConsoleMsg("PDF... GENERATED"); System.err.println("Printing Done"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); // TODO add your handling code here: }
From source file:com.softwaremagico.tm.pdf.small.SmallCharacterSheet.java
License:Open Source License
@Override protected Rectangle getPageSize() { return PageSize.A5; }
From source file:Forms.CloseCash.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String sql = "SELECT * FROM `cash` WHERE 1"; Date dNow = new Date(); SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy"); String date = "" + ft.format(dNow); File theDir = new File("E:\\Reports"); // if the directory does not exist, create it if (!theDir.exists()) { //System.out.println("creating directory: " + directoryName); boolean result = false; try {/*from w ww . j av a 2 s . co m*/ theDir.mkdir(); result = true; } catch (SecurityException se) { //handle it } } try { Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/nafis", "root", ""); Statement s = (Statement) con.prepareStatement(sql); ResultSet rs = s.executeQuery(sql); Document document = new Document(PageSize.A5); PdfWriter.getInstance(document, new FileOutputStream("E:\\Reports\\report(" + date + ").pdf")); document.open(); Image image = Image.getInstance("api.png"); document.add(image); document.add(new Paragraph("UNITY POS REPORS", FontFactory.getFont(FontFactory.TIMES_BOLD, 20, Font.BOLD, BaseColor.BLUE))); document.add(new Paragraph(date, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph( "--------------------------------------------------------------------------------------")); PdfPTable table = new PdfPTable(4); //table.addCell("Date"); //table.addCell("Cash In/Out"); PdfPCell cell = new PdfPCell(new Phrase("Date")); cell.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(cell); PdfPCell ce = new PdfPCell(new Phrase("Cash In/Out")); ce.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(ce); PdfPCell c = new PdfPCell(new Phrase("Cause")); c.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(c); PdfPCell cel = new PdfPCell(new Phrase("Amount")); cel.setBackgroundColor(BaseColor.DARK_GRAY); table.addCell(cel); document.add(new Paragraph(" ")); document.add(table); float in = 0, out = 0; while (rs.next()) { String dateof = rs.getString(5); String inout = rs.getString(2); String cause = rs.getString(3); String amount = rs.getString(4); if (inout.equalsIgnoreCase("Cash In")) { in = in + Float.parseFloat(amount); } else { out = out + Float.parseFloat(amount); } PdfPTable t = new PdfPTable(4); t.addCell(dateof); t.addCell(inout); t.addCell(cause); t.addCell(amount); document.add(t); } System.out.println("in=" + in + "out=" + out); document.add(new Paragraph(" ")); document.add(new Paragraph("Total Invested: " + out, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph("Total Return: " + in, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph("Total Earned: " + (in - out), FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.BLACK))); document.add(new Paragraph(" ")); document.add(new Paragraph( "--------------------------------------------------------------------------------------")); document.close(); } catch (Exception ex) { JOptionPane.showMessageDialog(null, "problem in memoo"); } /////////////////////////// //to open pdf invoice try { Runtime.getRuntime() .exec("rundll32 url.dll,FileProtocolHandler " + "E:\\Reports\\report(" + date + ").pdf"); } catch (IOException ex) { Logger.getLogger(SellPage.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:itext_result.Main.java
private int developScreeningSheet() { new SwingWorker<Object, Object>() { String filename;/* ww w .j a va 2 s . com*/ @Override protected void done() { // ConsoleMsg("Printing PROFILE SHEET IN PROGRESS.. "); } public PdfPCell createBarcode(PdfWriter writer, String code) throws DocumentException, IOException { BarcodeEAN barcode = new BarcodeEAN(); barcode.setCodeType(Barcode.EAN8); barcode.setCode(code); PdfPCell cell = new PdfPCell( barcode.createImageWithBarcode(writer.getDirectContent(), BaseColor.BLACK, BaseColor.GRAY), true); cell.setPadding(10); return cell; } class ImageContent implements PdfPTableEvent { protected com.itextpdf.text.Image content; public ImageContent(com.itextpdf.text.Image content) { this.content = content; } public void tableLayout(PdfPTable table, float[][] widths, float[] heights, int headerRows, int rowStart, PdfContentByte[] canvases) { try { PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS]; float x = widths[3][1] + 10; float y = heights[3] - 10 - content.getScaledHeight(); content.setAbsolutePosition(x, y); canvas.addImage(content); } catch (DocumentException e) { throw new ExceptionConverter(e); } } } @Override protected Object doInBackground() throws Exception { // System.err.println(" Roll No Received ....." + rollno); Document doc = new Document(); try { PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream("12345" + ".pdf")); doc.open(); doc.addTitle("Recruitment PET Sheett - " + "Created By SOS : "); doc.addSubject("Confidential Report Eyes Only"); doc.addKeywords(""); doc.addAuthor("SOS"); doc.addCreator("SOS"); // A4 = 210mm x 297mm ~ 605points x 855points doc.setPageSize(PageSize.A5); doc.setMargins(15f, 15f, 15f, 15f); ///////////////////////////////////////////////////////////// int pageno = 1; for (int i = 0; i == pageno; i++) { // doc.add(imageRight); } PdfContentByte cb = writer.getDirectContent(); //DONE BarcodeEAN codeEAN = new BarcodeEAN(); codeEAN.setCodeType(Barcode.EAN8); Barcode128 code128 = new Barcode128(); code128.setCode(String.valueOf("123456")); Barcode128 code128_jacket = new Barcode128(); code128_jacket.setCode(String.valueOf("10345")); codeEAN.setCode(String.valueOf("123456")); com.itextpdf.text.Image imageEAN = code128.createImageWithBarcode(cb, null, null); // imageEAN.scalePercent(10f); //464f, 725f // imageEAN.setAbsolutePosition(474f, 662f); int i = 1; while (i <= pageno) { doc.newPage(); // cb.addImage(imageRight); // cb.addImage(imageEAN); i++; } com.itextpdf.text.Image carcode = code128_jacket.createImageWithBarcode(cb, null, null); carcode.scaleAbsolute(100f, 35f); carcode.setAbsolutePosition(500f, 600f); writer.addDirectImageSimple(carcode); // cb.addImage(carcode); com.itextpdf.text.Image carcode2 = code128.createImageWithBarcode(cb, null, null); carcode2.scaleAbsolute(100f, 35f); carcode2.setAbsolutePosition(450f, 760f); writer.addDirectImageSimple(carcode2); // cb.addImage(carcode2); Image image1 = Image.getInstance("jklogo.gif"); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(99); table.addCell(image1); doc.add(table); table = new PdfPTable(4); table.setWidthPercentage(99); float[] columnWidths = { 6, 2 }; PdfPTable CandidateTable = new PdfPTable(columnWidths); Font f = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); Font fsmall = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL, GrayColor.BLACK); PdfPCell rollno = new PdfPCell(new Phrase("Roll No# " + String.valueOf("123456"), fsmall)); PdfPCell cname = new PdfPCell(new Phrase("Name #" + String.valueOf("John Doe"), fsmall)); // DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); // String today = formatter.format(cInfo.getDob()); PdfPCell dob = new PdfPCell(new Phrase("DOB#" + String.valueOf("12-03-1989"), fsmall)); PdfPCell fname = new PdfPCell(new Phrase("F/H Name #" + String.valueOf("Big John"), fsmall)); PdfPCell type = new PdfPCell(new Phrase("Total Time #" + String.valueOf("350.00"), fsmall)); // String scrtoday = formatter.format(cInfo.getScreeningdate()); // System.out.println("Today : " + today); PdfPCell scrdate = new PdfPCell(new Phrase("Laps #" + String.valueOf("4"), fsmall)); PdfPCell cell = new PdfPCell(new Phrase(" ", fsmall)); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); rollno.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); dob.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); fname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); type.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); scrdate.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); CandidateTable.addCell(rollno); CandidateTable.addCell(cell); CandidateTable.addCell(cname); CandidateTable.addCell(cell); CandidateTable.addCell(dob); CandidateTable.addCell(cell); PdfPTable CandidateOtherTable = new PdfPTable(columnWidths); CandidateOtherTable.addCell(fname); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(scrdate); CandidateOtherTable.addCell(cell); CandidateOtherTable.addCell(type); CandidateOtherTable.addCell(cell); PdfPCell race_start_time = new PdfPCell(new Phrase("Start Time :XX-XX-XX ", fsmall)); PdfPCell race_end_time = new PdfPCell(new Phrase("End Time :XX-XX-XX", fsmall)); PdfPCell race_total_time = new PdfPCell(new Phrase("Total Time : 350.00 ", fsmall)); race_start_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_end_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); race_total_time.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); PdfPTable CandidateRaceDetails = new PdfPTable(columnWidths); CandidateRaceDetails.addCell(race_start_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_end_time); CandidateRaceDetails.addCell(cell); CandidateRaceDetails.addCell(race_total_time); CandidateRaceDetails.addCell(cell); PdfPTable tablewith3cells = new PdfPTable(3); //1 St Col for Roll No Name and DOB tablewith3cells.addCell(CandidateTable); //2 nd Col for Father Name sCREEning Date Gurkha tablewith3cells.addCell(CandidateOtherTable); //3rd Col for Barcode to be Printed tablewith3cells.addCell(CandidateRaceDetails); // Setting the Width here to 101 tablewith3cells.setWidthPercentage(99); doc.add(tablewith3cells); PdfPTable userArea = new PdfPTable(1); userArea.setWidthPercentage(99); userArea.addCell(" \n \n Congratulations \n \n "); doc.add(userArea); PdfPTable footerCSBC = new PdfPTable(2); footerCSBC.setWidthPercentage(99); PdfPCell height_box = new PdfPCell(new Phrase("Height \n\n\n", f)); height_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_box = new PdfPCell(new Phrase("Chest \n\n\n", f)); chest_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell chest_exp_box = new PdfPCell(new Phrase("Chest Exp \n\n\n", f)); chest_exp_box.setBorder(com.itextpdf.text.Rectangle.BOX); PdfPCell pushup_box = new PdfPCell(new Phrase("Pushup \n\n\n", f)); pushup_box.setBorder(com.itextpdf.text.Rectangle.BOX); //CSignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); // ASignatureBox.setBorder(com.itextpdf.text.Rectangle.BOX); footerCSBC.addCell(height_box); footerCSBC.addCell(chest_box); footerCSBC.addCell(chest_exp_box); footerCSBC.addCell(pushup_box); doc.add(footerCSBC); float[] columnWidths_ForBarcode = { 6, 3 }; PdfPTable terminalinfo = new PdfPTable(columnWidths_ForBarcode); // terminalinfo.setWidthPercentage(99); String computername = InetAddress.getLocalHost().getHostName(); System.out.println(computername); PdfPCell pcname = new PdfPCell(new Phrase("\t Jacket \n\n ", f)); String UserMatchScore = "\t Barcode\n\n"; PdfPCell score = new PdfPCell(new Phrase(UserMatchScore, f)); PdfPCell barcode = new PdfPCell(carcode2); PdfPCell jacketnumber = new PdfPCell(carcode); pcname.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); score.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); barcode.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); jacketnumber.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); terminalinfo.addCell(score); terminalinfo.addCell(pcname); terminalinfo.addCell(barcode); terminalinfo.addCell(jacketnumber); doc.add(terminalinfo); PdfPCell eula_notice = new PdfPCell(new Phrase(" ", f)); eula_notice.setBorder(com.itextpdf.text.Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); PdfPTable eula_notice_table = new PdfPTable(1); eula_notice_table.setWidthPercentage(25); eula_notice_table.addCell(eula_notice); doc.add(eula_notice_table); } catch (Exception e) { System.err.println(e.getMessage()); // ConsoleMsg(e.getMessage()); } finally { doc.close(); doc.close(); doc.close(); } //ConsoleMsg("PDF... GENERATED"); return null; // throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } }.execute(); return 0; }
From source file:naprawa.praca.PracaController.java
public void akcjaDrukuj() { mapaUslug = getDaoFactory().getDaoDefect().pobierzUslugi(getConnection(), wybranyDefect); FileOutputStream file = null; File druk = null;/*from ww w.j a va 2s .c o m*/ try { Document document = new Document(PageSize.A5, 0, 0, 0, 0); String userPath = System.getProperty("user.home"); druk = new File(userPath + "/Baks wydruki"); if (!druk.exists()) { druk.mkdirs(); } File wydruk = new File(druk + "/" + wybranyDefect.getInfoNaprawa() + ".pdf"); if (!wydruk.exists()) { try { wydruk.createNewFile(); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } file = new FileOutputStream(wydruk); try { PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(wydruk)); document.open(); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(100); table.setSpacingBefore(0f); table.setSpacingAfter(0f); PdfPTable tableO = new PdfPTable(2); tableO.setWidthPercentage(100); tableO.setSpacingBefore(0f); table.setSpacingAfter(0f); tableO.addCell(getNewCell( "BAK's Machine\nin. Baej Krzciuk\n26-800 Biaobrzegi\nul. Brzechwy 31\ntel. 509-281-487")); Image image = Image.getInstance(getClass().getClassLoader().getResource("baksZ.jpg")); tableO.addCell(image); table.addCell(tableO); PdfPCell cell1 = getNewCell( "Biaobrzegi, dn. " + new SimpleDateFormat("yyyy-MM-dd").format(new Date())); cell1.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell1); table.addCell(addTableCzesc()); table.addCell(addTableCzescService("Materiay", RodzajUslugi.MATERIAL)); table.addCell(addTableCzescService("Naprawa", RodzajUslugi.NAPRAWA)); PdfPTable tablePodsumowanie = new PdfPTable(3); tablePodsumowanie.setWidthPercentage(100); int[] width = { 8, 77, 15 }; tablePodsumowanie.setWidths(width); PdfPCell cell = getNewCell("Podsumowanie"); cell.setColspan(10); cell.setBorder(PdfPCell.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); tablePodsumowanie.addCell(cell); tablePodsumowanie.addCell(getNewCell("1.")); tablePodsumowanie.addCell(getNewCell("Czci")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztCzesciS() + " z")); tablePodsumowanie.addCell(getNewCell("2.")); tablePodsumowanie.addCell(getNewCell("Materiay")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztMaterialyS() + " z")); tablePodsumowanie.addCell(getNewCell("3.")); tablePodsumowanie.addCell(getNewCell("Naprawa")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztNaprawyS() + " z")); tablePodsumowanie.addCell(getNewCell("")); tablePodsumowanie.addCell(getNewCell("RAZEM")); tablePodsumowanie.addCell(getNewCell(wybranyDefect.getKosztSumaS() + " z")); table.addCell(tablePodsumowanie); document.add(table); document.close(); writer.close(); } catch (Exception e) { e.printStackTrace(); } } catch (FileNotFoundException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); BaksSessionBean.getInstance().fireMessage(widok, "Wydruk", "Pdf do ktrego chcesz zapisa wynik jest otwarty!\n Zamknij i sprbuj jeszcze raz."); } finally { try { file.close(); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } Desktop desktop = null; if (Desktop.isDesktopSupported()) { desktop = Desktop.getDesktop(); try { desktop.open(druk); } catch (IOException ex) { Logger.getLogger(WyszukPlatnosciController.class.getName()).log(Level.SEVERE, null, ex); } } BaksSessionBean.getInstance().fireMessage(widok, "Zapis", "Wydruk zapisany w folderze: " + System.getProperty("user.home") + "/Baks wydruki"); }
From source file:org.fhaes.neofhchart.PDFExportOptionsDialog.java
License:Open Source License
/** * Handles when actions are performed on the dialog. *//*www . j a va 2s .c o m*/ @Override public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals("OK")) { // Perform the export operation boolean completedSuccessfully = doExportToPDF(); if (completedSuccessfully) { MainWindow.getInstance().getFeedbackMessagePanel().updateFeedbackMessage(FeedbackMessageType.INFO, FeedbackDisplayProtocol.AUTO_HIDE, FeedbackDictionary.NEOFHCHART_PDF_EXPORT_MESSAGE.toString()); } else { MainWindow.getInstance().getFeedbackMessagePanel().updateFeedbackMessage(FeedbackMessageType.ERROR, FeedbackDisplayProtocol.MANUAL_HIDE, "An error occured while attempting to export chart as PDF."); } this.dispose(); } else if (evt.getActionCommand().equals("Cancel")) { // Close the dialog this.dispose(); } else if (evt.getActionCommand().equals("PaperSize")) { // Update the paper size label if (this.cboPaperSize.getSelectedItem() instanceof Rectangle) { Object value = this.cboPaperSize.getSelectedItem(); if (value.equals(PageSize.A5)) { this.lblSize.setText("148 x 210mm / 5.83 x 8.27\""); } else if (value.equals(PageSize.A4)) { this.lblSize.setText("210 x 297mm / 8.27 x 11.7\""); } else if (value.equals(PageSize.A3)) { this.lblSize.setText("297 x 420mm / 11.7 x 16.5\""); } else if (value.equals(PageSize.A2)) { this.lblSize.setText("420 x 594mm / 16.5 x 23.4\""); } else if (value.equals(PageSize.A1)) { this.lblSize.setText("594 x 841mm / 23.4 x 33.1\""); } else if (value.equals(PageSize.A0)) { this.lblSize.setText("841 x 1189mm / 33.1 x 46.8\""); } else if (value.equals(PageSize.LETTER)) { this.lblSize.setText("215.9 x 279.4mm / 8.5 x 11\""); } else if (value.equals(PageSize.LEGAL)) { this.lblSize.setText("215.9 x 355.6mm / 8.5 x 14\""); } else if (value.equals(PageSize.EXECUTIVE)) { this.lblSize.setText("184 x 267mm / 7.25 x 10.5\""); } else { this.lblSize.setText(""); } radLandscape.setEnabled(true); radPortrait.setEnabled(true); } else { this.lblSize.setText(""); radLandscape.setEnabled(false); radPortrait.setEnabled(false); } } }
From source file:org.gephi.ui.exporter.preview.UIExporterPDFPanel.java
License:Open Source License
public UIExporterPDFPanel() { initComponents();//from w w w .jav a 2s . c om sizeFormatter = NumberFormat.getNumberInstance(); sizeFormatter.setMaximumFractionDigits(3); marginFormatter = NumberFormat.getNumberInstance(); marginFormatter.setMaximumFractionDigits(1); //Page size model - http://en.wikipedia.org/wiki/Paper_size DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel(); comboBoxModel.addElement(new PageSizeItem(PageSize.A0, "A0", 841, 1189, 33.1, 46.8)); comboBoxModel.addElement(new PageSizeItem(PageSize.A1, "A1", 594, 841, 23.4, 33.1)); comboBoxModel.addElement(new PageSizeItem(PageSize.A2, "A2", 420, 594, 16.5, 23.4)); comboBoxModel.addElement(new PageSizeItem(PageSize.A3, "A3", 297, 420, 11.7, 16.5)); comboBoxModel.addElement(new PageSizeItem(PageSize.A4, "A4", 210, 297, 8.3, 11.7)); comboBoxModel.addElement(new PageSizeItem(PageSize.A5, "A5", 148, 210, 5.8, 8.3)); comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_A, "ARCH A", 229, 305, 9, 12)); comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_B, "ARCH B", 305, 457, 12, 18)); comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_C, "ARCH C", 457, 610, 18, 24)); comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_D, "ARCH D", 610, 914, 24, 36)); comboBoxModel.addElement(new PageSizeItem(PageSize.ARCH_E, "ARCH E", 914, 1219, 36, 48)); comboBoxModel.addElement(new PageSizeItem(PageSize.B0, "B0", 1000, 1414, 39.4, 55.7)); comboBoxModel.addElement(new PageSizeItem(PageSize.B1, "B1", 707, 1000, 27.8, 39.4)); comboBoxModel.addElement(new PageSizeItem(PageSize.B2, "B2", 500, 707, 19.7, 27.8)); comboBoxModel.addElement(new PageSizeItem(PageSize.B3, "B3", 353, 500, 13.9, 19.7)); comboBoxModel.addElement(new PageSizeItem(PageSize.B4, "B4", 250, 353, 9.8, 13.9)); comboBoxModel.addElement(new PageSizeItem(PageSize.B5, "B5", 176, 250, 6.9, 9.8)); comboBoxModel.addElement(new PageSizeItem(PageSize.LEDGER, "Ledger", 432, 279, 17, 11)); comboBoxModel.addElement(new PageSizeItem(PageSize.LEGAL, "Legal", 216, 356, 8.5, 14)); comboBoxModel.addElement(new PageSizeItem(PageSize.LETTER, "Letter", 216, 279, 8.5, 11)); comboBoxModel.addElement(new PageSizeItem(PageSize.TABLOID, "Tabloid", 279, 432, 11, 17)); customSizeString = NbBundle.getMessage(UIExporterPDFPanel.class, "UIExporterPDFPanel.pageSize.custom"); comboBoxModel.addElement(customSizeString); pageSizeCombo.setModel(comboBoxModel); loadPreferences(); initEvents(); refreshUnit(false); }
From source file:Screens.Print.java
public void ConvertPDF() throws DocumentException, FileNotFoundException, UnsupportedEncodingException, IOException, ParserConfigurationException, SAXException { FontFactory.register("tahoma.ttf", "MY_FONT"); Document document = new Document(PageSize.A5, 20, 20, 10, 10); Image image = Image.getInstance("123.jpg"); PdfPTable table = new PdfPTable(2); table.getDefaultCell().setBorder(0); // table.setBorderColor(BaseColor.WHITE); PdfPTable tablefooter = new PdfPTable(3); tablefooter.getDefaultCell().setBorder(0); try {/* w ww. j a v a 2 s . c o m*/ PdfWriter.getInstance(document, new FileOutputStream(RESULT)); document.open(); image.setAbsolutePosition(350f, 520f); document.add(image); document.add(new Paragraph("\n\n Telefon: " + PrintTel + "\n\n\n", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell( new Paragraph("Ad, Soyad, ID kod", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph(DataPrint.Ad + " " + DataPrint.Soyad + " (#" + DataPrint.idDaxilOlan + ")", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph("Model, Marka", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph(DataPrint.Model + " " + DataPrint.Marka, FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph("Aksesuar", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell( new Paragraph(DataPrint.Aksesuar, FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph("Problem", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell( new Paragraph(DataPrint.Problem, FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph("Tarix", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell( new Paragraph(DataPrint.DatePlan, FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell(new Paragraph("Telefon", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); table.addCell( new Paragraph(DataPrint.Telefon, FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); document.add(table); document.add( new Paragraph(jEditorPane1.getText(), FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); // document.add(new Paragraph(footer, FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); tablefooter.addCell( new Paragraph("Thvil Verdi:", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); tablefooter.addCell(new Paragraph("" + DataPrint.Ad + " " + DataPrint.Soyad + "", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); tablefooter.addCell( new Paragraph("_____________", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 12))); tablefooter.addCell(new Paragraph(" ", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 12))); tablefooter.addCell(new Paragraph(" ", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 12))); tablefooter.addCell(new Paragraph(" ", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 12))); tablefooter.addCell( new Paragraph("Thvil ald:", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); tablefooter.addCell( new Paragraph("Elxan ?sgrli", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 10))); tablefooter.addCell( new Paragraph("_____________", FontFactory.getFont("MY_FONT", BaseFont.IDENTITY_H, 12))); document.add(tablefooter); } catch (FileNotFoundException | DocumentException e) { } document.close(); }