itext

how to convert doc,docx files to pdf in java programatically

血红的双手。 提交于 2019-12-22 14:58:09
问题 I am able to generate pdf from docx file using docx4j.But i need to convert doc file to pdf including images and tables. Is there any way to convert doc to docx in java . or (doc to pdf)? 回答1: docx4j contains org.docx4j.convert.in.Doc, which uses POI to read the .doc, but it is a proof of concept, not production ready code. Last I checked, there were limits to POI's HWPF parsing of a binary .doc. Further to mqchen's comment, you can use LibreOffice or OpenOffice to convert doc to docx. But if

IText: How to add blank page inside pdf?

邮差的信 提交于 2019-12-22 14:49:11
问题 I have pdf document, for example 25 pages. How to add one blank page beetwen page 10 and 11 ? 回答1: First hit on google: /* * This class is part of the book "iText in Action - 2nd Edition" * written by Bruno Lowagie (ISBN: 9781935182610) * For more info, go to: http://itextpdf.com/examples/ * This example only works with the AGPL version of iText. */ package part1.chapter05; import java.io.FileOutputStream; import java.io.IOException; import com.itextpdf.text.Document; import com.itextpdf.text

IText: How to add blank page inside pdf?

て烟熏妆下的殇ゞ 提交于 2019-12-22 14:49:04
问题 I have pdf document, for example 25 pages. How to add one blank page beetwen page 10 and 11 ? 回答1: First hit on google: /* * This class is part of the book "iText in Action - 2nd Edition" * written by Bruno Lowagie (ISBN: 9781935182610) * For more info, go to: http://itextpdf.com/examples/ * This example only works with the AGPL version of iText. */ package part1.chapter05; import java.io.FileOutputStream; import java.io.IOException; import com.itextpdf.text.Document; import com.itextpdf.text

Search for a text in a pdf file and return the coordinates if the text exist

倖福魔咒の 提交于 2019-12-22 13:57:56
问题 I am trying to search for a text in a pdf file and return the coordinates if the text exist. I was researching the net and find out that this can be done with the itextsharp library. I found this code and I am trying to modify it to meet my requirements. How can I pass my file to this class. class Program { static void Main(string[] args) { var testFile = @"test.pdf"; //Create an instance of our strategy var t = new MyLocationTextExtractionStrategy("test"); //Parse page 1 of the document

Putting several images next to each other in a pdfcell with itextsharp

孤街浪徒 提交于 2019-12-22 13:53:34
问题 I'm using itextsharp with a aspmvc project to create PDF versions of some of my pages. I have a very basic parser which takes simple html (plus some style info supplied seperately) and creates a pdf. When my parser encounts a table it loops over rows then cells, creating a PdfPCell for each cell. It then loops over child elements of the cell adding them to the PdfPCell. It's pretty basic but it's worked for me so far. The problem is that I now have a table one column of which contains a

Fix the orientation of a PDF in order to scale it

て烟熏妆下的殇ゞ 提交于 2019-12-22 11:37:09
问题 I am having some issues with a PDF containing a rotation property created by a Xerox scanner. The below function was originally created to scale the height of an input PDF by the amount given by the variable scaleHeight. This works fine for input documents without rotation. When testing a document with a 270 degree rotation, I found that the rotation property which would have made the document appear in a portrait orientation was ignored. Instead, the document appeared in a landscape

iText PDFWriter - Writing table header if the few table rows go to new page

对着背影说爱祢 提交于 2019-12-22 10:56:18
问题 I am using PdfWriter to create a PDF document. I am adding a PdfPTable to the PDF document. This table has header row and then actual data rows. If the table is big, then part of it gets carried forward to new page. I want this page to have table header row as well. However, I want this header row only when the table data goes on new page. 回答1: This is how you create a table with a header row: // table with 2 columns: PdfPTable table = new PdfPTable(2); // header row: table.addCell("Key");

Image not sequentialy added in pdf document itextsharp (wrong order of elements)

守給你的承諾、 提交于 2019-12-22 10:36:19
问题 i am working with iTextSharp (5.4.5) for a couple of weeks now. This week, i encountered something strangew hen it comes to the order of elements in the documents. I am working on a pdf report that contains topics and images (charts). The document is formatted this way: NR. TOPIC TITLE FOR TOPIC 1 CHART IMAGE for topic 1 (from bytearray) NR. TOPIC TITLE FOR TOPIC 2 CHART IMAGE for topic 2 ... below is a sample of code. I know code is not completely correct but it's just to point the issue.

Add image to PDF from a URL?

大憨熊 提交于 2019-12-22 10:35:35
问题 Im trying to add a image from a URL address to my pdf. The code is: Image image=Image.getInstance("http://www.google.com/intl/en_ALL/images/logos/images_logo_lg.gif"); image.scaleToFit((float)200.0, (float)49.0); paragraph.add(image); But it does not work. What can be wrong? 回答1: This is a known issue when loading .gif from a remote location with iText. A fix for this would be to download the .gif with Java (not via the getInstance method of iText's Image class) and to use the downloaded

Multiple Table Column alignment in iTextsharp

跟風遠走 提交于 2019-12-22 10:13:00
问题 I am creating a table where each column has its own alignment as shown below. How do I accomplish it at column level than at cell level? 回答1: iText and iTextSharp don't support column styles and formatting. The only way to do this is as you are doing currently, cell by cell. EDIT The easiest work around is to create helper methods that set your common properties. These can either be done through extension methods or just regular static methods. I don't have a C# IDE in front of me so my