itextsharp

VB.Net Merge multiple pdfs into one and export

☆樱花仙子☆ 提交于 2019-11-27 07:22:38
问题 I have to merge multiple PDFs into a single PDF. I am using the iText.sharp library, and collect converted the code and tried to use it (from here) The actual code is in C# and I converted that to VB.NET. Private Function MergeFiles(ByVal sourceFiles As List(Of Byte())) As Byte() Dim mergedPdf As Byte() = Nothing Using ms As New MemoryStream() Using document As New Document() Using copy As New PdfCopy(document, ms) document.Open() For i As Integer = 0 To sourceFiles.Count - 1 Dim reader As

How to create and apply redactions?

你。 提交于 2019-11-27 07:20:49
问题 Is there any way to implement PDF redaction using iText? Working with the Acrobat SDK API I found that redactions also just seem to be annotations with the subtype "Redact". So I was wondering if it's possible to create those in iTextSharp as well? With the Acrobat SDK the code would like simply like this: AcroPDAnnot annot = page.AddNewAnnot(-1, "Redact", rect) as AcroPDAnnot; (I haven't be able to apply them though as annot.Perform(avDoc) does not seem to work. Ideas?) In iTextSharp I can

How to get the UserUnit property from a PdfFile using iTextSharp PdfReader

徘徊边缘 提交于 2019-11-27 07:10:39
问题 I have a bunch of PDF files- I read these as requested into a byte array and then also pass it to a iTextSharp PdfReader instance. I want to then grab the dimensions of each page- in pixels. From what I've read so far it seems by PDF files work in points- a point being a configurable unit stored in some kind of dictionary in an element called UserUnit. Loading my PDF File into a PdfReader, what do I need to do to get the UserUnit for each page (apparently it can vary from page to page) so I

Set PDF Version using iTextSharp

陌路散爱 提交于 2019-11-27 07:08:50
问题 Anyone know how to save a PDF as a lower PDF version programmatically using iTextSharp so that you can use certain iTextSharp features that require the PDF to be version 5 or lower? I'm trying to merge two PDF version 7 documents together and it insists that they be version 5 or lower. 回答1: How odd. PDF versions are mostly a suggestion. PDFs must start with something like: %PDF-1.x Where the X is 0,1,2,... This is just a clue to the app reading the PDF. The only clue. Most "I need version X"

Bolding with Rich Text Values in iTextSharp

泪湿孤枕 提交于 2019-11-27 07:08:32
问题 Is it possible to bold a single word within a sentence with iTextSharp? I'm working with large paragraphs of text coming from xml, and I am trying to bold several individual words without having to break the string into individual phrases. Eg: document.Add(new Paragraph("this is <b>bold</b> text")); should output... this is bold text 回答1: As @kuujinbo pointed out there is the XMLWorker object which is where most of the new HTML parsing work is being done. But if you've just got simple

Hebrew text in PDF

拟墨画扇 提交于 2019-11-27 07:05:18
问题 I wrote a PDF document, and I try to write in Hebrew (UTF-8), and I can not in Windows Forms using C# and Visual Studio 2010 using the following code. Document Doc = new Document(PageSize.LETTER); //Create our file stream using (FileStream fs = new FileStream("C:\\Users\\moshe\\Desktop\\Test18.pdf", FileMode.Create, FileAccess.Write, FileShare.Read)) { //Bind PDF writer to document and stream PdfWriter writer = PdfWriter.GetInstance(Doc, fs); //Open document for writing Doc.Open(); //Add a

PdfPTable as a header in iTextSharp

假如想象 提交于 2019-11-27 07:04:05
问题 I need a table with about 12 cells to display as a header. The following code fails to do this. I am aware table2 does not have 12 cells. On the second page, only "testing" is displayed. What am I missing? Thanks in advance! Document document = new Document(); try { PdfWriter.GetInstance(document, new FileStream("TableTest.pdf", FileMode.Create)); document.Open(); PdfPTable table = new PdfPTable(1); table.WidthPercentage = 100; PdfPTable table2 = new PdfPTable(2); //logo PdfPCell cell2 = new

itextSharp - html to pdf some turkish characters are missing

烂漫一生 提交于 2019-11-27 06:33:15
问题 When I am trying to generate PDF from HTML, some Turkish characters like ĞÜŞİÖÇ ğüşıöç are missing in PDF, I see a space in place of these characters but i want to print that character. My code is: public virtual void print pdf(string html, int id) { String htmlText = html.ToString(); Document document = new Document(); string filePath = HostingEnvironment.MapPath("~/Content/Pdf/"); PdfWriter.GetInstance(document, new FileStream(filePath + "\\pdf-"+id+".pdf", FileMode.Create)); document.Open(

PDF Convert to Black And White PNGs

こ雲淡風輕ζ 提交于 2019-11-27 06:29:35
问题 I'm trying to compress PDFs using iTextSharp. There are a lot of pages with color images stored as JPEGs (DCTDECODE)...so I'm converting them to black and white PNGs and replacing them in the document (the PNG is much smaller than a JPG for black and white format) I have the following methods: private static bool TryCompressPdfImages(PdfReader reader) { try { int n = reader.XrefSize; for (int i = 0; i < n; i++) { PdfObject obj = reader.GetPdfObject(i); if (obj == null || !obj.IsStream()) {

iTextSharp Re-use Font Embedded In Acrofield

若如初见. 提交于 2019-11-27 06:26:43
问题 There are tips in "iText In Action" that cover setting fonts, as well as the "FontFactory.RegisterDirectories" method (which is, as the book says...an expensive call). However, in my case, the font that I want to use for new fields is already embedded in the document (in an existing Acrofield). With no guarantee that the same font will exist on the user's machine (or on a web server)....is there a way that I can register that already-embedded font, so that I can re-use it for other objects?