itext

itext7 pdf to image

本小妞迷上赌 提交于 2019-12-29 04:55:11
问题 I am using iText7(java) and am looking for a way to convert a pdf page to image. In older iText versions you could do this : PdfImportedPage page = writer.getImportedPage(reader, 1); Image image = Image.getInstance(page); But iText7 does not have PdfImportedPage . My use case, I have a one page pdf file. I need to add a table and resize the pdf contents to fit a single page. In old iText I would create a page , add table, convert existing pdf page to image, resize image and add that resized

How can I add titles of chapters in ColumnText?

此生再无相见时 提交于 2019-12-29 01:30:35
问题 Please, how i can add titles of the Chapters in ColumnText? I need make PDF like this: | ColumnText column1 | ColumnText column2 | | PdfPTable with content | PdfPTable with content | | | Chapter 2 title | | Chapter 1 title | | And then add TOC to this document. I make document with ColumnText and table in it. But can't add Chapter in table. I can add Chapter only to the document body, but in this case title of Chapter not in ColumnText. Image of one page of the result document here 回答1: Your

How can I use iText to convert HTML with images and hyperlinks to PDF?

佐手、 提交于 2019-12-29 00:47:13
问题 I'm trying to convert HTML to PDF using iTextSharp in an ASP.NET web application that uses both MVC, and web forms. The <img> and <a> elements have absolute and relative URLs, and some of the <img> elements are base64. Typical answers here at SO and Google search results use generic HTML to PDF code with XMLWorkerHelper that looks something like this: using (var stringReader = new StringReader(xHtml)) { using (Document document = new Document()) { PdfWriter writer = PdfWriter.GetInstance

How to add Header and Footer in dynamic pdf using iTextLibrary?

送分小仙女□ 提交于 2019-12-28 18:42:10
问题 I have created a PDF file dynamically using iText Library, Now I want to add Header and Footer in PDF's pages, for this one I have added given code: document.addHeader("My Header Title", "My Header Details"); But in my PDF's pages this header couldn't set. What is issue that I don't know, If you have any idea related to it,please share your thoughts. 回答1: In case you use a current iText version (i.e. 5.4.x as of now) have a look at the sample MovieHistory2 from iText in Action — 2nd Edition

Merge memorystreams to one iText document

梦想与她 提交于 2019-12-28 16:08:12
问题 I have four MemoryStreams of data that I want to merge and then open the pdfDocument, without creating a single file. It's possible to write them down to files and then merge them but that would be bad practice and that can also cause a few issues so I want to avoid that. However, I can not find a way to merge the MemoryStreams with iText5 for .NET. Right now, this is how I do it with files: private static void ConcatenateDocuments() { var stream = new MemoryStream(); var readerFrontPage =

RTL not working in pdf generation with itext 5.5 for Arabic text

筅森魡賤 提交于 2019-12-28 04:32:26
问题 I have java code that writes arabic characters with the help of itext 5.5 and xmlworker jars, but its writing left to right even after writer.setRunDirection(PdfWriter.RUN_DIRECTION_RTL) is used. Code used is: public class CreateArabic extends DefaultHandler { /** Paths to and encodings of fonts we're going to use in this example */ public static String[][] FONTS = { {"C:/arialuni.ttf", BaseFont.IDENTITY_H}, {"C:/abserif4_5.ttf", BaseFont.IDENTITY_H}, {"C:/damase.ttf", BaseFont.IDENTITY_H}, {

PDF - Remove White Margins

百般思念 提交于 2019-12-28 02:50:08
问题 I would like to know a way to remove white margins from a PDF file. Just like Adobe Acrobat X Pro does. I understand it will not work with every PDF file. I would guess that the way to do it, is by getting the text margins, then cropping out of that margins. PyPdf is preferred. iText finds text margins based on this code: public void addMarginRectangle(String src, String dest) throws IOException, DocumentException { PdfReader reader = new PdfReader(src); PdfReaderContentParser parser = new

How can I can insert an image or stamp on a pdf where there is free space available like a density scanner

怎甘沉沦 提交于 2019-12-28 02:19:04
问题 I have a pdf file where-in I am adding a stamp to all it's pages. But, the problem is, the stamp is added to the upper-left corner of each page. If, the page has text in that part, the stamp appears on the text. My question is, is there any method by which I can read each page and if there is no text in that part add the stamp else search for nearest available free space, just like what a density scanner does? I am using IText and Java 1.7. The free space fider class and the distance

PDF Compression with iTextSharp [closed]

那年仲夏 提交于 2019-12-27 15:42:54
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am currently trying to recompress a pdf that has already been created, I am trying to find a way to recompress the images that are in the document, to reduce the file size. I have been trying to do this with the DataLogics PDE and iTextSharp libraries but I can not find a way to

iText 5 HTML+CSS to PDF/A-2 : Helvetica font not embedded error

最后都变了- 提交于 2019-12-27 12:07:31
问题 The following code is being used for converting HTML file with CSS to PDF/A-2 using iText5 (this code is from the example provided online): public static final String HTML = "D:\\PDFA2\\html\\sample.html"; public static final String CSS = "D:\\PDFA2\\html\\sample.css"; public static final String DEST = "D:\\PDFA2\\html\\sample.pdf"; public void createPdf(String file) throws IOException, DocumentException { Document document = new Document(); PdfAWriter writer = PdfAWriter.getInstance(document