itextsharp

What are the ways of checking if piece of text in PDF documernt is bold using iTextSharp

↘锁芯ラ 提交于 2019-12-17 16:52:48
问题 I have an application, that extracts headings out of pdf files. The documents, that the application is supposed to work with, all have more or less coherent structure and formatting, in fact, telling if a text chunk is bold or not, is very important. Recently I came across a bunch of files, where some chunks visually appear bold, but do not have "bold" piece in string representation of font. The following SO thread how can i get text formatting with iTextSharp helped me to understand, that

How to set initial view properties?

微笑、不失礼 提交于 2019-12-17 16:21:02
问题 Here I want to set the already exist PDF document properties under Initial View tab in acrobat. Document Options: Show = Bookmarks Panel and Page Page Layout = Continuous Magnification = Fit Width Open to Page number = 1 Window Options: Show = Document Title As show in below screen shot: I am tried following code: PdfStamper stamper = new PdfStamper(reader, new FileStream(dPDFFile, FileMode.Create)); stamper.AddViewerPreference(PdfName.DISPLAYDOCTITLE, new PdfBoolean(true)); the above code is

How do I embed fonts in an existing PDF?

六眼飞鱼酱① 提交于 2019-12-17 15:47:18
问题 Background: I have PDF's I am programmatically generating. I need to be able to send the PDF directly to a printer from the server (not through an intermediate application). At the moment I can do all of the above (generate PDF, send to printer), but because the fonts aren't embedded in the PDF the printer is doing font substitution. Why the fonts aren't embedded when generated: I am creating PDF's using SQL Reporting Services 2008. There is a known issue with SQL Reporting Services in that

Why doesn't FontFactory.GetFont(“Known Font Name”, floatSize) work?

烂漫一生 提交于 2019-12-17 14:54:47
问题 If I say: var georgia = FontFactory.GetFont("Georgia Regular", 10f); it doesn't work. When I check the state of the variable georgia, it has its Family property set to the value UNDEFINED and its FamilyName property set to Unknown . It only works if I actually load and register the font file and then get it like so: FontFactory.Register("C:\\Windows\\Fonts\\georgia.ttf", "Georgia"); var georgia = FontFactory.GetFont("Georgia", 20f); Why is that? 回答1: iText is written in Java, which means it's

How can I decrypt a PDF document with the owner password? [closed]

两盒软妹~` 提交于 2019-12-17 12:30:08
问题 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 4 years ago . I need to be able to remove the security/encryption from some PDF documents, preferably with the itextsharp library. This used to be possible (How to decrypt a pdf file by supplying password of the file as argument using c#?), but a more recent change to the library means that solution no longer works. I know

How to parse multiple HTML files into a single PDF?

纵饮孤独 提交于 2019-12-17 10:01:59
问题 I want to use iText to convert a series of html file to PDF. For instance: if have these files: page1.html page2.html page3.html ... Now I want to create a single PDF file, where page1.html is the first page, page2.html is the second page, and so on... I know how to convert a single HTML file to a PDF, but I don't know how to combine these different PDFs resulting from this operation into a single PDF. 回答1: Before we start: I am not a C# developer, so I can not give you an example in C#. All

How do I enumerate all the fields in a PDF file in ITextSharp

混江龙づ霸主 提交于 2019-12-17 09:55:22
问题 Let's say I've loaded a PDF file using iTextSharp: PdfStamper p = GetDocument(); AcroFields af = ps.AcroFields; How do I get a list of all field names on the document from af ? 回答1: AcroFields af = ps.AcroFields; foreach (var field in af.Fields) { Console.WriteLine("{0}, {1}", field.Key, field.Value); } 回答2: PdfReader pdfReader = new PdfReader("c:\\ABC.pdf"); string TempFilename = Path.GetTempFileName(); AcroFields pdfFormFields = pdfReader.AcroFields; foreach (KeyValuePair<string, AcroFields

Read/Modify PDF Metadata using iTextSharp

孤者浪人 提交于 2019-12-17 09:43:29
问题 I am trying to use iTextSharp to read/modify PDF metadata. I figured out how to do it using pdfreader and pdfstamper. I was wondering if I could also read/modify additional metadata information like copyright information and few others within the XMP photoshop namespace. I would greatly appreciate any pointers to the solution. Thank you, Murugesh. 回答1: You can read metadata using `PdfReader'. I've read metadata like this: PdfReader reader = new PdfReader("HelloWorldNoMetadata.pdf"); string s

How can I flatten a XFA PDF Form using iTextSharp?

谁都会走 提交于 2019-12-17 07:53:36
问题 I assume I need to flatten a XFA form in order to display properly on the UI of an application that uses Nuance's CSDK. When I process it now I get a generic message "Please Wait.... If this message is not eventually replaced..". Looking for some sample iTextSharp code to do this. 回答1: You didn't insert a code sample to show how you are currently flattening the XFA form. I assume your code looks like this: var reader = new PdfReader(existingFileStream); var stamper = new PdfStamper(reader,

How to add a watermark to a PDF file?

不羁的心 提交于 2019-12-17 07:39:01
问题 I'm using C# and iTextSharp to add a watermark to my PDF files: Document document = new Document(); PdfReader pdfReader = new PdfReader(strFileLocation); PdfStamper pdfStamper = new PdfStamper(pdfReader, new FileStream(strFileLocationOut, FileMode.Create, FileAccess.Write, FileShare.None)); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(WatermarkLocation); img.SetAbsolutePosition(100, 300); PdfContentByte waterMark; // for (int pageIndex = 1; pageIndex <= pdfReader