List of usage examples for org.apache.pdfbox.pdmodel.font PDType1Font TIMES_ITALIC
PDType1Font TIMES_ITALIC
To view the source code for org.apache.pdfbox.pdmodel.font PDType1Font TIMES_ITALIC.
Click Source Link
From source file:com.baseprogramming.pdwriter.html.HtmlStyle.java
License:Apache License
private void createFontMap() { fontMap = new HashMap<>(); fontMap.put("TIMES NEW ROMAN", PDType1Font.TIMES_ROMAN); fontMap.put("TIMES NEW ROMAN_BOLD", PDType1Font.TIMES_BOLD); fontMap.put("TIMES NEW ROMAN_ITALIC", PDType1Font.TIMES_ITALIC); fontMap.put("TIMES NEW ROMAN_OBLIQUE", PDType1Font.TIMES_ITALIC); fontMap.put("TIMES NEW ROMAN_BOLD_ITALIC", PDType1Font.TIMES_BOLD_ITALIC); fontMap.put("COURIER", PDType1Font.COURIER); fontMap.put("COURIER_BOLD", PDType1Font.COURIER_BOLD); fontMap.put("COURIER_ITALIC", PDType1Font.COURIER_OBLIQUE); fontMap.put("COURIER_OBLIQUE", PDType1Font.COURIER_OBLIQUE); fontMap.put("COURIER_BOLD_ITALIC", PDType1Font.COURIER_BOLD_OBLIQUE); fontMap.put("HELVATICA", PDType1Font.TIMES_ROMAN); fontMap.put("HELVATICA_ITALIC", PDType1Font.HELVETICA_BOLD); fontMap.put("HELVATICA_OBLIQUE", PDType1Font.HELVETICA_BOLD); fontMap.put("HELVATICA_BOLD_ITALIC", PDType1Font.HELVETICA_OBLIQUE); fontMap.put("HELVATICA_BOLD_ITALIC", PDType1Font.HELVETICA_BOLD_OBLIQUE); }
From source file:jgnash.PDFBoxTableTest.java
License:Open Source License
@Test void basicReportTest() throws IOException { Path tempPath = null;// ww w . jav a 2s . c o m Path tempRasterPath = null; try (final Report report = new SimpleReport()) { tempPath = Files.createTempFile("pdfTest", ".pdf"); tempRasterPath = Files.createTempFile("pdfTest", ".png"); final float padding = 2.5f; report.setTableFont(PDType1Font.COURIER); report.setHeaderFont(PDType1Font.HELVETICA_BOLD); report.setCellPadding(padding); report.setBaseFontSize(9); final PageFormat pageFormat = ReportPrintFactory.getDefaultPage(); pageFormat.setOrientation(PageFormat.LANDSCAPE); report.setPageFormat(pageFormat); report.setFooterFont(PDType1Font.TIMES_ITALIC); report.setEllipsis(""); assertEquals(1, Report.getGroups(new BasicTestReport()).size()); assertEquals(80, ((Report.GroupInfo) Report.getGroups(new BasicTestReport()).toArray()[0]).rows); report.addTable(new BasicTestReport(), "Test Report"); report.addFooter(); report.saveToFile(tempPath); assertTrue(report.isLandscape()); assertEquals(padding, report.getCellPadding()); assertTrue(Files.exists(tempPath)); // Create a PNG file final BufferedImage bim = report.renderImage(0, 300); ImageIOUtil.writeImage(bim, tempRasterPath.toString(), 300); assertTrue(Files.exists(tempRasterPath)); } catch (final IOException e) { e.printStackTrace(); } finally { if (tempPath != null) { Files.deleteIfExists(tempPath); } if (tempRasterPath != null) { Files.deleteIfExists(tempRasterPath); } } }
From source file:jgnash.PDFBoxTableTest.java
License:Open Source License
@Test void crossTabReportTest() throws IOException { Path tempPath = null;//from w w w . j a va 2 s .co m Path tempRasterPath = null; try (final Report report = new SimpleReport()) { tempPath = Files.createTempFile("pdfTest", ".pdf"); tempRasterPath = Files.createTempFile("pdfTest", ".png"); final float padding = 2.5f; report.setTableFont(PDType1Font.COURIER); report.setHeaderFont(PDType1Font.HELVETICA_BOLD); report.setCellPadding(padding); report.setBaseFontSize(9); report.setForceGroupPagination(true); final PageFormat pageFormat = (PageFormat) report.getPageFormat().clone(); pageFormat.setOrientation(PageFormat.LANDSCAPE); report.setPageFormat(pageFormat); report.setFooterFont(PDType1Font.TIMES_ITALIC); report.setEllipsis(""); assertEquals(2, Report.getGroups(new CrossTabTestReport()).size()); assertEquals(40, ((Report.GroupInfo) Report.getGroups(new CrossTabTestReport()).toArray()[0]).rows); report.addTable(new CrossTabTestReport(), "Test Report"); report.addFooter(); report.saveToFile(tempPath); assertTrue(report.isLandscape()); assertEquals(padding, report.getCellPadding()); assertTrue(Files.exists(tempPath)); // Create a PNG file final BufferedImage bim = report.renderImage(0, 300); ImageIOUtil.writeImage(bim, tempRasterPath.toString(), 300); assertTrue(Files.exists(tempRasterPath)); } catch (final IOException e) { e.printStackTrace(); } finally { if (tempPath != null) { Files.deleteIfExists(tempPath); } if (tempRasterPath != null) { Files.deleteIfExists(tempRasterPath); } } }
From source file:org.fit.cssbox.render.PDFRenderer.java
License:Open Source License
private PDFont tryBuiltinFallback(String fontFamily, boolean isItalic, boolean isBold) { PDFont font;/*from w ww .j a v a 2 s. c o m*/ fontFamily = fontFamily.toLowerCase(); switch (fontFamily) { case "courier": case "courier new": case "lucida console": if (isBold && isItalic) { font = PDType1Font.COURIER_BOLD_OBLIQUE; } else if (isBold) { font = PDType1Font.COURIER_BOLD; } else if (isItalic) { font = PDType1Font.COURIER_OBLIQUE; } else { font = PDType1Font.COURIER; } break; case "times": case "garamond": case "georgia": case "times new roman": case "serif": if (isBold && isItalic) { font = PDType1Font.TIMES_BOLD_ITALIC; } else if (isBold) { font = PDType1Font.TIMES_BOLD; } else if (isItalic) { font = PDType1Font.TIMES_ITALIC; } else { font = PDType1Font.TIMES_ROMAN; } break; default: if (isBold && isItalic) { font = PDType1Font.HELVETICA_BOLD_OBLIQUE; } else if (isBold) { font = PDType1Font.HELVETICA_BOLD; } else if (isItalic) { font = PDType1Font.HELVETICA_OBLIQUE; } else { font = PDType1Font.HELVETICA; } break; } return font; }
From source file:org.sejda.impl.pdfbox.util.FontUtilsTest.java
License:Apache License
@Test public void testGetStandardType1Fontg() { assertEquals(PDType1Font.COURIER, FontUtils.getStandardType1Font(StandardType1Font.CURIER)); assertEquals(PDType1Font.COURIER_BOLD, FontUtils.getStandardType1Font(StandardType1Font.CURIER_BOLD)); assertEquals(PDType1Font.COURIER_BOLD_OBLIQUE, FontUtils.getStandardType1Font(StandardType1Font.CURIER_BOLD_OBLIQUE)); assertEquals(PDType1Font.COURIER_OBLIQUE, FontUtils.getStandardType1Font(StandardType1Font.CURIER_OBLIQUE)); assertEquals(PDType1Font.HELVETICA, FontUtils.getStandardType1Font(StandardType1Font.HELVETICA)); assertEquals(PDType1Font.HELVETICA_BOLD, FontUtils.getStandardType1Font(StandardType1Font.HELVETICA_BOLD)); assertEquals(PDType1Font.HELVETICA_BOLD_OBLIQUE, FontUtils.getStandardType1Font(StandardType1Font.HELVETICA_BOLD_OBLIQUE)); assertEquals(PDType1Font.HELVETICA_OBLIQUE, FontUtils.getStandardType1Font(StandardType1Font.HELVETICA_OBLIQUE)); assertEquals(PDType1Font.TIMES_BOLD, FontUtils.getStandardType1Font(StandardType1Font.TIMES_BOLD)); assertEquals(PDType1Font.TIMES_BOLD_ITALIC, FontUtils.getStandardType1Font(StandardType1Font.TIMES_BOLD_ITALIC)); assertEquals(PDType1Font.TIMES_ITALIC, FontUtils.getStandardType1Font(StandardType1Font.TIMES_ITALIC)); assertEquals(PDType1Font.TIMES_ROMAN, FontUtils.getStandardType1Font(StandardType1Font.TIMES_ROMAN)); assertEquals(PDType1Font.SYMBOL, FontUtils.getStandardType1Font(StandardType1Font.SYMBOL)); assertEquals(PDType1Font.ZAPF_DINGBATS, FontUtils.getStandardType1Font(StandardType1Font.ZAPFDINGBATS)); }
From source file:org.socialbiz.cog.util.PDFUtil.java
License:Apache License
private void writeRest(String line) throws IOException, Exception { while (line.length() > 0) { if (checkMoreToken(line)) { for (int i = 0; i < line.length(); i++) { String wikiToken = checkForWiki(line, i); if ("bold".equals(wikiToken)) { line = formatAndWrite(line, i, PDType1Font.TIMES_BOLD, "__"); break; } else if ("italic".equals(wikiToken)) { line = formatAndWrite(line, i, PDType1Font.TIMES_ITALIC, "''"); break; } else if ("bold_italic".equals(wikiToken)) { line = formatAndWrite(line, i, PDType1Font.TIMES_BOLD_ITALIC, "''__"); break; } else if ("italic_bold".equals(wikiToken)) { line = formatAndWrite(line, i, PDType1Font.TIMES_BOLD_ITALIC, "__''"); break; } else if ("hyperlink".equals(wikiToken)) { wIndex = 0;//from w w w . ja v a 2 s .co m initializeWrappedListOfLink(); String preLink = line.substring(0, i); if (preLink.length() > 0) { writeRest(preLink + " "); } float preLinkWidth = previousSubLineWidth + font.getStringWidth(preLink.substring(wIndex)) / 1000 * 10f; addLinkAnnotation(yPos - 3, 22, line, preLinkWidth, i); contentStream.setNonStrokingColor(Color.black); line = line.substring(line.indexOf("]") + 1); break; } } } else { wrappedAndWriteString(line); break; } } }