itextsharp

PdfWriter.GetInstance throws System.NullReferenceException

半城伤御伤魂 提交于 2019-12-18 09:14:05
问题 I'm trying to create a pdf document using iTextSharp 5.3.4 using the following Document document = new Document(); FileStream stm = new FileStream(filename, FileMode.Create); PdfWriter writer = PdfWriter.GetInstance(document, stm); I'm getting a System.NullReferenceException with the following stack trace: System.NullReferenceException occurred HResult=-2147467261 Message=La référence d'objet n'est pas définie à une instance d'un objet. Source=itextsharp StackTrace: à iTextSharp.text.Version

add an image and it span in multiple pages using itextsharp

自作多情 提交于 2019-12-18 09:11:59
问题 How can I add a large image, that spans over in multiple PDF pages using iTextSharp. I have an image that exceeds the PDF page height and because of it, the image is not fully displaying in the PDF page. Image's last portion is missing. 回答1: Please check if this solves your issue: Document oDocument = new Document(); oDocument.Open(); PdfPTable table = new PdfPTable(1); table.WidthPercentage = 100; PdfPCell c = new PdfPCell(image, true); c.Border = PdfPCell.NO_BORDER; c.Padding = 5; c.Image

Image alignment in text?

佐手、 提交于 2019-12-18 07:35:28
问题 Using iTextSharp i'm trying to align an image so that it gets embedded in a paragraph. I can do it like this: iTextSharp.text.Image image; image.Alignment = Image.ALIGN_RIGHT | Image.TEXTWRAP; document.Add(image); document.Add(new Paragraph("Large string of text goes here")); But the image comes out on the top right with the text surrounding it (kind of like an L) What I want is the text to be a few paragraphs then the image with text below it (kind of like a C). Does anyone know how I would

PDF hostContainer callback

与世无争的帅哥 提交于 2019-12-18 05:45:10
问题 Following this SO solution here to notify clients of a click event in a PDF document, how is it possible to notify the client when the PDF gets submitted by the client using this.myPDF.submitForm("localhost/Handler.ashx?r=2) function? The PDF File is created inside a user control then rendered into a HTML object: string container = ("<object data='/myfile.pdf' type='application/pdf'></object>"); The JS file attached to the PDF is done like this: var webClient = new WebClient(); string

Extracting Additional Metadata from a PDF using iTextSharp

老子叫甜甜 提交于 2019-12-18 05:21:30
问题 I've seen the extraction of basic metadata (ie. author, title) using iTextSharp and it usually looks something like this: var pdfReader = new PdfReader(pdfData); var author = pdfReader.Info["author"] However, in my case I'm after something a bit more exotic, the additional "advanced" metadata that the document may contain. Pardon the paint highlights, but here is a screenshot from within Adobe Acrobat showing the data in question: In this case, it doesn't seem like this data is available

iTextSharp to print a gridview

亡梦爱人 提交于 2019-12-18 04:15:02
问题 I use iTextSharp to print a grid view but I face some problems: No arabic characters appears at all. The direction is LTR and I wany it RTL instead. Some columns in the gridview are templatefields (label, imagebutton,...), and I can't handle this case. I won't show all of them (like delete button , ...) The code : protected void ExportToPDF(GridView gvReport, bool LandScape) { int noOfColumns = 0, noOfRows = 0; DataTable tbl = null; if (gvReport.AutoGenerateColumns) { tbl = gvReport

Split PDF into multiple PDFs using iTextsharp

﹥>﹥吖頭↗ 提交于 2019-12-18 03:59:08
问题 public int SplitAndSave(string inputPath, string outputPath) { FileInfo file = new FileInfo(inputPath); string name = file.Name.Substring(0, file.Name.LastIndexOf(".")); using (PdfReader reader = new PdfReader(inputPath)) { for (int pagenumber = 1; pagenumber <= reader.NumberOfPages; pagenumber++) { string filename = pagenumber.ToString() + ".pdf"; Document document = new Document(); PdfCopy copy = new PdfCopy(document, new FileStream(outputPath + "\\" + filename, FileMode.Create)); document

iTextSharp creation of a pdf from a list of byte arrays

安稳与你 提交于 2019-12-18 03:17:16
问题 I've got a list of byte[] which i'd like to concatenate into one byte[] which will be the final PDf. On the "page = copy.GetImportedPage(new PdfReader(p), i); " i'm getting an "object reference not set to an instance error. I've got no clue of what's going on, i've already checked every object and there's no null. Any ideas on this, or another piece of code that could make the trick?! I've got this method: EDIT public static byte[] concatAndAddContent(List<byte[]> pdf) { byte [] todos; using

iTextSharp HTMLWorker ParseHTML Tablestyle and PDFStamper

穿精又带淫゛_ 提交于 2019-12-18 03:00:26
问题 Hi I have succesfully used a HTMLWorker to convert a gridview using asp.NET / C#. (1) I have applied some limited style to the resulting table but cannot see how to apply tablestyle for instance grid lines or apply other formatting style such as a large column width for example for a particular column. (2) I would actually like to put this text onto a pre-existing template which contains a logo etc. I've used PDF Stamper before for this but cannot see how I can use both PDFStamper and

Barcode with Text Under using ItextSharp

两盒软妹~` 提交于 2019-12-18 02:48:05
问题 I am using iTextSharp in my application to generate a barcode. Though everything is working as I wanted, I need to display the value of the barcode under the barcode like the one showin in the attached image. Below is the C# code I use: Barcode39 barcodeImg = new Barcode39(); barcodeImg.Code = barcodeValue.ToString(); barcodeImg.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White).Save(stream, ImageFormat.Png); 回答1: This is code I found while searching the net. Hope this