List of usage examples for com.itextpdf.text FontFactory TIMES_ROMAN
String TIMES_ROMAN
To view the source code for com.itextpdf.text FontFactory TIMES_ROMAN.
Click Source Link
From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java
public void reporteRH(Map<String, Object> model, HttpServletResponse hsr1, int detalle) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();//from w w w.ja v a 2 s. com document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30); font1.setColor(BaseColor.BLACK); Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24); font2.setColor(BaseColor.BLACK); document.add(new Paragraph("TAILS 2015", font1)); document.add(new Paragraph("Reportes Direccin\n", font2)); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Recursos Humanos"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF TextoPdf x = (TextoPdf) model.get("todoTexto"); document.add(new Paragraph(x.getTodoTexto())); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 2.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Total de de Empleados en Vacaciones", font)); table.addCell(cell); String bla = detalle + " "; table.addCell(bla); document.add(table); //-------------------------- FIN CONTENIDO ----------------- document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.sapito.pdf.PDFView.PDFGeneratorDireccion.java
public void reportefinanzas(Map<String, Object> model, HttpServletResponse hsr1, List<CuentaBancaria> cuenta) throws Exception { Document document = new Document(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); PdfWriter.getInstance(document, baos); document.open();/*from w w w. j av a2 s .c o m*/ document.addTitle("Sapito PDFs"); document.addSubject("Pdf de sapito"); Font font1 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 30); font1.setColor(BaseColor.BLACK); Font font2 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 24); font2.setColor(BaseColor.BLACK); document.add(new Paragraph("TAILS 2015", font1)); document.add(new Paragraph("Reportes Direccin\n", font2)); //------------------------ TAIS ______________________________ Image tais = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/tais-banner.jpg")); document.add(tais); //--------------------- BODY --------------------------------------------------------- Image body = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/body.png")); body.setAlignment(Image.UNDERLYING); body.setTransparency(new int[] { 0x00, 0x10 }); body.setAbsolutePosition(50, 250); document.add(body); //------------------------------------------------------------------------------------------- Image footer = Image.getInstance(new URL("http://localhost:8080/SAPITO/resources/img/footer.jpg")); footer.setAbsolutePosition(50, 20); document.add(footer); //---------------------- TITLE --------------------------- String titulo = "Reporte de Finanzas"; //Cambiar el titulo del PDF aqui Font f = new Font(FontFamily.HELVETICA, 25.0f, Font.BOLD, BaseColor.BLACK); Chunk c = new Chunk(titulo + " \n ", f); c.setBackground(BaseColor.WHITE); Paragraph title = new Paragraph(c); title.setAlignment(Element.ALIGN_CENTER); //------------------------- CONTENIDO ------------------------------------------------------- document.add(title); //Titulo del PDF TextoPdf x = (TextoPdf) model.get("todoTexto"); document.add(new Paragraph(x.getTodoTexto())); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 2.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.COURIER_BOLD); font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); cell.setBackgroundColor(BaseColor.BLUE); cell.setPadding(5); // write table header cell.setPhrase(new Phrase("Total de dinero que se tiene en CUENTAS BANCARIAS", font)); table.addCell(cell); for (int i = 0; i < cuenta.size(); i++) { a = cuenta.get(i).getHaber(); b = b + a; } String bla = b + " "; table.addCell(bla); document.add(table); //-------------------------- FIN CONTENIDO ----------------- document.close(); byte[] bytes = baos.toByteArray(); hsr1.setContentType("application/pdf"); hsr1.setContentLength(bytes.length); hsr1.getOutputStream().write(bytes); }
From source file:com.shiyq.itext.PdfUtil.java
public static FontSelector getSelector(int fontsize) { FontSelector selector = new FontSelector(); selector.addFont(FontFactory.getFont(FontFactory.TIMES_ROMAN, fontsize)); selector.addFont(FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED, fontsize)); return selector; }
From source file:com.timesheet.export.PdfGenerator.java
@Override protected void buildPdfDocument(Map<String, Object> model, Document document, PdfWriter writer, HttpServletRequest request, HttpServletResponse response) throws Exception { /* Add header*/ Font fontHeader = FontFactory.getFont(FontFactory.TIMES_ROMAN, 22, Font.BOLD); Paragraph headerPara = new Paragraph("Time sheet report", fontHeader); headerPara.setSpacingAfter(20f);/*from ww w. j a v a 2 s .c o m*/ document.add(headerPara); /*Add user info*/ User userProfile = (User) model.get("userprofile"); Font fontUserInfo = FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD); document.add(new Paragraph("Name : " + userProfile.getName(), fontUserInfo)); document.add(new Paragraph("User no. : " + userProfile.getUserIdentifier(), fontUserInfo)); document.add(new Paragraph("Department : " + userProfile.getDepartment(), fontUserInfo)); document.add(new Paragraph("Email : " + userProfile.getEmail(), fontUserInfo)); Paragraph spacing = new Paragraph(""); spacing.setSpacingAfter(20f); document.add(spacing); PdfPTable table = new PdfPTable(5); table.setWidthPercentage(100.0f); table.setWidths(new float[] { 5.0f, 3.0f, 3.0f, 3.0f, 10.0f }); table.setSpacingBefore(10); // define font for table header row Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD); //font.setColor(BaseColor.WHITE); // define table header cell PdfPCell cell = new PdfPCell(); //cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPadding(5); cell.setBorderWidth(2.0f); cell.setBorder(Rectangle.BOTTOM); // get data model which is passed by the Spring container List<Booking> bookings = (List<Booking>) model.get("bookings"); // write table header cell.setPhrase(new Phrase("Project", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Option", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Date", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Duration", font)); table.addCell(cell); // write table header cell.setPhrase(new Phrase("Description", font)); table.addCell(cell); int sum = 0; Font fontData = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11); for (Booking booking : bookings) { PdfPCell cell1 = new PdfPCell(new Phrase( booking.getProject().getProjectId() + "-" + booking.getProject().getName(), fontData)); cell1.setBorder(Rectangle.BOTTOM); cell1.setPadding(5); table.addCell(cell1); PdfPCell cell2 = new PdfPCell(new Phrase(booking.getBookingOption().getOptionLabel(), fontData)); cell2.setBorder(Rectangle.BOTTOM); cell2.setPadding(5); table.addCell(cell2); PdfPCell cell3 = new PdfPCell(new Phrase(formatDate(booking.getBookingDate()), fontData)); cell3.setBorder(Rectangle.BOTTOM); cell3.setPadding(5); table.addCell(cell3); int hh = booking.getDuration() / 60; int mm = booking.getDuration() % 60; PdfPCell cell4 = new PdfPCell(new Phrase(hh + ":" + mm, fontData)); cell4.setBorder(Rectangle.BOTTOM); cell4.setPadding(5); table.addCell(cell4); PdfPCell cell5 = new PdfPCell( new Phrase(StringEscapeUtils.escapeHtml(booking.getDescription()), fontData)); cell5.setBorder(Rectangle.BOTTOM); cell5.setPadding(5); table.addCell(cell5); sum += booking.getDuration(); } document.add(table); int sumHH = sum / 60; int sumMM = sum % 60; document.add(new Paragraph("Sum : " + sumHH + ":" + sumMM, fontUserInfo)); //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. }
From source file:direccion.GeneradorFormato.java
@Override public void onEndPage(PdfWriter writer, Document document) { Rectangle rect = writer.getBoxSize("art"); Image imghead = null;/*w w w.j a va 2s . c o m*/ PdfContentByte cbhead = null; // try { // imghead = Image.getInstance("LogoSapito5.png"); // imghead.setAbsolutePosition(0, 0); // imghead.setAlignment(Image.ALIGN_CENTER); // imghead.scalePercent(10f); // cbhead = writer.getDirectContent(); // PdfTemplate tp = cbhead.createTemplate(100, 150); // tp.addImage(imghead); // cbhead.addTemplate(tp, 100, 715); // } catch (BadElementException e) { // e.printStackTrace(); // } catch (IOException e) { // e.printStackTrace(); // } catch (DocumentException e) { // e.printStackTrace(); // } Phrase headPhraseImg = new Phrase(cbhead + "", FontFactory.getFont(FontFactory.TIMES_ROMAN, 7, Font.NORMAL)); Calendar c1 = Calendar.getInstance(); Calendar c2 = new GregorianCalendar(); String dia, mes, annio; dia = Integer.toString(c1.get(Calendar.DATE)); mes = Integer.toString(c1.get(Calendar.MONTH)); annio = Integer.toString(c1.get(Calendar.YEAR)); Date fecha = new Date(); String fechis = dia + "/" + mes + "/" + annio; Paragraph parrafo5 = new Paragraph(fechis, FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo5), rect.getRight(450), rect.getTop(-80), 0); Paragraph parrafo7 = new Paragraph("Empresa Sapito S.A. de C.V.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 16, Font.BOLD, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo7), rect.getBottom(250), rect.getTop(-60), 0); Paragraph parrafo8 = new Paragraph("Reporte algoooooo", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.BOLD, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo8), rect.getBottom(250), rect.getTop(-40), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(650), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(-24), 0); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_BOTTOM, new Phrase( " _____________________________________________________________________________________ "), rect.getBorder(), rect.getTop(-20), 0); Paragraph parrafo6 = new Paragraph(String.format("Pg %d", writer.getPageNumber()), FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.NORMAL, BaseColor.BLACK)); ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, new Phrase(parrafo6), rect.getRight(-35), rect.getTop(-80), 0); }
From source file:direccion.GeneradorFormato.java
public static void main(String[] args) { try {// w ww. j a v a 2 s. c o m Document document = new Document(PageSize.LETTER, 50, 50, 85, 50); document.addAuthor("Direccin"); document.addTitle("Reporte de algo"); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Reporte prueba.pdf")); writer.setInitialLeading(16); Rectangle rct = new Rectangle(80, 104, 500, 688); writer.setBoxSize("art", rct); GeneradorFormato event = new GeneradorFormato(); writer.setPageEvent(event); document.open(); Paragraph parrafo2 = new Paragraph( "De aqui en adelante el contenido, ya se pone en automatico el encabezado en cada pgina y el nmero", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.RED)); parrafo2.setAlignment(0); document.add(parrafo2); document.add(Chunk.NEWLINE); document.close(); } catch (FileNotFoundException | DocumentException ex) { System.out.println(ex.getMessage()); } }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
public PDFDocument(String authorName, Map<String, Integer> yearToPublicationCount, Document document, PdfWriter pdfWriter) {/*from w w w.ja v a 2 s .com*/ // setPreferredSize(new Dimension(600,400)); try { document.addTitle("PDF Pipeline iText Prototype"); document.addAuthor(authorName); document.addSubject("This example tests text, color, image, transparency & table functionality."); document.addKeywords("text, color, image, transparency, table"); document.addCreator("Standalone PDF Renderer using iText"); Paragraph header = new Paragraph(); Font pageHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 15, Font.BOLDITALIC | Font.UNDERLINE); Font featureHeaderStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 10, new BaseColor(Color.red)); header.add(new Chunk("PDF Pipeline Prototype v2 using iText\n", pageHeaderStyle)); header.setSpacingAfter(15f); document.add(header); Paragraph content = new Paragraph(); content.add(new Chunk("Publication Count - Author Name - " + authorName, featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); // step4 PdfPTable publicationCount = createTable(yearToPublicationCount); document.add(publicationCount); content = new Paragraph(); content.add(new Chunk("Transparency of Shapes", featureHeaderStyle)); content.setSpacingAfter(15f); document.add(content); createTransparencyShapes(document, pdfWriter); createImage(document, pdfWriter, featureHeaderStyle); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private void createImage(Document document, PdfWriter writer, Font featureHeaderStyle) throws BadElementException, MalformedURLException, IOException, DocumentException { Image imageSprite = Image.getInstance(new URL( "http://lh3.ggpht.com/_4msVPAgKJv8/SCRYD-pPVKI/AAAAAAAAAYU/zUN963EPoZc/s1024/102_0609.JPG")); imageSprite.setAbsolutePosition(400, 500); imageSprite.scaleAbsolute(171.0f, 250.0f); float imageSpriteY = document.getPageSize().getHeight() * 0.60f; float imageSpriteX = document.getPageSize().getWidth() * 0.65f; imageSprite.setAlignment(Image.UNDERLYING); document.add(imageSprite);//w ww. ja v a 2s . co m PdfContentByte cb = writer.getDirectContent(); ColumnText ct = new ColumnText(cb); Chunk imageHeader = new Chunk("Images", featureHeaderStyle); ct.addText(imageHeader); ct.setAlignment(Element.ALIGN_LEFT); ct.setSimpleColumn(imageSpriteX, imageSpriteY - imageSprite.getScaledHeight(), imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY + imageSprite.getScaledHeight() + 20); ct.go(); ct = new ColumnText(cb); Chunk imageFooter = new Chunk("Footer to be set for a figure. Similar to 'image cpation'.", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)); ct.addText(imageFooter); ct.setAlignment(Element.ALIGN_CENTER); ct.setSimpleColumn(imageSpriteX, imageSpriteY - 150, imageSpriteX + imageSprite.getScaledWidth(), imageSpriteY); ct.go(); }
From source file:edu.cornell.mannlib.vitro.webapp.visualization.visutils.PDFDocument.java
License:Open Source License
private PdfPTable createTable(Map<String, Integer> yearToPublicationCount) { Font normalContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11); Font summaryContentStyle = FontFactory.getFont(FontFactory.TIMES_ROMAN, 11, Font.BOLDITALIC); BaseColor summaryBackgroundColor = new BaseColor(0xEE, 0xEE, 0xEE); BaseColor headerBackgroundColor = new BaseColor(0xC3, 0xD9, 0xFF); BaseColor bodyBackgroundColor = new BaseColor(Color.white); PdfPTable table = new PdfPTable(2); table.setWidthPercentage(36.0f);/*from w ww .jav a 2 s .c om*/ table.setHorizontalAlignment(Element.ALIGN_LEFT); table.getDefaultCell().setBorderWidth(0.0f); table.setHeaderRows(2); PdfPCell cell; cell = new PdfPCell(new Phrase("Publications per year", normalContentStyle)); setTableCaptionStyle(summaryBackgroundColor, cell); table.addCell(cell); cell = new PdfPCell(new Phrase("Year", normalContentStyle)); setTableHeaderStyle(headerBackgroundColor, cell); table.addCell(cell); cell.setPhrase(new Phrase("Publications", normalContentStyle)); table.addCell(cell); setTableBodyStyle(bodyBackgroundColor, cell); int totalPublications = 0; for (Entry<String, Integer> currentEntry : yearToPublicationCount.entrySet()) { cell.setPhrase(new Phrase(currentEntry.getKey(), normalContentStyle)); table.addCell(cell); cell.setPhrase(new Phrase(currentEntry.getValue().toString(), normalContentStyle)); table.addCell(cell); totalPublications += currentEntry.getValue(); } setTableFooterStyle(summaryBackgroundColor, cell); cell.setPhrase(new Phrase("Total", summaryContentStyle)); table.addCell(cell); cell.setPhrase(new Phrase(String.valueOf(totalPublications), summaryContentStyle)); table.addCell(cell); return table; }
From source file:edu.ksu.cs.a4vm.bse.reporter.Reporter.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) { JFileChooser chooser = new JFileChooser(); int option = chooser.showSaveDialog(null); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { File3 = chooser.getSelectedFile().getAbsolutePath(); }//from w ww . j a v a 2 s. c om try { br1 = new BufferedReader(new FileReader(f)); BufferedReader b1 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } String line = ""; bull1 = new String[number_of_rows - 1][]; int k = 0; BufferedReader br3 = null; try { br3 = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException ex) { } try { while ((line = br3.readLine()) != null) { // use comma as separator String Bull[] = line.split(","); if (k != 0) { System.out.println(Bull.length); bull1[k - 1] = new String[Bull.length]; for (int j = 0; j < Bull.length; j++) { bull1[k - 1][j] = Bull[j]; } } k++; } } catch (IOException ex) { } Document doc = new Document(); PdfWriter docWriter = null; DecimalFormat df = new DecimalFormat("0.00"); try { //special font sizes Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 8, Font.BOLD, new BaseColor(0, 0, 0)); Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 6); Font bfBold20 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD); Font bfBold25 = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD); //file path docWriter = PdfWriter.getInstance(doc, new FileOutputStream(File3)); //document header attributes doc.addAuthor("Shubh Chopra"); doc.addCreationDate(); doc.addProducer(); doc.addCreator("Shubh Chopra"); doc.addTitle("BES"); doc.setPageSize(PageSize.LETTER.rotate()); //open document doc.open(); //create a paragraph Paragraph paragraph = new Paragraph("BULL EVALUATION\n\n"); paragraph.setFont(bfBold25); paragraph.setAlignment(Element.ALIGN_CENTER); Image img = Image.getInstance("VETMED.png"); img.scaleToFit(300f, 150f); doc.add(paragraph); PdfPTable table1 = new PdfPTable(2); table1.setWidthPercentage(100); PdfPCell cell = new PdfPCell(img); cell.setBorder(PdfPCell.NO_BORDER); table1.addCell(cell); String temp1 = "\tOwner: " + bull1[1][62] + " " + bull1[1][63] + "\n\n\tRanch: " + bull1[1][64] + "\n\n\tAddress: " + bull1[1][55] + "\n\n\tCity: " + bull1[1][57] + "\n\n\tState: " + bull1[1][60] + "\tZip: " + bull1[1][61] + "\n\n\tPhone: " + bull1[1][59] + "\n\n"; table1.addCell(getCell(temp1, PdfPCell.ALIGN_LEFT)); doc.add(table1); if (dlm3.size() == 1) { String str; str = dlm3.get(0).toString(); String[] parts = str.split(":"); String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; String[][] temp = new String[25][6]; temp[0][0] = "Tag"; temp[0][1] = bull1[row][7]; temp[0][2] = "Comments"; temp[0][3] = ""; temp[0][4] = "Total Count"; temp[0][5] = ""; temp[1][0] = "Tatoo"; temp[1][1] = bull1[row][8]; temp[1][2] = "All Normal"; temp[1][3] = "Yes"; temp[2][0] = "RFID"; temp[2][1] = bull1[row][6]; temp[2][2] = "Eyes"; temp[2][3] = bull1[row][10]; temp[3][0] = "Lot#"; temp[3][1] = bull1[row][5]; temp[3][2] = "Feet"; temp[3][3] = bull1[row][12]; temp[4][0] = "Brand"; temp[4][1] = bull1[row][2]; temp[4][2] = "Legs"; temp[4][3] = bull1[row][14]; temp[5][0] = "Date of Birth"; temp[5][1] = bull1[row][4]; temp[5][2] = "Testicals"; temp[5][3] = bull1[row][16]; temp[6][0] = "Age"; temp[6][1] = bull1[row][0]; temp[6][2] = "Accessory Sex Glands"; temp[6][3] = bull1[row][18]; temp[7][0] = "Breed"; temp[7][1] = bull1[row][3]; temp[7][2] = "Inguinal"; temp[7][3] = bull1[row][20]; temp[8][0] = "Other"; temp[8][1] = bull1[row][9]; temp[8][2] = "Scrotal"; temp[8][3] = bull1[row][22]; temp[9][0] = "Clinic Info"; temp[9][1] = "xx"; temp[9][2] = "Epidydimides"; temp[9][3] = bull1[row][24]; temp[10][4] = "Measurements"; temp[10][5] = "xx"; temp[10][0] = "Clinic Name"; temp[10][1] = bull1[row][73]; temp[10][2] = "Penis"; temp[10][3] = bull1[row][26]; temp[11][4] = "Scrotal Cirumference"; temp[11][5] = bull1[row][54]; temp[11][0] = "Veterinarian Name"; temp[11][1] = bull1[row][74] + " " + bull1[row][74]; temp[11][2] = "Prepuce"; temp[11][3] = bull1[row][28]; temp[12][4] = "Body Condition"; temp[12][5] = bull1[row][47]; temp[12][0] = "Address"; temp[12][1] = bull1[row][66] + " " + bull1[row][67]; temp[12][2] = "Scrotum"; temp[12][3] = bull1[row][30]; temp[13][4] = "Pelvic X Measure"; temp[13][5] = bull1[row][52]; temp[13][0] = "City"; temp[13][1] = bull1[row][68]; temp[13][2] = "Sex Drive"; temp[13][3] = "xx"; temp[14][4] = "Pelvic Y Measure"; temp[14][5] = bull1[row][53]; temp[14][0] = "State"; temp[14][1] = bull1[row][71]; temp[14][2] = "Breeding seasons used"; temp[14][3] = bull1[row][40]; temp[15][4] = "Hip Hight"; temp[15][5] = bull1[row][50]; temp[15][0] = "Zip Code"; temp[15][1] = bull1[row][72]; temp[15][2] = "Performance last season"; temp[15][3] = bull1[row][38]; temp[16][4] = "Frame Score"; temp[16][5] = bull1[row][49]; temp[16][0] = "Email"; temp[16][1] = bull1[row][69]; temp[16][2] = "Single or Multi sire"; temp[16][3] = bull1[row][41]; temp[17][4] = "Other"; temp[17][5] = bull1[row][48]; temp[17][0] = "Phone"; temp[17][1] = bull1[row][70]; temp[17][2] = "Other"; temp[17][3] = bull1[row][39]; temp[18][4] = "Motility"; temp[18][5] = "xx"; temp[18][0] = "Classification"; temp[18][1] = bull1[row][35]; temp[18][2] = "Comments"; temp[18][3] = bull1[row][37]; temp[19][4] = "Individual Motility"; temp[19][5] = bull1[row][45]; temp[19][0] = "Comments"; temp[19][1] = bull1[row][36]; temp[19][2] = ""; temp[19][3] = ""; temp[20][4] = "Motility %"; temp[20][5] = bull1[row][46]; temp[20][0] = ""; temp[20][1] = ""; temp[20][2] = ""; temp[20][3] = ""; temp[21][4] = "Gross Motility"; temp[21][5] = bull1[row][44]; temp[21][0] = ""; temp[21][1] = ""; temp[21][2] = ""; temp[21][3] = ""; for (int i = 9; i <= 29; i += 2) { if (bull1[row][i].equals("FALSE")) { temp[1][4] = "No"; break; } } int i; int total = 0; for (i = 77; i < header.length && i < bull1[row].length; i++) { temp[i - 76][4] = header[i].split("_")[1]; temp[i - 76][5] = bull1[row][i]; total += Integer.parseInt(bull1[row][i]); } temp[0][5] = Integer.toString(total); for (int j = i; j <= 85; j++) { temp[j - 76][4] = ""; temp[j - 76][5] = ""; } PdfPTable table = new PdfPTable(6); PdfPCell cell11, cell12, cell13; cell11 = new PdfPCell( new Phrase("Bull Info", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell11.setColspan(2); cell11.setHorizontalAlignment(Element.ALIGN_CENTER); cell11.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell11); cell12 = new PdfPCell( new Phrase("Physical Exam", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell12.setColspan(2); cell12.setHorizontalAlignment(Element.ALIGN_CENTER); cell12.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell12); cell13 = new PdfPCell( new Phrase("Morphology", FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell13.setColspan(2); cell13.setHorizontalAlignment(Element.ALIGN_CENTER); cell13.setVerticalAlignment(Element.ALIGN_CENTER); table.addCell(cell13); for (int l = 0; l <= 21; l++) { for (int j = 0; j < 6; j++) { // System.out.println(l+" "+j); if (!temp[l][j].equals("xx") && temp[l][j] != null) { cell = new PdfPCell( new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 10))); cell.setBorder(PdfPCell.NO_BORDER); if ((l == 9 && j == 0) || (l == 13 && j == 2) || (l == 10 && j == 4) || (l == 18 && j == 4)) { cell = new PdfPCell(new Phrase(temp[l][j], FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); cell.setVerticalAlignment(Element.ALIGN_CENTER); cell.setColspan(2); } table.addCell(cell); } } } table.setWidthPercentage(90f); Reporter re; re = new Reporter(); doc.add(table); if (jCheckBox2.isSelected() || jCheckBox1.isSelected()) doc.newPage(); } else { //specify column widths int temp = dlm2.size(); float[] columnWidths = new float[temp]; for (int x = 0; x < columnWidths.length; x++) { columnWidths[x] = 2f; } //create PDF table with the given widths PdfPTable table = new PdfPTable(columnWidths); // set table width a percentage of the page width table.setWidthPercentage(90f); Reporter re; re = new Reporter(); re.insertCell(table, "Bull Info", Element.ALIGN_CENTER, 1, bfBold12); for (int i = 0; i < dlm2.size(); i++) { String[] parts = dlm2.get(i).toString().split(": "); String part2 = parts[1]; re.insertCell(table, newhead[Integer.parseInt(part2)], Element.ALIGN_CENTER, 1, bfBold12); } table.setHeaderRows(1); //insert an empty row //create section heading by cell merging //just some random data to fill for (int x = 0; x < dlm3.size(); x++) { String str = dlm3.get(x).toString(); //System.out.println(str); String[] parts = str.split(":"); String part2 = parts[1]; // System.out.println(part2); int row = Integer.parseInt(part2) - 1; re.insertCell(table, Bulls[row], Element.ALIGN_CENTER, 1, bf12); for (int i = 0; i < dlm2.getSize(); i++) { for (int j = 0; j < header.length && j < bull1[row].length; j++) { String str1 = dlm2.get(i).toString(); String[] p1 = str1.split(": "); String p2 = p1[0]; if (p2.equals(header[j])) { re.insertCell(table, bull1[row][j], Element.ALIGN_CENTER, 1, bf12); } } } // re.insertCell(table, bull1[x][7] , Element.ALIGN_CENTER, 1, bf12); } doc.add(table); } if (jCheckBox2.isSelected()) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); for (int i = 0; i < dlm3.size(); i++) { String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, Part2, part1); } else { dataSet.setValue(0, "Percent", header[j]); } } } JFreeChart chart = ChartFactory.createBarChart("Multi Bull Morphology Chart ", "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, true, true, false); if (dlm3.size() > 12) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); } if (jCheckBox1.isSelected()) { for (int i = 0; i < dlm3.size(); i++) { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String str = dlm3.get(i).toString(); System.out.println(str); String[] parts = str.split(":"); String part1 = parts[0]; String part2 = parts[1]; System.out.println(part2); int row = Integer.parseInt(part2) - 1; float total = (float) 0.0; for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (bull1[row][j].equals("")) { continue; } else { total += Integer.parseInt(bull1[row][j]); } } System.out.println(total); for (int j = 77; j < header.length && j < bull1[row].length; j++) { if (!bull1[row][j].equals("")) { String[] Parts = header[j].split("_"); String Part2 = Parts[1]; dataSet.setValue((Integer.parseInt(bull1[row][j]) * 100) / total, "Percent", Part2); } else { dataSet.setValue(0, "Percent", header[j]); } } JFreeChart chart = ChartFactory.createBarChart("Single Bull Morphology Chart " + part1, "Morphology", "Percent", dataSet, PlotOrientation.VERTICAL, false, true, false); if ((dlm3.size() > 12 && i == 0) || jCheckBox2.isSelected()) { doc.newPage(); } PdfContentByte contentByte = docWriter.getDirectContent(); PdfTemplate template = contentByte.createTemplate(325, 250); PdfGraphics2D graphics2d = new PdfGraphics2D(template, 325, 250); Rectangle2D rectangle2d = new Rectangle2D.Double(0, 0, 325, 250); chart.draw(graphics2d, rectangle2d); graphics2d.dispose(); contentByte.addTemplate(template, 0, 0); doc.newPage(); } } } catch (DocumentException dex) { dex.printStackTrace(); } catch (FileNotFoundException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(ReporterArchive.class.getName()).log(Level.SEVERE, null, ex); } finally { if (doc != null) { //close the document doc.close(); } if (docWriter != null) { //close the writer docWriter.close(); } } } // TODO add your handling code here: }