itextsharp

How to get text with a certain color from a pdf c#

夙愿已清 提交于 2019-12-05 20:17:23
I have to put the data from a pdf file in a certain database structure. This requires me to be able to get certain data out of the pdf file. Since pdf hasn't got any tags etc ... i was wondering if it is possible to get text based on a color. Say for example i want all the red text. Or i want all the italic text in the document. Is this possible in C# ? Or is there an other way to easily filter data in a pdf document ? By using this library http://www.codeproject.com/KB/files/xpdf_csharp.aspx?msg=3154408 you have an access to every word style (font, color...) this.pdfDoc.Pages[4].WordList

Disable extended features with iTextSharp

北城余情 提交于 2019-12-05 19:37:25
问题 I have a PDF template with a form with the Extended features enabled. After filling in the fields of this form using iTextSharp , a user with acrobat reader gets the error message: This document enabled extended features in Adobe Reader. The document has been changed since it was created and use of extended features is no longer available. Please contact the author for the original version of this document. I googled a bit but all the posts talk about "enabling" extended features, however, I

Displaying a pdf to webpage using iTextSharp?

我怕爱的太早我们不能终老 提交于 2019-12-05 19:31:10
I am generating a pdf using iTextSharp. I would like to display it on the webpage and let the user save it from the online pdf viewer. dynamicpdf has a drawtoweb() method, but it is not free to use and I cannot find the same functionality using iTextSharp. How can I display the pdf? string newFile = "Pdf Document.pdf"; Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(newFile, FileMode.Create)); doc.AddCreator("Myself"); doc.AddTitle("Sample PDF Document"); doc.Open(); doc.Add(new Paragraph("Hello, World!")); doc.Close(); Daniel Hilgarth Is there a

itextsharp does not care my html styles

你离开我真会死。 提交于 2019-12-05 18:15:31
I create a panel in my page and i create dynamically divs and tables in page. When I convert to pdf with itextsharp it does not care my div or table styles and it gives me nasty look. How can I fix this. Here is my code to convert html. String HTML = Session["xpdf"].ToString(); string filename = "\\xpdf\\xpdf____" + Request.QueryString["id"] + ".pdf"; string filepath = HttpContext.Current.Server.MapPath("\\xpdf\\xpdf____" + Request.QueryString["id"] + ".pdf"); Document document = new Document(PageSize.A4); PdfWriter.GetInstance(document, new FileStream(filepath, FileMode.Create)); document

Define foreground color of a itextsharp table cell

房东的猫 提交于 2019-12-05 17:06:16
I have a iTextSharp.text.Table and tried to change the foreground text color. But there is no method on the Cell object to define the color. Does anybody knows, where I can adjust the color? Try the following var FontColour = new BaseColor(31, 73, 125); var MyFont = FontFactory.GetFont("Times New Roman", 11, FontColour ); table.AddCell(new Paragraph("My Text", MyFont)); CKDT LnDCobras answerworked well. My final solution is the following: Font font = new Font(Font.HELVETICA, 11, new Color(255, 0, 0)); Chunk chunk = new Chunk("my Text", font); Cell cell = new Cell(chunk); table.AddCell(cell);

How to set copyright metadata of an existing PDF using iTextSharp for C#

人盡茶涼 提交于 2019-12-05 16:26:51
How can the copyright metadata of an existing (i.e. a pdf loaded from file or memory stream) pdf file be set using iTextSharp for C#? Thanks a lot The native XMP structures don't have copyright implemented (or at least they don't in a way that Adobe Reader recognizes.) To do that you can reverse engineer what Adobe kicks out and write it manually: String inputPDF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Services.pdf"); String outputPDF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "Services_Out.pdf"); PdfReader reader = new

Using different fonts in PDF using iTextSharp and PDFStamper

南笙酒味 提交于 2019-12-05 15:27:12
I'm using iTextSharp to load an existing PDF and adding text using the PdfStamper. I want full control over the text, meaning I want to be able to control the font (only TrueType), font size and coordinates. Right now, I'm using ShowTextAligned to add text to certain coordinaties and setFontAndSize to set the font and font size. This is my code to add text: private void AddText(BaseFont font, string text, int x, int y, int size) { pdf.BeginText(); pdf.SetFontAndSize(font, size); pdf.ShowTextAligned(PdfContentByte.ALIGN_LEFT, text, x, y, 0); pdf.EndText(); } The following function is used to

How can you find a problem with a programmatically generated PDF? [closed]

╄→尐↘猪︶ㄣ 提交于 2019-12-05 13:53:22
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . My group has been using the itext-sharp library and C#/.NET to generate custom, dynamic PDFs. For the most part, this process is working great for our needs. The one problem we can run into during development/testing is layout issues which can cause the PDF to not open/render correctly in Adobe Reader, esp. the

How to make a particular sub-string Bold while printing a string in Pdf using iText in java eclipse?

北战南征 提交于 2019-12-05 13:02:09
I am using iText in Java to convert a HTML to PDF. I want a particular paragraph which has some words as Bold and some as Bold+Underlined to be passed as a string to the Java code and to be converted to PDF using the iText library. I am unable to find a suitable method for this. How should I do this? If you want to convert XHTML to PDF, you need iText + XML Worker. You can find a number of examples here: http://itextpdf.com/sandbox/xmlworker The most simple examples looks like this: public void createPdf(String file) throws IOException, DocumentException { // step 1 Document document = new

iTextSharp - move Acrofield

坚强是说给别人听的谎言 提交于 2019-12-05 12:32:10
I have a process that inserts a table of content into an existing Acroform, and I am able to track where I need to start that content. However, I have existing Acrofields below that point that will need to be moved up or down, based on the height of the tables I insert. With that, how can I change the position of an Acrofield? Below is code that I can use to "get" the position...but now I also need to be able to "set" it. .... // Initialize Stamper ("output" is a MemoryStream object) PdfStamper stamper = new PdfStamper(pdf_rdr, output); // Get Reference to PDF Document Fields AcroFields fields