List of usage examples for com.itextpdf.text.pdf BaseFont IDENTITY_H
String IDENTITY_H
To view the source code for com.itextpdf.text.pdf BaseFont IDENTITY_H.
Click Source Link
From source file:com.github.ukase.service.PdfRenderer.java
License:Open Source License
@Autowired private PdfRenderer(WaterMarkSettings settings, ResourceProvider provider) throws IOException, DocumentException { this.provider = provider; this.waterMark = settings; BaseFont baseFont = BaseFont.createFont(provider.getDefaultFont(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED); this.font = new Font(baseFont, waterMark.getSize(), 0, BaseColor.LIGHT_GRAY); }
From source file:com.github.ukase.toolkit.ResourceProvider.java
License:Open Source License
private void initFonts(ITextFontResolver fontResolver) throws IOException, DocumentException { for (String font : source.getFontsUrls()) { fontResolver.addFont(font, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); }/*from ww w.j av a 2s .c o m*/ }
From source file:com.gp.cong.logisoft.lcl.report.LclVoyageNotificationPdfCreator.java
public PdfPTable thankyouMsg(String contextPath) throws DocumentException, Exception { BaseFont palationRomanBase = BaseFont.createFont(contextPath + "/ttf/palabi.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);// w w w. j a v a2 s. co m Font palatinoRomanSmallFont = new Font(palationRomanBase, 8.5f, Font.ITALIC, new BaseColor(00, 102, 12)); table = new PdfPTable(1); table.setWidthPercentage(100f); table.addCell(createEmptyCell(0, 10f, 0)); cell = new PdfPCell(); cell.setBorder(0); Paragraph pContent = new Paragraph(8f, "Thank you for choosing Econocaribe Consolidators, Inc. for your international shipping needs. \n Please contact us if you have any questions at 1-866-ECONO-IT (866-326-6648) or visit us at www.econocaribe.com.", palatinoRomanSmallFont); pContent.setAlignment(Element.ALIGN_CENTER); cell.addElement(pContent); table.addCell(cell); return table; }
From source file:com.iisigroup.cap.report.AbstractReportPdfService.java
License:Open Source License
public ByteArrayOutputStream generateReport(Request request) throws CapException { ByteArrayOutputStream templateOut = null; ByteArrayOutputStream out = null; Writer writer = null;/*from w w w .ja v a2 s . c o m*/ OutputStreamWriter wr = null; try { Template t = getFmConfg().getConfiguration().getTemplate(getReportDefinition() + REPORT_SUFFIX); Map<String, Object> reportData = excute(request); templateOut = new ByteArrayOutputStream(); wr = new OutputStreamWriter(templateOut, getSysConfig().getProperty(ReportParamEnum.defaultEncoding.toString(), DEFAULT_ENCORDING)); writer = new BufferedWriter(wr); t.process(reportData, writer); /** * 1.FOR ? JDK 1.7 ???TransformerFactoryImpl org.apache.xalanz 2. org.apache.xalan.processor.TransformerFactoryImpl org.w3c.dom.DOMException: NAMESPACE_ERR: */ System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.xsltc.trax.TransformerFactoryImpl"); // process core-render Document document = XMLResource.load(new ByteArrayInputStream(templateOut.toByteArray())).getDocument(); ITextRenderer iTextRenderer = new ITextRenderer(); out = new ByteArrayOutputStream(); // ITextFontResolver fontResolver = iTextRenderer.getFontResolver(); fontResolver.addFont(getFontPath(), BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); PDFEncryption pdfEncryption = new PDFEncryption(); // if (reportData.containsKey(ReportParamEnum.encrypt.toString())) { String password = (String) reportData.get(ReportParamEnum.encrypt.toString()); if (!CapString.isEmpty(password)) { pdfEncryption.setUserPassword(password.getBytes()); } } // ? if (getAllowedPrivileges() != -1) { pdfEncryption.setAllowedPrivileges(getAllowedPrivileges()); } iTextRenderer.setPDFEncryption(pdfEncryption); iTextRenderer.setDocument(document, FIL_URL_PREFIX + servletContext.getRealPath("").replace("\\", "/") + "/"); iTextRenderer.layout(); iTextRenderer.createPDF(out); } catch (Exception e) { if (e.getCause() != null) { throw new CapException(e.getCause(), e.getClass()); } else { throw new CapException(e, e.getClass()); } } finally { if (templateOut != null) { try { templateOut.close(); } catch (IOException e) { if (logger.isErrorEnabled()) { logger.error(e.getMessage()); } } } if (out != null) { try { out.close(); } catch (IOException e) { if (logger.isErrorEnabled()) { logger.error(e.getMessage()); } } } } return out; }
From source file:com.microware.intrahealth.Createpdf2.java
@SuppressLint("SdCardPath") public boolean write(Context context, String fname, String[] Header, ArrayList<HashMap<String, String>> data, String[] Page2, int Flag) throws Exception { try {// w w w. ja va 2 s.c o m // file = new File(Environment.getExternalStorageDirectory()+IIHSPdf+ "/"+fname+".pdf"); this.context = context; g = (Global) context.getApplicationContext(); BaseFont urName = BaseFont.createFont("assets/FreeSans.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); urFontName = new Font(urName, 12); urName1 = FontFactory.getFont("assets/mangal.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); // urFontName = new Font(urName, 12); sHeader[0] = context.getResources().getString(R.string.hrpreport); sHeader[1] = context.getResources().getString(R.string.anmname) + " " + g.getsGlobalANMName() + " " + context.getResources().getString(R.string.distname); sHeader[2] = context.getResources().getString(R.string.Identificationcode); sHeader2[0] = context.getResources().getString(R.string.Identificationcode1); sHeader2[1] = context.getResources().getString(R.string.totalhrp); sHeader2[2] = context.getResources().getString(R.string.totalcheckup); sHeader2[3] = context.getResources().getString(R.string.anmsign); catFont2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); if (Flag == 2) { catFont = new Font(urName, 16, Font.BOLD); catFont1 = new Font(urName, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(urName, 14); smallBold = new Font(urName, 12, Font.BOLD, BaseColor.WHITE); } else { catFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD); catFont1 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(Font.FontFamily.TIMES_ROMAN, 14); smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.WHITE); } String fpath = "/sdcard/msakhi/Pdf"; File path = new File(fpath); File file = new File(path, fname + ".pdf"); if (!path.exists()) { path.mkdirs(); if (!file.exists()) { file.createNewFile(); } } else { if (!file.exists()) { file.createNewFile(); } } // Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); // Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); Document document = new Document(A4.rotate()); PdfWriter.getInstance(document, new FileOutputStream(file.getAbsoluteFile())); document.open(); // addMetaData(document); // addTitlePage(document); addContent(document, Header, data, sHeader2, Flag); document.close(); return true; } catch (IOException e) { e.printStackTrace(); return false; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } }
From source file:com.microware.intrahealth.Createpdfall.java
@SuppressLint("SdCardPath") public boolean write(String fname, String[] Header1, String[] Page1, String[] Page1Value, String heading1, String Page1Remark,// w w w . jav a 2 s . c om String[] Header2, String[] Page2_1, String[] Page2_1source, String[] Page2_1value, String[] Page2_2, String[] Page2_2source, String[] Page2_2value, String[] Page2_3, String[] Page2_3source, String[] Page2_3value, String heading2, String heading3, String heading4, String heading5, String Remark2Value, String[] Header3, String[] Page31, String[] Page3Census1, String[] Page3Value1, String[] Page32, String[] Page3Census2, String[] Page3Value2, String heading6, String heading7, String heading8, String Page3Remark, String[] Header4, String[] Page4_1, String[] Page4Value1, String[] Page4_2, String[] Page4Value2, String[] Page4_3, String[] Page4Value3, String heading9, String heading10, String heading11, String heading12, String Page4Remark1, String Page4Remark3, String[] Header5, String[] Page5Value1, String[] Page5Value2, String[] Page5Value3, String[] Page5Value4, String[] Page5_2, String[] Page5Value5, String[] Page5_3, String[] Page5Value6, String text5, String value5, String heading13, String heading14, String heading15, String Page5Remark1, String Page5Remark2, String[] Header6, String[] Page6Value1, String[] Page6Value2, String[] Page6Value3, String[] Page6Value4, String text6, String value6, String heading16, String[] Header7_1, String[] Page7Value1, String[] Page7Value2, String[] Page7Value3, String[] Page7Value4, String[] Page7Value5, String[] Header7_2, String[] Page7Value6, String[] Page7Value7, String[] Page7Value8, String[] Page7Value9, String[] Page7Value10, String[] Page7Value11, String text7_1, String value7_1, String text7_2, String value7_2, String heading17, String heading18, String heading19, String pdf1, String pdf2, int Flag) throws Exception { try { // file = new File(Environment.getExternalStorageDirectory()+IIHSPdf+ "/"+fname+".pdf"); BaseFont urName = BaseFont.createFont("assets/baamini.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); urFontName = new Font(urName, 12); catFont2 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); if (Flag == 2) { catFont = new Font(urName, 16, Font.BOLD); catFont1 = new Font(urName, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(urName, 14); smallBold = new Font(urName, 12, Font.BOLD, BaseColor.WHITE); } else { catFont = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD); catFont1 = new Font(Font.FontFamily.TIMES_ROMAN, 16, Font.BOLD, new BaseColor(0, 85, 133)); subFont = new Font(Font.FontFamily.TIMES_ROMAN, 14); smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, BaseColor.WHITE); } String fpath = "/sdcard/IIHS/Pdfs"; File path = new File(fpath); File file = new File(path, fname + ".pdf"); if (!path.exists()) { path.mkdirs(); if (!file.exists()) { file.createNewFile(); } } else { if (!file.exists()) { file.createNewFile(); } } // Font bfBold12 = new Font(Font.FontFamily.TIMES_ROMAN, 12, Font.BOLD, new BaseColor(0, 0, 0)); // Font bf12 = new Font(Font.FontFamily.TIMES_ROMAN, 12); Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(file.getAbsoluteFile())); document.open(); // addMetaData(document); // addTitlePage(document); addContent(document, Header1, Page1, Page1Value, heading1, Page1Remark, Header2, Page2_1, Page2_1source, Page2_1value, Page2_2, Page2_2source, Page2_2value, Page2_3, Page2_3source, Page2_3value, heading2, heading3, heading4, heading5, Remark2Value, Header3, Page31, Page3Census1, Page3Value1, Page32, Page3Census2, Page3Value2, heading6, heading7, heading8, Page3Remark, Header4, Page4_1, Page4Value1, Page4_2, Page4Value2, Page4_3, Page4Value3, heading9, heading10, heading11, heading12, Page4Remark1, Page4Remark3, Header5, Page5Value1, Page5Value2, Page5Value3, Page5Value4, Page5_2, Page5Value5, Page5_3, Page5Value6, text5, value5, heading13, heading14, heading15, Page5Remark1, Page5Remark2, Header6, Page6Value1, Page6Value2, Page6Value3, Page6Value4, text6, value6, heading16, Header7_1, Page7Value1, Page7Value2, Page7Value3, Page7Value4, Page7Value5, Header7_2, Page7Value6, Page7Value7, Page7Value8, Page7Value9, Page7Value10, Page7Value11, text7_1, value7_1, text7_2, value7_2, heading17, heading18, heading19, pdf1, pdf2, Flag); document.close(); return true; } catch (IOException e) { e.printStackTrace(); return false; } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } }
From source file:com.netsteadfast.greenstep.bsc.command.KpiReportPdfCommand.java
License:Apache License
private Font getFont(String color, boolean bold) throws Exception { Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); int rgb[] = SimpleUtils.getColorRGB2(color); BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]); font.setSize(9);/*from ww w . jav a 2 s . c om*/ if (bold) { font.setSize(14); font.setStyle(Font.BOLD); } font.setColor(baseColor); return font; }
From source file:com.netsteadfast.greenstep.bsc.command.OrganizationReportPdfCommand.java
License:Apache License
private Font getFont(String color, boolean bold) throws Exception { Font font = FontFactory.getFont(BscConstants.PDF_ITEXT_FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); int rgb[] = SimpleUtils.getColorRGB2(color); BaseColor baseColor = new BaseColor(rgb[0], rgb[1], rgb[2]); font.setSize(9);//from w w w. jav a 2 s. c o m font.setColor(baseColor); return font; }
From source file:com.norbsoft.pdfconverter.helpers.PDFHelper.java
License:Open Source License
public PDFHelper(Context context, String fontUrl) { this.context = context; try {/*from ww w . j a v a 2s . c o m*/ baseFont = BaseFont.createFont(fontUrl, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } normal = new Font(baseFont, 10, Font.NORMAL); bold = new Font(baseFont, 10, Font.BOLD); strike = new Font(baseFont, 10, Font.STRIKETHRU); }
From source file:com.ots.jsp1.itext.ADAStamper.java
License:Open Source License
public void addADAAsWatermark(InputStream inStream, OutputStream outputStream, String ADA) throws DocumentException, IOException { PdfStamper stamper = null;/*from w w w .j a v a 2s.c o m*/ PdfReader reader = null; try { reader = new PdfReader(inStream); //The zero byte means we dont want to change the version number of the PDF file. //true->not to change any of the original bytes stamper = new PdfStamper(reader, outputStream, '\0', true); int numberOfPages = reader.getNumberOfPages(); for (int currentPage = 1; currentPage <= numberOfPages; currentPage++) { PdfAppearance canvas = PdfAppearance.createAppearance(stamper.getWriter(), 100, 30); canvas.setFontAndSize( BaseFont.createFont(fontFilePath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED, true), 11); Rectangle pageSize = reader.getPageSizeWithRotation(currentPage); Rectangle watermarkPosition = new Rectangle(pageSize.getRight() - 150, pageSize.getTop() - 30, pageSize.getRight() - 50, pageSize.getTop() - 10, 0); PdfAnnotation annotation = PdfAnnotation.createFreeText(stamper.getWriter(), watermarkPosition, ADA, canvas); annotation.put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_READONLY)); // annotation.put(PdfName.FONT, canvas); // PdfAnnotation annotation = PdfAnnotation.createText(stamper.getWriter(), watermarkPosition, "", ADA, true, "Key"); // PdfBorderDictionary borderDictionary = new PdfBorderDictionary(0, PdfBorderDictionary.STYLE_SOLID); annotation.setBorderStyle(borderDictionary); stamper.addAnnotation(annotation, currentPage); } } finally { stamper.close(); reader.close(); } }