List of usage examples for com.lowagie.text.pdf BaseFont NOT_EMBEDDED
boolean NOT_EMBEDDED
To view the source code for com.lowagie.text.pdf BaseFont NOT_EMBEDDED.
Click Source Link
From source file:edtscol.client.Imprime.java
License:CeCILL license
private void ecrireTexteHor(String texte, float x, float y, float l, float h, float ph, float pv, int szf) { float x1, y1; try {// w w w .j a v a 2s .c om BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, szf); x1 = x + ph; y1 = y - pv; if (bf.getWidthPoint(texte, szf) > l) { cesure(bf, szf, texte, x1, y1, l, h); } else { cb.beginText(); cb.setTextMatrix(x1, y1); cb.showText(texte); cb.endText(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:edtscol.client.Imprime.java
License:CeCILL license
private void graduationEdt(float x, float y, float l, float h, int nb) { float taille = l / (nb - 1); float x1, y1; y1 = y;//w ww . j a va 2 s . c om x1 = x; for (int i = 0; i < nb; i++) { try { if (i > 0) { x1 = x1 + taille; } BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); if (i == 0 || i == nb - 1) { cb.setLineWidth(1.0f); } else { cb.setLineWidth(0.1f); } cb.moveTo(x1, y1); cb.lineTo(x1, y1 - (h * 7.0f)); cb.stroke(); cb.setLineWidth(0.2f); if (i < nb - 1) { for (int j = 1; j < 4; j++) { float tq = (taille / 04.f) * j; cb.moveTo(x1 + tq, y1); cb.lineTo(x1 + tq, y1 - (h * 7.0f)); cb.stroke(); } } cb.setLineWidth(1.0f); cb.beginText(); bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, 12); cb.setTextMatrix(x1 - 5.0f, y1 + 1.0f); int heure = i * 2 + 8; String texte = new Integer(heure).toString() + "h"; cb.showText(texte); cb.endText(); } catch (Exception e) { } } // ligne de fin de journe y1 = y1 - taille; x1 = x + l; cb.moveTo(x1, y1); cb.lineTo(x1 + lgs, y1); cb.stroke(); }
From source file:include.nseer_cookie.MakePdf.java
License:Open Source License
public void make(String database, String tablename, String sql1, String sql2, String filename, int everypage, HttpSession session) {/*from ww w . j av a 2 s.c om*/ try { nseer_db aaa = new nseer_db(database); nseer_db demo_db = new nseer_db(database); ServletContext context = session.getServletContext(); String path = context.getRealPath("/"); Masking reader = new Masking(configFile); Vector columnNames = new Vector(); Vector tables = reader.getTableNicks(); Iterator loop = tables.iterator(); while (loop.hasNext()) { String tablenick = (String) loop.next(); columnNames = reader.getColumnNames(tablenick); } int cpage = 1; //? int spage = 1; int ipage = everypage; String pagesql = sql1; //? ResultSet pagers = demo_db.executeQuery(pagesql); pagers.next(); int allCol = pagers.getInt("A"); allpage = (int) Math.ceil((allCol + ipage - 1) / ipage); // for (int m = 1; m <= allpage; m++) { spage = (m - 1) * ipage; String sql = sql2 + " limit " + spage + "," + ipage; ResultSet bbb = aaa.executeQuery(sql); //ResultSetMetaData tt=bbb.getMetaData(); // int b = columnNames.size(); // int a = 0; while (bbb.next()) { a++; } // bbb.first(); // ?? Rectangle rectPageSize = new Rectangle(PageSize.A4);// rectPageSize = rectPageSize.rotate(); Document document = new Document(rectPageSize, 20, 20, 20, 20); //? Document PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path + filename + m + ".pdf")); //?PDF?? document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); //? com.lowagie.text.Font FontChinese = new com.lowagie.text.Font(bfChinese, 8, com.lowagie.text.Font.NORMAL); // Paragraph title1 = new Paragraph("nseer ERP", FontFactory.getFont(FontFactory.HELVETICA, 18, Font.BOLDITALIC)); Chapter chapter1 = new Chapter(title1, 1); // ? chapter1.setNumberDepth(0); Paragraph title11 = new Paragraph(tablename, FontFactory.getFont(FontFactory.HELVETICA, 16, Font.BOLD)); Section section1 = chapter1.addSection(title11); //? Table t = new Table(b, a); // ? t.setPadding(1); // t.setSpacing(0); // ? t.setBorderWidth(1); // do { // // for (int k = 0; k < b; k++) { // Cell cell = new Cell( new Paragraph(bbb.getString((String) columnNames.elementAt(k)), FontChinese)); //? // t.addCell(cell); // ? // } // } while (bbb.next()); // section1.add(t); // document.add(chapter1); // document.close(); } // ? } catch (Exception pp) { pp.printStackTrace(); } }
From source file:io.vertigo.dynamo.plugins.export.pdf.PDFAdvancedPageNumberEvents.java
License:Apache License
/** {@inheritDoc} */ @Override//from w ww .jav a 2s . co m public void onOpenDocument(final PdfWriter writer, final Document document) { try { bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb = writer.getDirectContent(); template = cb.createTemplate(50, 50); } catch (final DocumentException | IOException e) { throw new RuntimeException(e); } }
From source file:io.vertigo.quarto.plugins.export.pdf.PDFAdvancedPageNumberEvents.java
License:Apache License
/** {@inheritDoc} */ @Override/* ww w . j a va 2s . c o m*/ public void onOpenDocument(final PdfWriter writer, final Document document) { try { bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb = writer.getDirectContent(); template = cb.createTemplate(50, 50); } catch (final DocumentException | IOException e) { throw WrappedException.wrap(e); } }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
private PdfTemplate createPasswordLetterTemplate(PdfWriter writer) throws Exception { IWBundle iwb = getIWApplicationContext().getIWMainApplication() .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER); PdfContentByte cb = writer.getDirectContent(); float tempLength = 511f; float tempHeight = getPointsFromMM(40); PdfTemplate template = cb.createTemplate(tempLength, tempHeight); if (addTemplateHeader()) { BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); String mail_zip = iwb.getProperty("commune.mail_zip"); String mail_name = iwb.getProperty("commune.mail_name"); float convLengt = 100f; float convHeight = 60f; template.rectangle(0f, 0f, convLengt, convHeight); template.moveTo(0f, 0f);/*w w w . j a v a 2 s . c o m*/ template.lineTo(convLengt, convHeight); template.moveTo(convLengt, 0f); template.lineTo(0f, convHeight); template.stroke(); template.beginText(); template.setFontAndSize(bf, 11f); template.setTextMatrix(5f, 40f); template.showText(mail_name); template.endText(); template.beginText(); template.setFontAndSize(bf, 11f); template.setTextMatrix(5f, 25f); template.showText(mail_zip); template.endText(); Image porto = Image.getInstance(iwb.getResourcesRealPath() + "/shared/porto_betalt.jpg"); porto.scaleAbsolute(60f, 60f); // Image portoA =Image.getInstance(iwb.getResourcesRealPath()+ // "/shared/porto_a_logo.jpg"); // float Awidth = 2.3f*60f; // portoA.scaleToFit(Awidth,60f); float portoXPos = tempLength - 90f; // float portoAXPos = portoXPos-Awidth-5f; template.addImage(porto, 60f, 0f, 0f, 60f, portoXPos, 0); // template.addImage(portoA,Awidth,0f,0f,60f,portoAXPos,0); } return template; }
From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java
License:Open Source License
public void createHeaderDate(Document document, PdfWriter writer, String dateString) throws DocumentException { /*//from ww w . j a va2s . c o m * final PdfPTable header = new PdfPTable(new float[]{1}); header.setWidthPercentage(100f); final PdfPCell defaultCell = header.getDefaultCell(); * defaultCell.setBorder(0); //defaultCell.setFixedHeight(getPointsFromMM(40)); defaultCell.setPadding(0); defaultCell.setNoWrap(true); * defaultCell.setVerticalAlignment(align); header.addCell(new Phrase(new Chunk(dateString, getDefaultParagraphFont()))); document.add(header); */ PdfContentByte cb = writer.getDirectContent(); cb.beginText(); Font font = getDefaultParagraphFont(); try { BaseFont bf = BaseFont.createFont(font.getFamilyname(), BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.setFontAndSize(bf, font.size()); // we show some text starting on some absolute position with a given // alignment cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, dateString, getPointsFromMM(210 - 20), getPointsFromMM(297 - 20), 0); cb.endText(); } catch (IOException e) { e.printStackTrace(); } }
From source file:joelib2.io.types.PDF.java
License:Open Source License
/** * Writes a molecule with his <tt>PairData</tt> . * * @param mol the molecule with additional data * @param title the molecule title or <tt>null</tt> if the title * from the molecule should be used * @param writePairData if <tt>true</tt> then the additional molecule data * is written/*from w ww . j av a2 s. c om*/ * @param attribs2write Description of the Parameter * @return <tt>true</tt> if the molecule and the data has * been succesfully written. * @exception IOException Description of the Exception */ public boolean write(Molecule mol, String title, boolean writePairData, List attribs2write, SMARTSPatternMatcher smarts) throws IOException { if (firstMoleculeWritten == false) { document.open(); firstMoleculeWritten = true; } Dimension d = new Dimension(Mol2Image.instance().getDefaultWidth(), Mol2Image.instance().getDefaultHeight()); RenderingAtoms container = new RenderingAtoms(); container.add(mol); RenderHelper.translateAllPositive(container); RenderHelper.scaleMolecule(container, d, 0.8); RenderHelper.center(container, d); Renderer2D renderer = new Renderer2D(); //BaseFont helvetica = null; try { BaseFont.createFont("Helvetica", BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } int w = d.width; int h = d.height; PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(w, h); Graphics2D g2 = tp.createGraphics(w, h); g2.setStroke(new BasicStroke(0.1f)); tp.setWidth(w); tp.setHeight(h); g2.setColor(renderer.getRenderer2DModel().getBackColor()); g2.fillRect(0, 0, d.width, d.height); if (smarts != null) { renderer.selectSMARTSPatterns(container, smarts); } renderer.paintMolecule(container, g2); g2.dispose(); ////cb.addTemplate(tp, 72, 720 - h); //cb.addTemplate(tp, 12, 720 - h); cb.addTemplate(tp, 0, document.getPageSize().height() - h); // Mol2Image.instance().mol2image(mol); BaseFont bf = null; try { bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); } catch (DocumentException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } String string = ""; //float myBorder = DEFAULT_BORDER; //float fontSize = 10; //float fontSizeDelta = DEFAULT_FONT_OFFSET; float hpos; if (writePairData) { PairData pairData; PairDataIterator gdit = mol.genericDataIterator(); int index = 0; boolean firstPageWritten = false; List attributesV; if (attribs2write == null) { // write all descriptors attributesV = new Vector(); //DescResult tmpPropResult; while (gdit.hasNext()) { pairData = gdit.nextPairData(); attributesV.add(pairData.getKey()); } } else { attributesV = attribs2write; } // sort descriptors by attribute name String[] attributes = new String[attributesV.size()]; for (int i = 0; i < attributesV.size(); i++) { attributes[i] = (String) attributesV.get(i); } Arrays.sort(attributes); // write them for (int i = 0; i < attributes.length; i++) { pairData = mol.getData(attributes[i]); string = pairData.getKey() + " = " + pairData.toString(); // reduce too complex data string = string.replace('\n', ' '); string = string.substring(0, Math.min(string.length(), WRITE_MAX_CHARACTERS)); tp = cb.createTemplate(document.getPageSize().width() - pageBorder, fontSize + fontSizeDelta); tp.setFontAndSize(bf, fontSize); tp.beginText(); tp.setTextMatrix(0, fontSizeDelta); tp.showText(string); tp.endText(); cb.setLineWidth(1f); tp.moveTo(0, 0); tp.lineTo(document.getPageSize().width() - (2 * pageBorder), 0); tp.stroke(); if (firstPageWritten) { hpos = document.getPageSize().height() - ((fontSize + fontSizeDelta) * (index + 1)); } else { hpos = document.getPageSize().height() - h - ((fontSize + fontSizeDelta) * (index + 1)); } if (hpos < pageBorder) { index = 1; firstPageWritten = true; hpos = document.getPageSize().height() - ((fontSize + fontSizeDelta) * (index + 1)); try { document.newPage(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } } cb.addTemplate(tp, pageBorder, hpos); index++; } } try { document.newPage(); } catch (DocumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } return (true); }
From source file:managedbean.aas.reportController.java
public static void concatPDFs(List<InputStream> streamOfPDFFiles, OutputStream outputStream, boolean paginate) { Document document = new Document(); try {// www . j a v a 2 s. c o m List<InputStream> pdfs = streamOfPDFFiles; List<PdfReader> readers = new ArrayList<PdfReader>(); int totalPages = 0; Iterator<InputStream> iteratorPDFs = pdfs.iterator(); // Create Readers for the pdfs. while (iteratorPDFs.hasNext()) { InputStream pdf = iteratorPDFs.next(); PdfReader pdfReader = new PdfReader(pdf); readers.add(pdfReader); totalPages += pdfReader.getNumberOfPages(); } // Create a writer for the outputstream PdfWriter writer = PdfWriter.getInstance(document, outputStream); document.open(); BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); PdfContentByte cb = writer.getDirectContent(); // Holds the PDF // data PdfImportedPage page; int currentPageNumber = 0; int pageOfCurrentReaderPDF = 0; Iterator<PdfReader> iteratorPDFReader = readers.iterator(); // Loop through the PDF files and add to the output. while (iteratorPDFReader.hasNext()) { PdfReader pdfReader = iteratorPDFReader.next(); // Create a new page in the target for each source page. while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) { document.newPage(); pageOfCurrentReaderPDF++; currentPageNumber++; page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF); cb.addTemplate(page, 0, 0); // Code for pagination. if (paginate) { cb.beginText(); cb.setFontAndSize(bf, 9); cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "" + currentPageNumber + " of " + totalPages, 520, 5, 0); cb.endText(); } } pageOfCurrentReaderPDF = 0; } outputStream.flush(); document.close(); outputStream.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (document.isOpen()) { document.close(); } try { if (outputStream != null) { outputStream.close(); } } catch (IOException ioe) { ioe.printStackTrace(); } } }
From source file:mitm.common.pdf.MessagePDFBuilder.java
License:Open Source License
private FontSelector createFontSelector(String fontName, float size, int style, Color color) { FontSelector selector = new FontSelector(); selector.addFont(FontFactory.getFont(fontName, size, style, color)); /*// www. j ava2 s . c o m * Add extra fonts provided by the FontProvider */ if (fontProvider != null) { Collection<Font> extraFonts = fontProvider.getFonts(); for (Font extraFont : extraFonts) { selector.addFont(extraFont); } } /* * Supported CJK (Chinese, Japanse, Korean) * * his is the list of fonts supported in the iTextAsian.jar: * Chinese Simplified: * STSong-Light and STSongStd-Light with the encodings UniGB-UCS2-H and UniGB-UCS2-V * Chinese Traditional: * MHei-Medium, MSung-Light and MSungStd-Light with the encodings UniCNS-UCS2-H and UniCNS-UCS2-V * Japanese: * HeiseiMin-W3, HeiseiKakuGo-W5 and KozMinPro-Regular with the encodings UniJIS-UCS2-H, UniJIS-UCS2-V, UniJIS-UCS2-HW-H and UniJIS-UCS2-HW-V * Korean: * HYGoThic-Medium, HYSMyeongJo-Medium and HYSMyeongJoStd with the encodings UniKS-UCS2-H and UniKS-UCS2-V * * Need to find out which fonts we should add to the selector and in which order */ selector.addFont(FontFactory.getFont("KozMinPro-Regular", "UniJIS-UCS2-H", BaseFont.NOT_EMBEDDED, size, style, color)); selector.addFont( FontFactory.getFont("MSung-Light", "UniCNS-UCS2-H", BaseFont.NOT_EMBEDDED, size, style, color)); selector.addFont( FontFactory.getFont("HYGoThic-Medium", "UniKS-UCS2-H", BaseFont.NOT_EMBEDDED, size, style, color)); return selector; }