public static final String FONT = "resources/fonts/NotoNaskhArabic-Regular.ttf"; public static final String ARABIC = "\u0627\u0644\u0633\u0639\u0631 \u0627\u0644\u0627\u062c\u0645\u0627\u0644\u064a"; public void createPdf(String dest) throws IOException, DocumentException { Document document = new Document(); PdfWriter.getInstance(document, new FileOutputStream(dest)); document.open(); Font f = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); PdfPTable table = new PdfPTable(1); Phrase phrase = new Phrase(); Chunk chunk = new Chunk("test value"); phrase.add(chunk); phrase.add(new Chunk(ARABIC, f)); PdfPCell cell = new PdfPCell(phrase); cell.setUseDescender(true); cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL); table.addCell(cell); document.add(table); document.close(); }
if (value != null) cell.setPadding(Float.parseFloat(value)); cell.setUseDescender(true); value = props.getProperty("bgcolor"); cell.setBackgroundColor(Markup.decodeColor(value));
if (value != null) cell.setPadding(Float.parseFloat(value)); cell.setUseDescender(true); value = props.getProperty("bgcolor"); cell.setBackgroundColor(Markup.decodeColor(value));
if (value != null) cell.setPadding(Float.parseFloat(value)); cell.setUseDescender(true); value = props.getProperty("bgcolor"); cell.setBackgroundColor(Markup.decodeColor(value));
cell.setUseAscender(rowAttributes.useAscender); cell.setUseBorderPadding(rowAttributes.useBorderPadding); cell.setUseDescender(rowAttributes.useDescender); cell.setColspan(colspan); if (horizontalAlignment != Element.ALIGN_UNDEFINED) cell.setUseBorderPadding(useBorderPadding); if (useDescender) cell.setUseDescender(useDescender); float p; float sp_left = spacing_left;
cell.setUseAscender(rowAttributes.useAscender); cell.setUseBorderPadding(rowAttributes.useBorderPadding); cell.setUseDescender(rowAttributes.useDescender); cell.setColspan(colspan); if (horizontalAlignment != Element.ALIGN_UNDEFINED) cell.setUseBorderPadding(useBorderPadding); if (useDescender) cell.setUseDescender(useDescender); float p; float sp_left = spacing_left;
cell.setUseAscender(rowAttributes.useAscender); cell.setUseBorderPadding(rowAttributes.useBorderPadding); cell.setUseDescender(rowAttributes.useDescender); cell.setColspan(colspan); if (horizontalAlignment != Element.ALIGN_UNDEFINED) cell.setUseBorderPadding(useBorderPadding); if (useDescender) cell.setUseDescender(useDescender); float p; float sp_left = spacing_left;
/** * Creates a PdfPCell based on this Cell object. * @return a PdfPCell * @throws BadElementException */ public PdfPCell createPdfPCell() throws BadElementException { if (rowspan > 1) throw new BadElementException("PdfPCells can't have a rowspan > 1"); if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable()); PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(verticalAlignment); cell.setHorizontalAlignment(horizontalAlignment); cell.setColspan(colspan); cell.setUseBorderPadding(useBorderPadding); cell.setUseDescender(useDescender); cell.setLeading(getLeading(), 0); cell.cloneNonPositionParameters(this); cell.setNoWrap(getMaxLines() == 1); for (Iterator i = getElements(); i.hasNext(); ) { Element e = (Element)i.next(); if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) { Paragraph p = new Paragraph((Phrase)e); p.setAlignment(horizontalAlignment); e = p; } cell.addElement(e); } return cell; }
/** * Creates a PdfPCell based on this Cell object. * @return a PdfPCell * @throws BadElementException */ public PdfPCell createPdfPCell() throws BadElementException { if (rowspan > 1) throw new BadElementException(MessageLocalization.getComposedMessage("pdfpcells.can.t.have.a.rowspan.gt.1")); if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable()); PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(verticalAlignment); cell.setHorizontalAlignment(horizontalAlignment); cell.setColspan(colspan); cell.setUseBorderPadding(useBorderPadding); cell.setUseDescender(useDescender); cell.setLeading(getLeading(), 0); cell.cloneNonPositionParameters(this); cell.setNoWrap(getMaxLines() == 1); for (Iterator i = getElements(); i.hasNext(); ) { Element e = (Element)i.next(); if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) { Paragraph p = new Paragraph((Phrase)e); p.setAlignment(horizontalAlignment); e = p; } cell.addElement(e); } return cell; }
/** * Creates a PdfPCell based on this Cell object. * @return a PdfPCell * @throws BadElementException */ public PdfPCell createPdfPCell() throws BadElementException { if (rowspan > 1) throw new BadElementException(MessageLocalization.getComposedMessage("pdfpcells.can.t.have.a.rowspan.gt.1")); if (isTable()) return new PdfPCell(((Table)arrayList.get(0)).createPdfPTable()); PdfPCell cell = new PdfPCell(); cell.setVerticalAlignment(verticalAlignment); cell.setHorizontalAlignment(horizontalAlignment); cell.setColspan(colspan); cell.setUseBorderPadding(useBorderPadding); cell.setUseDescender(useDescender); cell.setLeading(getLeading(), 0); cell.cloneNonPositionParameters(this); cell.setNoWrap(getMaxLines() == 1); for (Iterator i = getElements(); i.hasNext(); ) { Element e = (Element)i.next(); if (e.type() == Element.PHRASE || e.type() == Element.PARAGRAPH) { Paragraph p = new Paragraph((Phrase)e); p.setAlignment(horizontalAlignment); e = p; } cell.addElement(e); } return cell; }
cell.setPadding(2); cell.setUseAscender(true); cell.setUseDescender(true); table.addCell(p); document.add(table);