itextsharp

iTextSharp creation of a pdf from a list of byte arrays

 ̄綄美尐妖づ 提交于 2019-11-29 01:26:01
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(MemoryStream ms = new MemoryStream()) { Document doc = new Document(); doc.Open(); PdfCopy copy = new

iTextSharp HTMLWorker ParseHTML Tablestyle and PDFStamper

≯℡__Kan透↙ 提交于 2019-11-29 00:46:58
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 HTMLWorker at once. HTMLWorker needs a Document which implements iDocListener ... but that doesnt seem

checking if pdf is password protected using itextsharp

不羁岁月 提交于 2019-11-29 00:35:56
I want to check if a pdf file is password protected or not to view. That is i want to know if the pdf file has user password or not. I found some help in some forum about it to use isencrypted function but it does not give correct answer. Is it possible to check if a pdf is password protected? The problem with using the PdfReader.IsEncrypted method is that if you attempt to instantiate a PdfReader on a PDF that requires a password - and you don't supply that password - you'll get a BadPasswordException . Keeping this in mind you can write a method like this: public static bool

Barcode with Text Under using ItextSharp

时光怂恿深爱的人放手 提交于 2019-11-28 23:50:25
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); Prashant This is code I found while searching the net. Hope this solves your problem: string prodCode = context.Request.QueryString.Get("code"); context.Response

how to set width for PdfPCell in ItextSharp

早过忘川 提交于 2019-11-28 21:19:24
i want set width for PdfpCell in Table, i want design this i Write this code PdfPCell cell; PdfGrid tableHeader; PdfGrid tmpTable; PdfGrid table = new PdfGrid(numColumns: 1) { WidthPercentage = 100, RunDirection = PdfWriter.RUN_DIRECTION_LTR, ExtendLastRow = false }; string imagepath2 = HttpRuntime.AppDomainAppPath + "Header.JPG"; cell = new PdfPCell() { Border = 0, RunDirection = PdfWriter.RUN_DIRECTION_RTL }; cell.Image = iTextSharp.text.Image.GetInstance(imagepath2); table.AddCell(cell); tableHeader = new PdfGrid(numColumns: 10); tableHeader.RunDirection = PdfWriter.RUN_DIRECTION_LTR;

Embedding DLL's into .exe in in Visual C# 2010

百般思念 提交于 2019-11-28 20:42:58
I'm working on a C# program that uses iTextSharp.dll and WebCam_Capture.dll. When I build the program, it creates executable in the debug folder and it also copies these two dll's to the debug folder as expected. I want to merge them into a single executable, however I failed. These two libraries are visible in the references normally in the solution explorer. I also add them as resources. Executable size got bigger which equals the sum of three files, nevertheless the executable still requires these libraries in its directory... I played with "build action" property of the resource files but

How to convert pdf Byte[] Array to downloadable file using iTextSharp

左心房为你撑大大i 提交于 2019-11-28 20:33:25
Hei guys I have this byte array i want to convert to pdf and make it available for download. Anybody has any idea how this is done? here is my Action Controller public ActionResult DownloadLabTestResult(string labTestResultID) { PdfReader pdfReader = new PdfReader("Xue_Tang.pdf"); MemoryStream stream = new MemoryStream(); PdfStamper stamper = new PdfStamper(pdfReader, stream); pdfReader.Close(); stamper.Close(); stream.Flush(); stream.Close(); byte[] pdfByte = stream.ToArray(); // So i got the byte array of the original pdf at this point. Now how do i convert this // byte array to a

.Net Core 遇到 “\'windows-1252\' is not a supported encoding name.”

拜拜、爱过 提交于 2019-11-28 19:32:24
最近用 iTextSharp 拆分 Pdf 文档 加水印的时候遇到错误: 'windows-1252' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. Parameter name: name 需要在 NuGet 里添加 System.Text.Encoding.CodePages 然后在程序里注册下就可以了 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); iTextSharp 还是很好用的 就是不能 Pdf 转图片或生成缩略图… 来源: https://www.cnblogs.com/sun8134/p/11423388.html

Generate PDF based on HTML code (iTextSharp, PDFSharp?)

眉间皱痕 提交于 2019-11-28 18:49:19
Does the library PDFSharp can - like iTextSharp - generate PDF files * take into account HTML formatting * ? (bold (strong), spacing (br), etc.) Previously I used iTextSharp and roughly handled in such a way (code below): string encodingMetaTag = "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"; string htmlCode = "text <div> <b> bold </ b> or <u> underlined </ u> <div/>"; var sr = new StringReader (encodingMetaTag + htmlCode); var pdfDoc = new Document (PageSize.A4, 10f, 10f, 10f, 0f); var = new HTMLWorker htmlparser (pdfDoc); PdfWriter.GetInstance (pdfDoc,

How can I convert image url to system.drawing.image

蹲街弑〆低调 提交于 2019-11-28 17:51:20
I'm using VB.Net I have an url of an image, let's say http://localhost/image.gif I need to create a System.Drawing.Image object from that file. Notice save this to a file and then open it is not one of my options also i'm using ItextSharp here is my code : Dim rect As iTextSharp.text.Rectangle rect = iTextSharp.text.PageSize.LETTER Dim x As PDFDocument = New PDFDocument("chart", rect, 1, 1, 1, 1) x.UserName = objCurrentUser.FullName x.WritePageHeader(1) For i = 0 To chartObj.Count - 1 Dim chartLink as string = "http://localhost/image.gif" x.writechart( ** it only accept system.darwing.image **