List of usage examples for com.itextpdf.text Anchor Anchor
public Anchor(final float leading, final String string)
Anchor
with a certain leading and a certain String
. From source file:com.example.drivequickstart.PDFActivity.java
private void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("ESTIMATING APP", catFont); anchor.setName("ESTIMATING APP"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); try {//w w w . j a v a 2 s . com Drawable d = PDFActivity.this.getResources().getDrawable(R.drawable.ic_launcher); Bitmap bitmap = ((BitmapDrawable) d).getBitmap(); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); Image image = Image.getInstance(stream.toByteArray()); subCatPart.add(image); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } // Add a list createList(subCatPart); Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // Add a table createTable(subCatPart); // Now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // Now add all this to the document document.add(catPart); }
From source file:com.ideationdesignservices.txtbook.pdf.TxtBookPdf.java
public Boolean createBackCoverPage(Document document, String backCoverNote) throws DocumentException, MalformedURLException, IOException { document.newPage();/* w ww . j a v a 2s . co m*/ Image backCoverImageFrame = Image .getInstance(ImageUtilities.getImageDataForFile(this.mContext, "pdf/txtbook_backpage_300.png")); backCoverImageFrame.scalePercent(24.0f); backCoverImageFrame.setAbsolutePosition(87.0f, 78.0f); backCoverImageFrame.setCompressionLevel(this.settings.compressionLevel); document.add(backCoverImageFrame); PdfContentByte canvas = this.writer.getDirectContent(); PdfPTable table = new PdfPTable(1); table.setTotalWidth(215.0f); if (backCoverNote != null && backCoverNote.length() > 0) { Paragraph backCoverEl = new Paragraph(backCoverNote, this.serifFont14); PdfPCell cell = new PdfPCell(); cell.setBorder(0); cell.addElement(backCoverEl); cell.setPadding(13.0f); cell.setIndent(0.0f); cell.setFixedHeight(310.0f); table.addCell(cell); table.completeRow(); } Element backUrl = new Anchor("txt-book.com", this.sansFont11Gray); backUrl.setName("txt-book.com"); backUrl.setReference("http://www.txt-book.com"); Paragraph paragraph = new Paragraph(); paragraph.setAlignment(2); paragraph.add(backUrl); PdfPCell cell2 = new PdfPCell(); cell2.setBorder(0); cell2.setHorizontalAlignment(2); cell2.addElement(paragraph); cell2.setPadding(0.0f); cell2.setPaddingTop(0.0f); cell2.setIndent(0.0f); table.addCell(cell2); table.completeRow(); table.writeSelectedRows(0, -1, 306.0f, 400.0f, canvas); return Boolean.valueOf(true); }
From source file:com.imipgroup.hieuvt.pdf.PdfUtils.java
private static void addContent(Document document) { Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // add a list createList(subCatPart);/* ww w .ja v a 2 s . c om*/ Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table createTable(subCatPart); // now add all this to the document try { document.add(catPart); } catch (DocumentException e) { e.printStackTrace(); } // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document try { document.add(catPart); } catch (DocumentException e) { e.printStackTrace(); } }
From source file:com.nlbhub.nlb.domain.export.hypertext.document.PDFAnchor.java
License:Open Source License
public PDFAnchor(boolean decapitalize, String text, PDFFont font) { super(decapitalize, text, font); m_anchor = new Anchor(text, font.getFont()); }
From source file:com.pdg.ticket.utils.FirstPdf.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // Add a list //createList(subCatPart); Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5);/*from w w w. j a v a 2 s . c o m*/ subCatPart.add(paragraph); // Add a table createTable(subCatPart); // Now add all this to the document document.add(catPart); // // Next section // anchor = new Anchor("Second Chapter", catFont); // anchor.setName("Second Chapter"); // // // Second parameter is the number of the chapter // catPart = new Chapter(new Paragraph(anchor), 1); // // subPara = new Paragraph("Subcategory", subFont); // subCatPart = catPart.addSection(subPara); // subCatPart.add(new Paragraph("This is a very important message")); // // // Now add all this to the document // document.add(catPart); }
From source file:com.shashi.itext.write.FirstPdf.java
private static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategory 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategory 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragraph 1")); subCatPart.add(new Paragraph("Paragraph 2")); subCatPart.add(new Paragraph("Paragraph 3")); // Add a list createList(subCatPart);//from w w w . j a v a 2 s . com Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // Add a table createTable(subCatPart); // Now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Second Chapter", catFont); anchor.setName("Second Chapter"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategory", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // Now add all this to the document document.add(catPart); }
From source file:com.util.Imprimir.java
public static void addContent(Document document) throws DocumentException { Anchor anchor = new Anchor("Capitulo Primeiro", catFont); anchor.setName("Capitulo Primeiro"); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), 1); Paragraph subPara = new Paragraph("Subcategoria 1", subFont); Section subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Hello")); subPara = new Paragraph("Subcategoria 2", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("Paragrafo 1")); subCatPart.add(new Paragraph("Paragrafo 2")); subCatPart.add(new Paragraph("Paragrafo 3")); // add a list createList(subCatPart);/*from www. j av a 2 s. c o m*/ Paragraph paragraph = new Paragraph(); addEmptyLine(paragraph, 5); subCatPart.add(paragraph); // add a table createTable(subCatPart); // now add all this to the document document.add(catPart); // Next section anchor = new Anchor("Capitulo Segundo", catFont); anchor.setName("Capitulo Segundo"); // Second parameter is the number of the chapter catPart = new Chapter(new Paragraph(anchor), 1); subPara = new Paragraph("Subcategoria", subFont); subCatPart = catPart.addSection(subPara); subCatPart.add(new Paragraph("This is a very important message")); // now add all this to the document document.add(catPart); }
From source file:com.VanLesh.macsv10.macs.Models.Pdf.java
License:GNU General Public License
private static void addContent(Document doc, Calculation calc) { try {//from w w w. jav a2s . c o m //special font so we can render greek characters BaseFont bfComic = BaseFont.createFont("/system/fonts/DroidSansFallback.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); Font font1 = new Font(bfComic, 12); Font tgfont, tipfont; if (calc.getRollover() > calc.getDrag()) { tipfont = redFont; tgfont = smallBold; } else { tipfont = smallBold; tgfont = redFont; } Anchor anchor = new Anchor("Site", subFont); anchor.setName("Site Parameters"); Paragraph identifier = new Paragraph("Calculation ID: " + calc.getTitle(), font1); Paragraph engineer = new Paragraph("Engineer: " + calc.getEngineerName(), font1); Paragraph jobsite = new Paragraph("Jobsite: " + calc.getJobSite(), font1); Paragraph latitude = new Paragraph("Latitude: " + calc.getLatitude(), font1); Paragraph longitude = new Paragraph("Longitude: " + calc.getLongitude(), font1); Anchor vehicleAnchor = new Anchor("Vehicle", subFont); vehicleAnchor.setName("Vehicle"); Paragraph vehicleclass = new Paragraph("Vehicle Class: " + calc.getVehicle().getVehicleClass(), font1); Paragraph vehicletype = new Paragraph("Vehicle Type: " + calc.getVehicle().getVehicleType(), font1); Paragraph vehicleweight = new Paragraph("Wv: " + calc.getVehicle().getWv(), font1); Paragraph vehicletracklength = new Paragraph("Tl: " + calc.getVehicle().getTrackL(), font1); Paragraph vehicletrackwidth = new Paragraph("Tw: " + calc.getVehicle().getTrackW(), font1); Paragraph vehiclebladewidth = new Paragraph("Wb: " + calc.getVehicle().getBladeW(), font1); Anchor soilAnchor = new Anchor("Soil", subFont); soilAnchor.setName("Soil"); Paragraph soiltype = new Paragraph("Soil Type: " + calc.getSoil().getName(), font1); Paragraph soilunitweight = new Paragraph("\u03B3: " + calc.getSoil().getunitW(), font1); Paragraph soilfrictionangle = new Paragraph("\u03A6: " + calc.getSoil().getfrictA(), font1); Paragraph soilcohesion = new Paragraph("c: " + calc.getSoil().getC(), font1); Anchor measurementsAnchor = new Anchor("Measurements", subFont); anchor.setName("Measurements"); Paragraph beta = new Paragraph("\u03B2: " + calc.getBeta(), font1); Paragraph theta = new Paragraph("\u03B8: " + calc.getTheta(), font1); Paragraph Ha = new Paragraph("Ha: " + calc.getHa(), font1); Paragraph La = new Paragraph("La: " + calc.getLa(), font1); Paragraph Db = new Paragraph("Db: " + calc.getD_b(), font1); Anchor resultsAnchor = new Anchor("Results", subFont); int drag = (int) calc.getDrag(); int roll = (int) calc.getRollover(); Paragraph Tg = new Paragraph("Anchor cap Sliding : " + drag, tgfont); Paragraph tipover = new Paragraph("Anchor cap Overturning: " + roll, tipfont); doc.add(anchor); doc.add(identifier); doc.add(engineer); doc.add(jobsite); doc.add(latitude); doc.add(longitude); doc.add(vehicleAnchor); doc.add(vehicleclass); doc.add(vehicletype); doc.add(vehicleweight); doc.add(vehicletracklength); doc.add(vehicletrackwidth); doc.add(vehiclebladewidth); doc.add(soilAnchor); doc.add(soiltype); doc.add(soilunitweight); doc.add(soilfrictionangle); doc.add(soilcohesion); doc.add(measurementsAnchor); doc.add(beta); doc.add(theta); doc.add(Ha); doc.add(La); doc.add(Db); doc.add(resultsAnchor); doc.add(Tg); doc.add(tipover); Log.e("addingcontent", "complete"); } catch (Exception e) { Font font1 = new Font(Font.FontFamily.HELVETICA, 24, Font.NORMAL, BaseColor.BLACK); } }
From source file:com.workhub.utils.PDFUtils.java
private static void addContent(Document document, List<ElementModel> models) throws DocumentException { for (int i = 0; i < models.size(); i++) { ElementModel elementModel = models.get(i); Anchor anchor = new Anchor(elementModel.getTitle(), catFont); anchor.setName(elementModel.getTitle()); // Second parameter is the number of the chapter Chapter catPart = new Chapter(new Paragraph(anchor), i + 1); Paragraph content = new Paragraph(); catPart.add(content);/*from ww w . j ava 2s . c o m*/ addEmptyLine(content, 2); switch (elementModel.getType()) { case Constants.TYPE_ELEMENT_TEXT: content.add(new Paragraph(((TextElementModel) elementModel).getContent(), smallBold)); break; case Constants.TYPE_ELEMENT_LINK: content.add(new Paragraph(((LinkElementModel) elementModel).getContent(), smallBold)); break; case Constants.TYPE_ELEMENT_PICTURE: Image image1; try { if (((PictureElementModel) elementModel).getContent() != null) { image1 = Image.getInstance(((PictureElementModel) elementModel).getContent()); content.add(image1); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } break; case Constants.TYPE_ELEMENT_FILE: content.add(new Paragraph(((FileElementModel) elementModel).getTitle(), smallBold)); break; } document.add(catPart); } }
From source file:com.zaptech.pdfdemo.MainActivity.java
private void addContent(Document document) { try {/*from w w w . ja va2 s .com*/ Anchor anchor = new Anchor("First Chapter", catFont); anchor.setName("First Chapter"); Chapter chapter = new Chapter(new Paragraph(anchor), 1); Paragraph paragraph = new Paragraph("Subcategory 1", subFont); Section section = chapter.addSection(paragraph); section.add(new Paragraph("Hello")); paragraph = new Paragraph("Subcategory 2", subFont); section = chapter.addSection(paragraph); section.add(new Paragraph("Paragraph 1")); section.add(new Paragraph("Paragraph 2")); section.add(new Paragraph("Paragraph 3")); createList(section); Paragraph paragraph1 = new Paragraph(); addEmptyLine(paragraph1, 5); section.add(paragraph1); document.add(chapter); } catch (Exception e) { e.printStackTrace(); } }