Tag: html to pdf

iTextPdf 5.5.1 – 使用自定义字体将大型HTML转换为单页PDF

我正在使用包含CSS样式的HTML文档。 我想创建一个带有自定义字体的pdf文件和根据文档内容的高度。 我按照这个实现调整了基于HTML数据量的页面大小但它需要单独的HTML和CSS。 我将整个文档字符串作为HTML提供,并将CSS String保留为null。 它给了我例外。 而且如果有任何例子在Java中实现自定义字体请帮忙。 Proforma-Quittung 27.03.17 11:18 2017/2432 @font-face { font-family: “Roboto Mono”; src: url(‘RobotoMono-Bold.ttf’) format(‘ttf’), url(‘RobotoMono-BoldItalic.ttf’) format(‘ttf’), url(‘RobotoMono-Italic.ttf’) format(‘ttf’), url(‘RobotoMono-Light.ttf’) format(‘ttf’), url(‘RobotoMono-LightItalic.ttf’) format(‘ttf’), url(‘RobotoMono-Medium.ttf’) format(‘ttf’), url(‘RobotoMono-MediumItalic.ttf’) format(‘ttf’), url(‘RobotoMono-Regular.ttf’) format(‘ttf’), url(‘RobotoMono-Thin.ttf’) format(‘ttf’), url(‘RobotoMono-ThinItalic.ttf’) format(‘ttf’); } body { font-family: “Roboto Mono”; font-size: 10pt; width: 100%; margin: 0pt; } .documentType { text-transform: uppercase; } […]

iText – HTML到PDF – 图像不以PDF格式显示

我有一个带有文本,图像的html页面,我正在将HTML内容解析为iText以生成PDF。 在生成的PDF中,未显示包含的图像,仅显示文本。 如果我通过D:/Deiva/CRs/HTMLPage/article-101-horz.jpg这样的绝对路径,那么图像将被打印出来。 但是如果我尝试从服务器上打印图像就像 http://localhost:8085/content/dam/article-101-h1.jpg or http://www.google.co.in/intl/en_ALL/images/logos/images_logo_lg.gif 然后它不会在PDF中打印出来。 注意:我使用itextpdf-5.2.1.jar生成PDF。 我的HTML代码(Article.html): Generate PDF with image using iText. 我使用以下java代码生成PDF: private void createPDF (){ String path = “D:/Deiva/Test.pdf”; PdfWriter pdfWriter = null; //create a new document Document document = new Document(); try { //get Instance of the PDFWriter pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(path)); //document header attributes document.addAuthor(“betterThanZero”); document.addCreationDate(); […]