itextsharp

iTextSharp - Using PDFAction.GotoLocalPage in Merged PDF

余生颓废 提交于 2019-12-02 04:34:07
I have written some code that merges together multiple PDF's into a single PDF that I then display from the MemoryStream. This works great. What I need to do is add a table of contents to the end of the file with links to the start of each of the individual PDF's. I planned on doing this using the GotoLocalPage action which has an option for page numbers but it doesn't seem to work. If I change the action to the code below to one of the presset ones like PDFAction.FIRSTPAGE it works fine. Does this not work because I am using the PDFCopy object for the writer parameter of GotoLocalPage?

ItextSharp with PowerShell Merging Tiff and PDF to 1 large PDF

我们两清 提交于 2019-12-02 04:30:59
I'm trying to write a powershell script that will loop through a csv file looking for Tiff & PDF files using ItextSharp dll. The desired end result is every image and page of a pdf needs to be in one large pdf. My thoughts are to create two functions to accomplish this. 1 for images and the other for PDF's. The image function is working properly, but the pdf is throwing a error: Exception calling ".ctor" with "1" argument(s): " not found as file or resource." Any thoughts on fixing add-pdf function? Current script is below. [System.Reflection.Assembly]::LoadFrom("C:\Temp\itextsharp`enter code

Bookmark to specific page using iTextSharp 4.1.6

删除回忆录丶 提交于 2019-12-02 04:20:34
问题 I want to add a bookmark pointing to a specific page within a document. Adding bookmarks from other PDF files I'm merging with code similar to that below works fine, but when I copied it to add custom bookmarks to non-bookmarked items it fails: var bookmarks = new ArrayList(); var writer = new PdfCopy(document, memorystream); // ... var uni = new Hashtable(); uni.Add("Action", "GoTo"); uni.Add("Title", "Awesome Unicorn pic"); uni.Add("Page", "8 XYZ 0 0 0"); bookmarks.Add(uni); // ... writer

C# iTextSharp - Code overwriting instead of appending pages

安稳与你 提交于 2019-12-02 04:18:23
I've seen many posts that have helped me get to where I am, I'm new to programming. My intention is to get the files within the directory "sourceDir" and look for a Regex Match. When it finds a Match, I want to create a new file with the Match as the name. If the code finds another file with the same Match (the file already exists) then create a new page within that document. Right now the code works, however instead of adding a new page, it overwrites the first page of the document. NOTE: Every document in the directory is only one page! string sourceDir = @"C:\Users\bob\Desktop\results\";

Pdf Merge Issue in ItextSharp (After Merging Pdfs don't retain their Values)

非 Y 不嫁゛ 提交于 2019-12-02 04:12:16
问题 We are trying to merge three PDFs using ITextSharp. The problem is after merging we are able to get Data from the first PDF only, while the other two PDFs don't retain their values. All these PDFs have the same structure (i.e. they use the same templates with different data), so my assumption is they are having same fields (AcroFields) which may be creating this problem while merging. Here is the merge code : public void MergeFiles(string destinationFile, string[] sourceFiles) { try { int f =

Maintain similar image size in PDF using itextsharp

*爱你&永不变心* 提交于 2019-12-02 03:57:24
i'm using itextsharp to bring my picture over to the pdf file. I uses chunk. However when i uses the chunk new line, my image changes it size despite me putting the same scaletofit. protected void btnPDF_Click(object sender, EventArgs e) { var doc1 = new Document(); var filename = "MyTestPDF" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".pdf"; var output = new FileStream(Path.Combine("C:\\Users\\apr13mpsip\\Downloads", filename), FileMode.Create); iTextSharp.text.pdf.PdfWriter.GetInstance(doc1, output); doc1.Open(); PdfPTable table = new PdfPTable(1); table.TotalWidth = 585f; table

Namespace for using iTextSharp CSSResolver classes

半城伤御伤魂 提交于 2019-12-02 03:39:26
问题 I am using iTextSharp CSSResolver classes for using external css in vb.net Please let me know the namespaces for using XMLWorkerFontProvider , CssFilesImpl , StyleAttrCSSResolver classes. Below is my code: Dim fontProvider As XMLWorkerFontProvider = New XMLWorkerFontProvider() Dim cssFiles As CssFilesImpl = New CssFilesImpl(fontProvider) cssFiles.Add(XMLWorkerHelper.GetInstance().GetDefaultCSS()) Dim cssRevolver As StyleAttrCSSResolver = New StyleAttrCSSResolver() Dim htmlContext As

ItextSharp - Acrofields are empty

牧云@^-^@ 提交于 2019-12-02 03:10:53
I have a PDF form with filled out fields. If I try to read the acrofields they are empty. But in the PDF I can change the values and save them. private static string GetFormFieldNamesWithValues(PdfReader pdfReader) { return string.Join("\r\n", pdfReader.AcroFields.Fields .Select(x => x.Key + "=" + pdfReader.AcroFields.GetField(x.Key)) .ToArray()); } var reader = new PdfReader((DataContext as PDFContext).Datei); AcroFields form = reader.AcroFields; txt.Text = GetFormFieldNamesWithValues(reader); How to read the fields? Clearly your PDF is broken. The fields are defined as widget annotations on

itextSharp - Merging pdf files disables extended reader permissions

谁都会走 提交于 2019-12-02 03:07:22
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 (MemoryStream ms = new MemoryStream()) { //2: Create the PdfCopyFields object. PdfCopyFields copy = new

iTextSharp pdfpTable flowing in two columns in same page

99封情书 提交于 2019-12-02 02:44:57
问题 I am using iTextSharp PdfPTtable for creating tables from a database. When the table is lengthy (long but just with 3 columns), I managed to get the table flowing (or continuing) to the next PDF page. But I want them to continue in the right side (or column) of the same page. And after that it has to continue to next page (left column and then the right column and so on...). 回答1: Your requirement is (almost) an exact match with one of the examples of my book. Please take a look at page 3 and