itextsharp

Can't change /Contents of annotation

巧了我就是萌 提交于 2019-12-04 06:24:32
问题 I'm trying to change the text in some PDF annotations using iTextSharp. Here is my code: void changeAnnotations(string inputPath, string outputPath) { PdfReader pdfReader = new PdfReader(inputPath); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(outputPath, FileMode.Create)); //get the PdfDictionary of the 1st page PdfDictionary pageDict = pdfReader.GetPageN(1); //get annotation array PdfArray annotArray = pageDict.GetAsArray(PdfName.ANNOTS); //iterate through annotation

Write MS Word Doc using itextsharp library

喜欢而已 提交于 2019-12-04 06:10:05
问题 Can I write MS Word document using iTextSharp library? If yes, please give me sample code. 回答1: No, you can't. According to Wikipedia, iTextSharp is a .NET port of iText, a free and open source library for creating and manipulating PDF files in Java . You can use it to create pdf documents, but not MS Word documents. 来源: https://stackoverflow.com/questions/3758043/write-ms-word-doc-using-itextsharp-library

iTextSharp multiple lines in PdfPCell one under another

流过昼夜 提交于 2019-12-04 06:07:24
I am using iTextSharp to create table in PDF document. I need several lines inside table cell to appear one under another like this: First line text Second Line Text Third Line Text Fourth line text Some times with extra line like this : First line text Second Line Text Third Line Text Fourth line text I have tried several approaches, with Paragraphs, Chunks, Phrases, did research online but still can not get this result. Please help. Also, how to make columns to adjust width dynamically to content ? (not wrapping) Thank you If you need to align at the text level you'll need to switch to a

how do i get section target page number in pdf file using iTextSharp?

我的未来我决定 提交于 2019-12-04 06:00:40
问题 I have a pdf file which contains Index Page that includes section with target page. I could get the section name(Section 1.1, Section 5.2) but i can not get the target page number... For ex: http://www.mikesdotnetting.com/Article/84/iTextSharp-Links-and-Bookmarks Here is my code: string FileName = AppDomain.CurrentDomain.BaseDirectory + "TestPDF.pdf"; PdfReader pdfreader = new PdfReader(FileName); PdfDictionary PageDictionary = pdfreader.GetPageN(9); PdfArray Annots = PageDictionary

iTextSharp v5 GetTextFromPage() throws IndexOutOfRangeException

老子叫甜甜 提交于 2019-12-04 05:49:43
问题 Trying to extract the textual content of a pdf with the following code: PdfReader reader = new PdfReader(path); string strText = string.Empty; for (int page = 1; page <= reader.NumberOfPages; page++) { string s = PdfTextExtractor.GetTextFromPage(reader, page); strText += " " + s; } reader.Close(); NumberOfPages returns 257, but at page 227, GetTextFromPage() throws a IndexOutOfRangeException. Any help is appreciated. hofnarwillie 回答1: I resolved this issue by updating my version of iTextSharp

How to add a table as a header?

送分小仙女□ 提交于 2019-12-04 05:45:30
问题 I am working with iTextSharp trying to add an header and a footer to my generated PDF but, if I try to add an header that have width of 100% of my page I have some problem. So I have do the following things: 1) I have create a class named PdfHeaderFooter that extends the iTextSharp PdfPageEventHelper class 2) Into PdfHeaderFooter I have implemented the OnStartPage() method that generate the header: // write on start of each page public override void OnStartPage(PdfWriter writer, Document

Tables with rounded corners

╄→гoц情女王★ 提交于 2019-12-04 05:39:24
I was wondering what would be the best approach for creating tables in a pdf that have rounded corners using the iTextSharp 5.x+ library. If you have iTextSharp source code, add the following to PdfContentByte class: /// <summary> /// Enumuration for defining corners you want rounded. /// </summary> [Flags()] public enum Corners {None = 0,All=15,Top=3,Bottom=12, TopLeft = 1, TopRight=2, BottomLeft=4, BottomRight=8}; /// <summary> /// Adds a round rectangle to the current path, with rounded conrners as specified by roundCorners. /// </summary> /// <param name="x"></param> /// <param name="y"><

How to use System Font in iTextSharp with VB.net

偶尔善良 提交于 2019-12-04 04:55:02
问题 I'm using Itextsharp to convert text files to PDF documents dynamically using VB.net. However I need to use a system font that is not part of the iTextSharp library. I've seen some code examples using C#. However I'm a newbie in programming and my experience is all in Visual Basic. Can someone help me with writing the code to use a system font? 回答1: Suppose that you want to use Arial regular and you have the file arial.ttf in your C:\windows\fonts directory, then creating the Font object is

itextSharp - Merging pdf files disables extended reader permissions

戏子无情 提交于 2019-12-04 04:48:12
问题 I'm using Itextsharp v5.1 and created enabled reader pdf files. I wrote a c# class that fill the form and keep each individual pdf file extended reader. But, when I use this MergeFiles function here, it create a new Merged file NOT extended reader and I need your help with this please to turn it extended reader... my MergeFiles function is : public static void MergeFiles(string destinationFile, string[] sourceFiles) { try { //1: Create the MemoryStream for the destination document. using

Changing font of PDF using iTextSharp

萝らか妹 提交于 2019-12-04 04:46:48
问题 How can I change the font of a existing PDF file with iTextSharp in C#? I want to change the whole documents font into one e.g. Arial 回答1: Finally I solved the problem. The following code will open an existing Pdf file and will change all its font to 'Braille' as per my expectation. private static void ChangeFont() { string strFile = @"E:\\xyz.pdf"; string OutputFile = @"E:\\xyz1.pdf"; PdfReader pdfReader = new PdfReader(strFile); //Get first page,Generally we get font information on first