List of usage examples for com.itextpdf.text Paragraph Paragraph
public Paragraph()
Paragraph
. From source file:bl.pdf.PDFFile.java
@SuppressWarnings("unused") private void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);/*from w ww.j a va 2 s . c o m*/ // Lets write a big header preface.add(new Paragraph("Title of the document", catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 3); preface.add(new Paragraph("This document describes something which is very important ", smallBold)); addEmptyLine(preface, 8); preface.add(new Paragraph( "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).", redFont)); document.add(preface); // Start a new page document.newPage(); }
From source file:bookshopautomationsoftware.GenerateReceipt.java
private static void addTitlePage(Document document) throws DocumentException { preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);//from w w w . j a v a 2 s . com // Lets write a big header preface.add(new Paragraph(" RECEIPT ", catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Report generated by: BAS , " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 1); preface.add(new Paragraph("Please keep the bill safe for future advantages ", smallBold)); //addEmptyLine(preface, 8); // preface.add(new Paragraph("This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).", // redFont)); // document.add(preface); // Start a new page // document.newPage(); }
From source file:Boss.BOss.java
private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked if (evt.getClickCount() == 2) { try {//from ww w .j a v a2s . com connect = new Connection(); Statement st = connect.con.createStatement(); String SQL = "SELECT * FROM request where idrequest =" + getSelectedrequest1(); ResultSet rq = st.executeQuery(SQL); rq.next(); /*****************************/ String type = ""; if (parseInt(rq.getString("id_type")) == 1) { type = "Instalation"; } if (parseInt(rq.getString("id_type")) == 2) { type = "Transfer"; } if (parseInt(rq.getString("id_type")) == 3) { type = "Maintenamce"; } /**************************/ Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream("report.pdf")); document.open(); Paragraph paragraph = new Paragraph(); paragraph.add(new Paragraph("Request : \n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY))); paragraph.add("ID Request :"); paragraph.add(rq.getString("idRequest") + ""); paragraph.add("\nRequest type :"); paragraph.add(type); paragraph.add("\nClient name :"); paragraph.add(rq.getString("clientName")); paragraph.add("\nPhone number :"); paragraph.add(rq.getString("TELCLIENT")); paragraph.add("\nAddress 1 :"); paragraph.add(rq.getString("address1")); paragraph.add("\nAddress 2 :"); paragraph.add(rq.getString("address2")); paragraph.add("\nTeam :"); paragraph.add(rq.getString("IDTEAM") + "\n"); /***********************/ String sql = "Select * from report where IDREQUEST = '" + getSelectedrequest1() + "' "; ResultSet rs = st.executeQuery(sql); rs.next(); /**********************/ paragraph.add(new Paragraph("Report : \n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.DARK_GRAY))); paragraph.add(rs.getString("REPORT") + "\n"); Paragraph date = new Paragraph(rs.getString("REPORTDATE").toString().substring(0, 10)); date.setAlignment(Element.ALIGN_RIGHT); Paragraph title = new Paragraph("Report\n", FontFactory.getFont(FontFactory.COURIER_BOLD, 20, Font.BOLD, BaseColor.BLACK)); title.setAlignment(Element.ALIGN_CENTER); document.add(date); document.add(title); document.add(paragraph); document.close(); /* Open Pdf */ Desktop desktop = Desktop.getDesktop(); if (desktop.isSupported(Desktop.Action.OPEN)) { desktop.open(new File("report.pdf")); } else { System.out.println("Open is not supported"); } } catch (SQLException | ClassNotFoundException | DocumentException ex) { Logger.getLogger(BOss.class.getName()).log(Level.SEVERE, null, ex); } catch (FileNotFoundException ex) { Logger.getLogger(BOss.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(BOss.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:br.com.treg.utils.GeneratorPDF.java
public GeneratorPDF(String valorExtenso, ObraFuncionario of, double valor) { //criao do documento Document document = new Document(); try {/*from ww w . j a v a2 s .com*/ PdfWriter.getInstance(document, new FileOutputStream("C:\\Users\\Gustavo\\Desktop\\Recibo.pdf")); document.open(); Paragraph preface = new Paragraph(); addEmptyLine(preface, 1); preface.add(new Paragraph("RECIBO", catFont)); addEmptyLine(preface, 1); preface.add(new Paragraph("Valor: R$ " + valor)); addEmptyLine(preface, 3); preface.add(new Paragraph("Recebi da empresa TR&G ")); addEmptyLine(preface, 1); preface.add(new Paragraph("A importncia de " + valorExtenso)); addEmptyLine(preface, 1); preface.add( new Paragraph("referente a servios prestados de " + of.getFuncionario().getFuncao() + ".")); addEmptyLine(preface, 4); Calendar data = Calendar.getInstance(); String mes = NomeDoMes(data.get(Calendar.MONTH), 0); int ds = data.get(Calendar.DAY_OF_WEEK); preface.add(new Paragraph("Campo Grande, " + data.get(Calendar.DATE) + " de " + mes + " de " + data.get(Calendar.YEAR) + " (" + DiaDaSemana(ds, 1) + ").")); addEmptyLine(preface, 1); preface.add(new Paragraph("Funcionrio: " + of.getFuncionario().getNome() + " - CPF/RG: " + of.getFuncionario().getCpf())); addEmptyLine(preface, 1); preface.add(new Paragraph("Endereo: " + of.getFuncionario().getEndereco())); addEmptyLine(preface, 1); preface.add(new Paragraph("Assinatura: _____________________________")); document.add(preface); } catch (DocumentException | IOException de) { System.err.println(de.getMessage()); } document.close(); }
From source file:bsf.conn.DBMS.java
private static void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);/*from ww w. j av a 2s .c om*/ // Lets write a big header catFont.setColor(BaseColor.BLUE); preface.add(new Paragraph("BSF DATABASE", catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph( "Report generated by: " + System.getProperty("user.name") + ", " + new java.util.Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ smallBold)); addEmptyLine(preface, 3); preface.add(new Paragraph("This document gives Database of BSF ", smallBold)); addEmptyLine(preface, 20); preface.add(new Paragraph("@copyright BSF", redFont)); document.add(preface); // Start a new page document.newPage(); }
From source file:by.bsuir.group172301.matskevich.tour.util.PDFCreator.java
public static void writeChartToPDF(JFreeChart chart, int width, int height, String fileName, int col1, int col2, double perc) { PdfWriter writer = null;// ww w .j a v a2 s. c o m Document document = new Document(); try { writer = PdfWriter.getInstance(document, new FileOutputStream(fileName)); document.open(); Paragraph paragraph = new Paragraph(); // We add one empty line paragraph = new Paragraph("Results:"); paragraph.setAlignment(Element.ALIGN_CENTER); document.add(paragraph); paragraph = new Paragraph("Test before: " + col1); document.add(paragraph); paragraph = new Paragraph("Test after: " + col2); document.add(paragraph); paragraph = new Paragraph("Percentage: " + perc); document.add(paragraph); PdfContentByte contentByte = writer.getDirectContent(); PdfTemplate template = contentByte.createTemplate(width, height); Graphics2D graphics2d = template.createGraphics(width, height, new DefaultFontMapper()); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, width, height); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 150, 250); } catch (Exception e) { e.printStackTrace(); } document.close(); }
From source file:ch.java_akademie.pdf.FirstPdf.java
private static void addTitlePage(Document document) throws DocumentException { Paragraph preface = new Paragraph(); // We add one empty line addEmptyLine(preface, 1);//from w ww . j a v a 2s . c o m // Lets write a big header preface.add(new Paragraph("Title of the document", catFont)); addEmptyLine(preface, 1); // Will create: Report generated by: _name, _date preface.add(new Paragraph("Report generated by: " //$NON-NLS-1$ + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ smallBold)); addEmptyLine(preface, 3); preface.add(new Paragraph("This document describes something which is very important ", smallBold)); addEmptyLine(preface, 8); preface.add(new Paragraph( "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).", redFont)); document.add(preface); // Start a new page document.newPage(); }
From source file:ci_eletronico.FXMLMainController.java
@FXML private void handleBtnImprimirCI(ActionEvent event) throws IOException { if (null == TbViewGeral.getSelectionModel().getSelectedItem()) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("Erro"); alert.setHeaderText("CI no foi selecionada."); alert.setContentText("Favor selecionar uma CI da tabela"); alert.showAndWait();/* w ww. j av a2 s . c o m*/ } else { File outfile = null; // variavel para abrir documento pdf aps sua criao String strFileName = this.lblNumeroSequencialCI.getText(); String strUserHome = System.getProperty("user.home") + "\\Downloads\\" + strFileName + ".pdf"; final Document document = new Document(); try { document.setPageSize(PageSize.A4); document.setMargins(10f, 10f, 70f, 40f); String strCIAssinatura = TbViewGeral.getSelectionModel().getSelectedItem().getStrp_CoinAssinatura(); //PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("c:/Temp/teste.pdf")); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(strUserHome)); MyFooter evento = new MyFooter(strCIAssinatura); writer.setPageEvent(evento); } catch (IOException | DocumentException e) { System.out.println(e.toString()); System.out.println(e.getMessage()); } document.open(); //String htmlString = htmlEditorCI.getHtmlText(); String strlCITitulo = ""; strlCITitulo = "<br /><p align=\"center\"><b>" + strFileName + "</b></p>"; String htmlString = TbViewGeral.getSelectionModel().getSelectedItem().getStrp_Conteudo(); //String strCIAssinatura = TbViewGeral.getSelectionModel().getSelectedItem().getStrp_CoinAssinatura(); // htmlString = htmlString.replace("<br>", "\n"); // htmlString = htmlString.replace("<br/>", "\n"); // htmlString = htmlString.replace("<br />", "\n"); htmlString = htmlString.replace("<br>", "<br />"); // htmlString = htmlString.replace("<hr>", "<p></p>"); // htmlString = htmlString.replace("<hr/>", "<p></p>"); // htmlString = htmlString.replace("<hr />", "<p></p>"); htmlString = htmlString.replace("<hr>", "<hr />"); htmlString = strlCITitulo.concat(htmlString); StringReader in = new StringReader(htmlString); try { final Paragraph test = new Paragraph(); XMLWorkerHelper.getInstance().parseXHtml(new ElementHandler() { @Override public void add(final Writable w) { if (w instanceof WritableElement) { List<Element> elements = ((WritableElement) w).elements(); for (Element e : elements) { test.add(e); } } } }, in); document.add(test); } catch (IOException | DocumentException e) { System.out.println(e.toString()); System.out.println(e.getMessage()); } document.close(); outfile = new File(strUserHome); // Alert alert = new Alert(Alert.AlertType.INFORMATION); // alert.setTitle("Informao"); // alert.setHeaderText("Imprimir CI: " + strFileName ); // alert.setContentText("Arquivo pdf criado com sucesso na pasta Downloads"); // alert.showAndWait(); openArquivo(outfile); // Abrimos o pdf criado para ser visualizado } }
From source file:Clases.NuevoPdf.java
public static void main() { try {/* w w w . j av a 2 s. com*/ /*Espaciador*/ Paragraph espaciador = new Paragraph(); addEmptyLine(espaciador, 2); /** * */ Document document = new Document(); if (Variables.guardar == false) { PdfWriter.getInstance(document, new FileOutputStream(FILE)); } else { JFileChooser dig = new JFileChooser(); int opcion = dig.showSaveDialog(null); if (opcion == JFileChooser.APPROVE_OPTION) { File f = dig.getSelectedFile(); String Direccion = f.toString(); FileOutputStream archivo = new FileOutputStream(Direccion + ".pdf"); PdfWriter.getInstance(document, archivo); Variables.guardar = false; } } //Document document = new Document(); // PdfWriter.getInstance(document, new FileOutputStream(FILE)); document.open(); addMetaData(document); addTitlePage(document); document.add(espaciador); addTableClienteYFactura(document); document.add(espaciador); addTableProducts(document); document.add(espaciador); addTableTotales(document); addFooter(document); document.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Clases.NuevoPdf.java
private static void addTitlePage(Document document) throws DocumentException, IOException { Paragraph encabezado = new Paragraph(); Paragraph empresa = new Paragraph("REFACCIONARIA AUTOMOTRIZ ANCONA S.A de C.V", smallBold); Paragraph direccion = new Paragraph( "AV. PUERTO JUAREZ, LTE. 29 MZA. 1, REG. 92, CANCUN MPIO BENITO JUAREZ Q.ROO C.P 77516", small); Paragraph telefono = new Paragraph("TELS: (998) 888-60-69", small); Paragraph rfc = new Paragraph("RAA020304893", small); Paragraph reg = new Paragraph("REGIMEN GENERAL DE LEY PERSONAS MORALES", small); encabezado.setAlignment(Element.ALIGN_CENTER); empresa.setAlignment(Element.ALIGN_CENTER); direccion.setAlignment(Element.ALIGN_CENTER); telefono.setAlignment(Element.ALIGN_CENTER); rfc.setAlignment(Element.ALIGN_CENTER); reg.setAlignment(Element.ALIGN_CENTER); Paragraph[] arregloParrafos = { empresa, direccion, telefono, rfc, reg }; tableDatosEncabezado(arregloParrafos, document); }