itextsharp

iTextSharp writer.AddDirectImageSimple throws exception

﹥>﹥吖頭↗ 提交于 2019-12-13 02:57:29
问题 What could be the problem for writer to throw an error, when the code seems correct? Image also exists. var img2 = iTextSharp.text.Image.GetInstance("C:\\2.bmp"); writer.AddDirectImageSimple(img2); at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at iTextSharp.text.pdf.PdfWriter.AddDirectImageSimple(Image image, PdfIndirectReference fixedRef) at iTextSharp.text.pdf.PdfWriter.AddDirectImageSimple(Image image) 回答1: That's not how

UserControl Export GridView to PDF

二次信任 提交于 2019-12-13 02:57:16
问题 I have a UserControl and I'm trying to export my GridView table to a PDF. I am able to do a CSV file just fine, but I get errors when trying to do a PDF. (I am using iTextSharp Library) This is the error I'm getting: "Control 'DoNotAddList_1_GridView1' of type 'GridView' must be placed inside a form tag with runat=server." I have a form tag in my html, and I tried adding it in the ascx file but nothing works. I've found many people getting this error and most everyone suggested adding this to

How to get the font name of Text from a PDF?

不想你离开。 提交于 2019-12-13 02:48:10
问题 I am looking to extract all different font names of the text in PDF file. I am using iTextSharp DLL, and below given is my code. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using iTextSharp.text.pdf.parser; using iTextSharp.text.pdf; namespace GetFontName { class Program { static void Main(string[] args) { PdfReader reader = new PdfReader("C:/Users/agnihotri/Downloads/Test.pdf"); HashSet<String> names = new HashSet<string

Parse a persian pdf file to txt and its images

时光总嘲笑我的痴心妄想 提交于 2019-12-13 02:15:38
问题 I used this code for convert a English pdf and it work perfectly, but when i use it for Persian file, its output has no Persian character !! how i can parse a Unicode pdf to a text file and a folder contains image files? using System; using System.IO; using iTextSharp.text.pdf; using System.Text.RegularExpressions; namespace Spider.Utils { /// <summary> /// Parses a PDF file and extracts the text from it. /// </summary> public class PDFParser { /// BT = Beginning of a text object operator ///

How can I make a file generated on a web page available to the user as a download?

a 夏天 提交于 2019-12-13 01:53:42
问题 This question is related to one I asked here on "How can I prompt the user for a save location from a Sharepoint page?" What I need to do is, after generating a PDF thus: private void GeneratePDF(List<ListColumns> listOfListItems) { . . . //Create a stream that we can write to, in this case a MemoryStream StringBuilder sb = new StringBuilder(); using (var ms = new MemoryStream()) { using (var doc = new Document(PageSize.A4, 25, 25, 10, 10)) { //Create a writer that's bound to our PDF

Split PDF form into pages preserving fields

二次信任 提交于 2019-12-13 01:47:06
问题 I'm using iTextSharp to split a multipage AcroForms into singe pages AcroForm but I'm not able to 'preserve' the complete functionality of the form: This's the code I'm using: using (PdfReader reader = new PdfReader(options.InputFile)) { string basename = Path.GetFileNameWithoutExtension(options.InputFile); for (int pagenumber = 1; pagenumber <= reader.NumberOfPages; pagenumber++) { string filename; Document document; PdfCopy copy; document = new Document(); filename = String.Format("{0}.{1}

How to use iTextSharp to populate radio button

冷暖自知 提交于 2019-12-13 01:31:40
问题 I have a table and one of the column is YesNo which is of type varchar(3) . I have two radio buttons in my PDF file which is in an array: pg1rb (radio group field) --> c1 (radio button one (yes)) --> c2 (radio button two (no)) I set textboxes like this in my code: formFieldMap["topmostSubform[0].Page1[0].f1_01_0_[0]"] = reader.GetValue(0).ToString(); How can I select YES or NO radio button based on the row value? Can I do something like this: formFieldMap["pg1rb"] = reader.GetBoolean(10); /

ShiftPageNumbers with iTextSharp

折月煮酒 提交于 2019-12-13 01:24:32
问题 I'm having some trouble using iTextSharp to merge some PDFs while preserving the bookmarks. I've written the following hackish code to test an idea, but the ShiftPageNumbers method doesn't seem to even be working for me. Does anyone have any idea why? string[] files = Directory.GetFiles(folder); string path = Path.GetDirectoryName(files[0]); IList<Dictionary<string, object>> oldBookmarks = SimpleBookmark.GetBookmark(new PdfReader(files[0])); List<Dictionary<string, object>> newBookmarks = new

PDF Found but failed to open for iTextSharp

為{幸葍}努か 提交于 2019-12-13 00:45:04
问题 I am using iTextSharp and the below code worked up to last week so I am stumped, I suspect an iTextSharp update. PDF file is found but then will not open for editing.. Error line (full error at the bottom): If System.IO.File.Exists(sourceFile) Then ' found here reader = New iTextSharp.text.pdf.PdfReader(sourceFile) 'fails here, see error at bottom of query Sourcefile is from the same website: www.website.com/folder/pdftest.pdf and I have tried local as well i.e. c:'... pdftest.pdf All code:

Insert PieceInfo in merged document with ITextSharp

拈花ヽ惹草 提交于 2019-12-13 00:45:02
问题 I have a process that merge several PDFs into a single PDF. This is working great. At the time of the merge, I want to add a PieceInfo at page level to track the documents that were included into that merged file. Let's say I have 3 documents in this order: Fester.pdf (2 pages), Gomez.pdf (2 pages) and Lurch.pdf (1 page). After the merge I will have 5 pages and each page would have a PieceInfo with the file name that was originated from. This way, if I go to page 4, I will know the page was