1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > java 生成字体文件 java使用itext生成pdf文件-设置字体 itextpdf import com.l

java 生成字体文件 java使用itext生成pdf文件-设置字体 itextpdf import com.l

时间:2020-11-28 21:04:33

相关推荐

java 生成字体文件 java使用itext生成pdf文件-设置字体 itextpdf import com.l

java使用itext生成pdf文件-设置字体,itextpdf,import com.limport com.lowagie.text.Document;import com.lowagie.text.Font;import com.lowagie.text.FontFactory;import com.lowagie.text.PageSize;import com.lowagie.text.Paragraph;import com.lowagie.text.Chunk;import com.lowagie.text.pdf.PdfWriter;import com.lowagie.text.pdf.PdfContentByte;public class CreatePDFiText { public static void main(String[] args) { try { Document document = new Document(PageSize. A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.getInstance (document, new FileOutputStream("C:\\my.pdf")); document.open(); // create a chunk object using chunk class of itext library. Chunk underlined = new Chunk("This is sample pdf file created by : "); // set the distance between text and line. underlined.setTextRise(8.0f); // set the width of the line, 'y' position, color and design of the line underlined.setUnderline(new Color(0x00, 0x00, 0xFF),0.0f, 0.2f, 3.0f, 0.0f, PdfContentByte.LINE_CAP_PROJECTING_SQUARE); // finally add object to the document. document.add(underlined); document.add(new Paragraph("Mahendra Singh", FontFactory.getFont(FontFactory.COURIER, 14, Font.BOLD, new Color(255, 150, 200))));; document.close(); } catch (Exception e2) { System.out.println(e2.getMessage()); } }}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。