itextsharp

HTML to List using XMLWorker

随声附和 提交于 2019-12-17 06:55:11
问题 Could somebody please provide an example of parsing HTML into a list of elements using XMLWorkerHelper in iTextSharp (C#). The JAVA version as given in the documentation is: XMLWorkerHelper.getInstance().parseXHtml(new ElementHandler() { public void add(final Writable w) { if (w instanceof WritableElement) { List<Element> elements = ((WritableElement)w).elements(); // write class names of elements to file } } }, HTMLParsingToList.class.getResourceAsStream("/html/walden.html")); 回答1: You need

Retrieve the respective coordinates of all words on the page with itextsharp

非 Y 不嫁゛ 提交于 2019-12-17 05:13:18
问题 my aim is to retrieve the respective coordinates of all words on the page,what i have done is PdfReader reader = new PdfReader("cde.pdf"); TextWithPositionExtractionStategy S = new TextWithPositionExtractionStategy(); PdfTextExtractor.GetTextFromPage(reader,1,S); Vector curBaseline = renderInfo.GetDescentLine().GetStartPoint(); Vector topRight = renderInfo.GetAscentLine().GetEndPoint(); iTextSharp.text.Rectangle rect = new iTextSharp.text.Rectangle(curBaseline[Vector.I1], curBaseline[Vector

Checking off pdf checkbox with itextsharp

梦想的初衷 提交于 2019-12-17 05:06:47
问题 I've tried so many different ways, but I can't get the check box to be checked! Here's what I've tried: var reader = new iTextSharp.text.pdf.PdfReader(originalFormLocation); using (var stamper = new iTextSharp.text.pdf.PdfStamper(reader,ms)) { var formFields = stamper.AcroFields; formFields.SetField("IsNo", "1"); formFields.SetField("IsNo", "true"); formFields.SetField("IsNo", "On"); } None of them work. Any ideas? 回答1: You shouldn't "guess" for the possible values. You need to use a value

iTextSharp-generated PDFs now cause Save dialog in Adobe Reader X

≯℡__Kan透↙ 提交于 2019-12-17 04:07:34
问题 I have been using iTextSharp to generate PDF documents for over a year. Unfortunately, with the release of Adobe Reader X, my PDFs now cause a "Do you want to Save?" dialog to appear when closing the PDF document. This does not happen with PDFs that are not generated with iTextSharp. It's really annoying for my users who are opening and closing PDF documents all day long. Are there any properties in iTextSharp that I can set to prevent this from happening? If it helps, I am using a PdfReader

Generate a PDF that automatically prints

和自甴很熟 提交于 2019-12-17 02:32:00
问题 I have a ASP.NET Web application that generates a PDF. I am using iTextSharp. What happens is that you click a button and it downloads. My employer want to be able to click the button and have it open with the print dialog. 回答1: Method 1: Using embedded javascript inside your PDF files You can try creating an iText PDFAction object with a javascript call this.print(false) (you can use new PdfAction(PdfAction.PRINTDIALOG) for this), and associate it with the OpenAction event of your pdf file.

Can I replicate the table header when a table keep on in more pages?

蹲街弑〆低调 提交于 2019-12-16 18:03:38
问题 I have the following situation creating a PDF with iTextSharp. I have some pages that contains some tables. It could be happen that a table begin in a page and keep on in the following page. I want to know if, when a table keep on in the following page, is it possible to "replicate" the table header in the new page. For example if a table begin in the page 1 and keep on in the table 2 I want have the following situation: The table begin with its header in page 1 and keep on in page 2 so at

How to change the check type for checkbox in ITextSharp

不羁岁月 提交于 2019-12-14 03:25:34
问题 I want to use a cross instead of a tick on my check-box. 回答1: You can change it by setting the CheckType field. myRadioCheckField.CheckType = RadioCheckField.TYPE_CROSS; You can check the other types available here. 来源: https://stackoverflow.com/questions/9684865/how-to-change-the-check-type-for-checkbox-in-itextsharp

description on each constans specified in pdfname, since i need to be able to retrieve both images and text at the same time

天大地大妈咪最大 提交于 2019-12-13 22:04:46
问题 i am having a trouble in retrieving images and text in a pdf file at the same, i was able to get images and text in a pdf file but not at the same time (this will cause a question of whether to render the image first or the text first for example in my panel control?), maybe if you guys can help me define what does each constants in pdfname means? i tried using pdfname.all but it returns null, but when using pdfname.resources it returns procset, font and xobject. i used xobject for image, but

iText stamp image on top not always working

孤街醉人 提交于 2019-12-13 20:06:04
问题 I am using iTextSharp to place an image and some text on every page of a PDF. This works perfectly for some PDF's but not for others. Strangely enough it does not work for instance on a PDF I created with Word 2010's 'Save as pdf' function. I use GetOverContent, which should everything on top. With Acrobat I can see that my layer has been added. So it must be under the word text somewhere. How can I set a z-index for my stamp? And is there a way (tool) to see clearly what objects are in a PDF

Replacing HTMLWorker with XML Worker in iTextSharp

倖福魔咒の 提交于 2019-12-13 19:09:20
问题 Currently I'm using this code : StyleSheet css = new StyleSheet(); using (var htmlViewReader = new StringReader(htmlText)) { using (var htmlWorker = new HTMLWorker(pdfDocument)) { css.LoadStyle("body", "style", "width: 100%;"); // css.LoadStyle(".fr", "style", "float: right;"); css.LoadStyle("fr","float","right"); css.LoadStyle(".fl", "style", "float: left; width: 20%;"); css.LoadStyle("container", "style", "width: 960px; margin: 0 auto;"); css.LoadStyle("header", "style", "margin-top: 75px;