List of usage examples for com.itextpdf.text Utilities millimetersToPoints
public static final float millimetersToPoints(final float value)
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildFirstPage(PdfWriter writer, Document document) throws DocumentException { Paragraph firstPageTitleParagraph = new Paragraph(getDocumentTitle(), FIRST_PAGE_TITLE); firstPageTitleParagraph.setAlignment(Element.ALIGN_CENTER); firstPageTitleParagraph.setSpacingAfter(Utilities.millimetersToPoints(50)); document.add(firstPageTitleParagraph); Paragraph firstPageProjectNameParagraph = new Paragraph(getProjectName(), FIRST_PAGE_PRJ_NAME); firstPageProjectNameParagraph.setAlignment(Element.ALIGN_CENTER); firstPageProjectNameParagraph.setSpacingAfter(Utilities.millimetersToPoints(20)); document.add(firstPageProjectNameParagraph); Paragraph firstPageAuthorNameParagraph = new Paragraph(getReportAuthor(), FIRST_PAGE_AUTHOR); firstPageAuthorNameParagraph.setAlignment(Element.ALIGN_CENTER); firstPageAuthorNameParagraph.setSpacingAfter(Utilities.millimetersToPoints(20)); document.add(firstPageAuthorNameParagraph); Paragraph firstPageOrganizationParagraph = new Paragraph(getReportIstitution(), FIRST_PAGE_ORGANIZ); firstPageOrganizationParagraph.setAlignment(Element.ALIGN_CENTER); firstPageOrganizationParagraph.setSpacingAfter(Utilities.millimetersToPoints(20)); document.add(firstPageOrganizationParagraph); Paragraph firstPageDateParagraph = new Paragraph(getDate(), FIRST_PAGE_DATE); firstPageDateParagraph.setAlignment(Element.ALIGN_CENTER); firstPageDateParagraph.setSpacingAfter(Utilities.millimetersToPoints(40)); document.add(firstPageDateParagraph); String[] phrases = { "This document has been generated by STS-Tool", "http://www.sts-tool.eu" }; Paragraph firstPageLastLineParagraph = new Paragraph(phrases[0], FIRST_PAGE_LAST_LINE); for (int i = 1; i < phrases.length; i++) { firstPageLastLineParagraph.add(Chunk.NEWLINE); firstPageLastLineParagraph.add(new Phrase(phrases[i], FIRST_PAGE_LAST_LINE)); }/* w w w . java 2s . c o m*/ firstPageLastLineParagraph.setAlignment(Element.ALIGN_CENTER); document.add(firstPageLastLineParagraph); if (footerImage != null) { footerImage.setAbsolutePosition((PageSize.A4.getWidth() / 2) - (footerImage.getPlainWidth() / 2), 50); document.add(footerImage); } }
From source file:net.sf.mzmine.util.DimensionUnitUtil.java
License:Open Source License
/** * Converts any value+unit to pixel//ww w . j a v a 2 s .c o m * * @param value * @param unit * @return Float.NaN if the no conversion was defined for this unit */ public static float toPixel(float value, DimUnit unit) { // convert to pt switch (unit) { case CM: return Utilities.millimetersToPoints(value * 10.f); case MM: return Utilities.millimetersToPoints(value); case INCH: return Utilities.inchesToPoints(value); case PX: case PT: return value; } return Float.NaN; }
From source file:nz.ac.waikato.cms.doc.SimplePDFOverlay.java
License:Open Source License
/** * Parses the location string.//from ww w. ja v a2s .co m * * @param str the string to parse * @param max the maximum to use if position string is -1 * @param units the units the location is in (in|mm|pt) * @return the position in points */ protected float parseLocation(String str, float max, String units) { float result; result = Float.parseFloat(str); if (result >= 0) { switch (units) { case "mm": result = Utilities.millimetersToPoints(result); break; case "in": result = Utilities.inchesToPoints(result); break; case "pt": // nothing to do break; default: m_Logger.warning("Unknown units: " + units); } } else { result = max; } return result; }
From source file:utilities.util.java
License:Open Source License
public static float m2p(float value) { return Utilities.millimetersToPoints(value); }