List of usage examples for com.itextpdf.text.pdf BaseFont NOT_EMBEDDED
boolean NOT_EMBEDDED
To view the source code for com.itextpdf.text.pdf BaseFont NOT_EMBEDDED.
Click Source Link
From source file:Operaciones.Destajo.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed // TODO add your handling code here: h = new Herramientas(usr, 0); h.session(sessionPrograma);//from w w w .ja va 2 s .co m Session session = HibernateUtil.getSessionFactory().openSession(); try { session.beginTransaction().begin(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED); //Orden ord=buscaApertura(); PDF reporte = new PDF(); Date fecha = new Date(); DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS String valor = dateFormat.format(fecha); File folder = new File("reportes/" + ord); folder.mkdirs(); reporte.Abrir(PageSize.LETTER.rotate(), "Valuacin", "reportes/" + ord + "/" + valor + "-destajo.pdf"); Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD); BaseColor contenido = BaseColor.WHITE; int centro = Element.ALIGN_CENTER; int izquierda = Element.ALIGN_LEFT; int derecha = Element.ALIGN_RIGHT; float tam[] = new float[] { 150, 50, 100, 300 }; PdfPTable tabla = reporte.crearTabla(4, tam, 100, Element.ALIGN_LEFT); cabecera(reporte, bf, tabla); session.beginTransaction().begin(); Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(this.ord)); List cuentas = null; for (int x = 0; x < 21; x++) { tabla.addCell(reporte.celda(" \n ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" \n ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" \n ", font, contenido, derecha, 0, 1, Rectangle.RECTANGLE)); tabla.addCell(reporte.celda(" \n ", font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE)); } session.beginTransaction().rollback(); tabla.setHeaderRows(1); reporte.agregaObjeto(tabla); reporte.cerrar(); reporte.visualizar("reportes/" + ord + "/" + valor + "-destajo.pdf"); } catch (Exception e) { System.out.println(e); e.printStackTrace(); JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto."); } if (session != null) if (session.isOpen()) { session.flush(); session.clear(); session.close(); } }
From source file:org.ganttproject.impex.htmlpdf.fonts.TTFontCache.java
License:Open Source License
private void registerFontFile(final File fontFile) throws FontFormatException, IOException { // FontFactory.register(fontFile.getAbsolutePath()); Font awtFont = createAwtFont(fontFile); GPLogger.getLogger(getClass()).fine("Trying font file: " + fontFile.getAbsolutePath()); final String family = awtFont.getFontName().toLowerCase(); AwtFontSupplier awtSupplier = myMap_Family_RegularFont.get(family); try {// ww w . ja v a 2s. c o m myMap_Family_ItextFont.put(family, createFontSupplier(fontFile, BaseFont.EMBEDDED)); } catch (DocumentException e) { if (e.getMessage().indexOf("cannot be embedded") < 0) { GPLogger.logToLogger(e); return; } } try { myMap_Family_ItextFont.put(family, createFontSupplier(fontFile, BaseFont.NOT_EMBEDDED)); } catch (DocumentException e) { GPLogger.logToLogger(e); return; } GPLogger.getLogger(getClass()).fine("registering font: " + family); if (awtSupplier == null) { awtSupplier = new AwtFontSupplier(); myMap_Family_RegularFont.put(family, awtSupplier); } awtSupplier.addFile(fontFile); }
From source file:org.h819.commons.file.MyPDFUtils.java
/** * STCAIYUN.TTF?? jar? classpath/*from ww w. j a v a 2 s . c o m*/ * ? pdf ??? pdf ? * ?????? * * @return * @throws IOException */ private static Font getPdfFont() { // String fontName = "/STCAIYUN.TTF"; String fontPath = SystemUtils.getJavaIoTmpDir() + File.separator + MyConstants.JarTempDir + File.separator + fontName; //????? if (!Files.exists(Paths.get(fontPath))) { MyFileUtils.copyResourceFileFromJarLibToTmpDir(fontName); } return FontFactory.getFont(fontPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); }
From source file:org.h819.commons.file.MyPDFUtils.java
/** * ? iTextAsian.jar//w ww . j av a 2s. c om * itext 5.5.9 ??? * * @return */ @Deprecated private static Font getChineseFont() { Font fontChinese = null; try { BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); fontChinese = new Font(bfChinese, 12, Font.NORMAL); } catch (DocumentException de) { System.err.println(de.getMessage()); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } return fontChinese; }
From source file:org.oscarehr.fax.util.PdfCoverPageCreator.java
License:Open Source License
public byte[] createCoverPage() { Document document = new Document(); ByteArrayOutputStream os = new ByteArrayOutputStream(); try {// ww w. j av a2s . c o m PdfWriter pdfWriter = PdfWriter.getInstance(document, os); document.open(); PdfPTable table = new PdfPTable(1); table.setWidthPercentage(95); PdfPCell cell = new PdfPCell(table); cell.setBorder(0); cell.setPadding(3); cell.setColspan(1); table.addCell(cell); ClinicDAO clinicDao = SpringUtils.getBean(ClinicDAO.class); Clinic clinic = clinicDao.getClinic(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); Font headerFont = new Font(bf, 28, Font.BOLD); Font infoFont = new Font(bf, 12, Font.NORMAL); if (clinic != null) { cell = new PdfPCell(new Phrase( String.format("%s\n %s, %s, %s %s", clinic.getClinicName(), clinic.getClinicAddress(), clinic.getClinicCity(), clinic.getClinicProvince(), clinic.getClinicPostal()), headerFont)); } else { cell = new PdfPCell(new Phrase("OSCAR", headerFont)); } cell.setPaddingTop(100); cell.setPaddingLeft(25); cell.setPaddingBottom(25); cell.setBorderWidthBottom(1); table.addCell(cell); PdfPTable infoTable = new PdfPTable(1); cell = new PdfPCell(new Phrase(note, infoFont)); cell.setPaddingTop(25); cell.setPaddingLeft(25); infoTable.addCell(cell); table.addCell(infoTable); document.add(table); } catch (DocumentException e) { MiscUtils.getLogger().error("PDF COVER PAGE ERROR", e); return new byte[] {}; } catch (IOException e) { MiscUtils.getLogger().error("PDF COVER PAGE ERROR", e); return new byte[] {}; } finally { document.close(); } return os.toByteArray(); }
From source file:org.primaresearch.pdf.PageToPdfConverter.java
License:Apache License
/** * Creates the font that is to be used for the hidden text layer in the PDF. *//*from w ww . ja v a 2 s. c om*/ private void createFont() throws DocumentException, IOException { //TODO Even with the 'NOT_EMBEDDED' settings it seems to embed the font! if (ttfFontFilePath == null) font = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); else { font = FontFactory.getFont(ttfFontFilePath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED).getBaseFont(); //PDTrueTypeFont.loadTTF(document, ttfFontFilePath); //Encoding enc = font.getFontEncoding(); //Map<Integer, String> map = enc.getCodeToNameMap(); //System.out.println("Font encoding map size: " + map.size()); } }
From source file:org.tvd.thptty.management.report.Report.java
private BaseFont getTahomaBaseFont() { BaseFont tahoma = null;/*from ww w .j ava 2 s . co m*/ try { tahoma = BaseFont.createFont(FontPath.TAHOMA_FONT, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return tahoma; }
From source file:pdf.alterLetter.java
public static void main(String args[]) { try {/*from www .j a v a 2s.c o m*/ PdfReader pdfReader; pdfReader = new PdfReader("C:\\Users\\asus\\Desktop\\web\\Appointment letter.pdf"); //pdfReader = new PdfReader("C:\\Users\\asus\\Desktop\\TFMsystem\\Appointment letter.pdf"); //Create PdfStamper instance. PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream( "C:\\Users\\asus\\Desktop\\TFMsystem\\web\\Modified appointment letter.pdf")); //new FileOutputStream("C:\\Users\\asus\\Desktop\\TFMsystem\\Modified appointment letter.pdf")); //Create BaseFont instance. BaseFont baseFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1257, BaseFont.NOT_EMBEDDED); //Get the number of pages in pdf. int pages = pdfReader.getNumberOfPages(); //Iterate the pdf through pages. for (int i = 1; i <= pages; i++) { //Contain the pdf data. PdfContentByte pageContentByte = pdfStamper.getOverContent(i); pageContentByte.beginText(); //Set text font and size. pageContentByte.setFontAndSize(baseFont, 12); //Write text pageContentByte.setTextMatrix(120, 706); pageContentByte.showText("[no rujukan(enter by admin/opai)]"); pageContentByte.setTextMatrix(500, 706); pageContentByte.showText("[current date]"); //address pageContentByte.setTextMatrix(46, 641); pageContentByte.showText("[name]"); pageContentByte.setTextMatrix(46, 629); pageContentByte.showText("[position]"); pageContentByte.setTextMatrix(46, 617); pageContentByte.showText("[department]"); pageContentByte.setTextMatrix(155, 493); pageContentByte.showText("[status(penyelaras/ahli),taskforce name]"); pageContentByte.setTextMatrix(178, 433); pageContentByte.showText("[start date]"); pageContentByte.setTextMatrix(290, 433); pageContentByte.showText("[end date] ."); pageContentByte.setTextMatrix(46, 248); pageContentByte.showText("[name]"); pageContentByte.setTextMatrix(46, 236); pageContentByte.showText("[post]"); pageContentByte.setTextMatrix(46, 224); pageContentByte.showText("[faculty]"); pageContentByte.setTextMatrix(46, 212); pageContentByte.showText("[email]"); pageContentByte.endText(); } //Close the pdfStamper. pdfStamper.close(); System.out.println("PDF modified successfully."); } catch (Exception e) { e.printStackTrace(); } }
From source file:pdf.letter.java
public boolean AlterLetter(String rujukan, String name, String position, String department, String gStatus, String sDate, String eDate, String taskName, String postHolderName, String postHolderEmail, String postName) {/*from w w w . j a va2s . c om*/ DateFormat df = new SimpleDateFormat("dd/MM/yyyy"); Date today = Calendar.getInstance().getTime(); String currDate = df.format(today); try { PdfReader pdfReader; pdfReader = new PdfReader("C:\\Users\\on\\Desktop\\AD\\TFMsystem\\web\\Appointment letter.pdf"); //C:\\Users\\on\\Desktop\\AD\\TFMsystem\\web\\Appointment letter.pdf //Create PdfStamper instance. PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileOutputStream( "C:\\Users\\on\\Desktop\\AD\\TFMsystem\\web\\Modified appointment letter.pdf")); //C:\\Users\\on\\Desktop\\AD\\TFMsystem\\web\\Modified Appointment letter.pdf //Create BaseFont instance. BaseFont baseFont = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1257, BaseFont.NOT_EMBEDDED); //Get the number of pages in pdf. int pages = pdfReader.getNumberOfPages(); //Iterate the pdf through pages. for (int i = 1; i <= pages; i++) { //Contain the pdf data. PdfContentByte pageContentByte = pdfStamper.getOverContent(i); pageContentByte.beginText(); //Set text font and size. pageContentByte.setFontAndSize(baseFont, 11); //Write text pageContentByte.setTextMatrix(120, 706); pageContentByte.showText(rujukan); pageContentByte.setTextMatrix(500, 706); pageContentByte.showText(currDate); //address pageContentByte.setTextMatrix(46, 641); pageContentByte.showText(name); pageContentByte.setTextMatrix(46, 629); pageContentByte.showText(position); pageContentByte.setTextMatrix(46, 617); pageContentByte.showText(department); String gstatus; pageContentByte.setTextMatrix(157, 493); String changeCase = gStatus + ", " + taskName; pageContentByte.showText(changeCase.toUpperCase()); pageContentByte.setTextMatrix(250, 444); pageContentByte.showText(gStatus + " " + taskName + " ."); pageContentByte.setTextMatrix(180, 432); pageContentByte.showText(sDate); pageContentByte.setTextMatrix(290, 432); pageContentByte.showText(eDate + " ."); pageContentByte.setTextMatrix(46, 248); pageContentByte.showText(postHolderName); pageContentByte.setTextMatrix(46, 236); pageContentByte.showText(postName); pageContentByte.setTextMatrix(46, 224); pageContentByte.showText("Fakulti Komputeran"); pageContentByte.setTextMatrix(46, 212); pageContentByte.showText(postHolderEmail); pageContentByte.endText(); } //Close the pdfStamper. pdfStamper.close(); System.out.println("PDF modified successfully."); return true; } catch (Exception e) { e.printStackTrace(); return false; } }
From source file:printInv.GenerateInvoice.java
public void initializeFonts() { try {//from w w w .jav a 2 s . c o m bfBold = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }