itextsharp

iTextSharp copy document, resize to custom size, and center

可紊 提交于 2019-12-11 19:19:21
问题 I've been struggling with this for awhile so thought I would post this for any gurus who might be able to knock out a solution. I have a PDF document that I'd like to copy and when I copy it I would like to resize the pages to custom size. For example, the original document has a page size of 8 1/2 x 16. The new document needs to be 8 1/2 by 22. The 8 1/2 in the new doc comes from the width of the original; the 22 is fixed (constant). What complicates the issue is that the new doc needs to

Store large hidden text/string to a PDF using iTextSharp

不羁的心 提交于 2019-12-11 19:01:57
问题 I want to store a large string in PDF document somewhere hidden. Right now I have a hidden text field in which I am writing that text. The problem is that when the string size increased upto 10MB I start getting OutOfMemory errors. What will be the best way to store some large hidden string/text to PDF document using iTextSharp ? That text/string should be retrieved later as well. 回答1: Such private data can be stored in PieceInfo dictionaries, also cf. David's answer to the OP's follow-up

How I can use a html file with styles for creat a pdf file with iTextSharp

北城以北 提交于 2019-12-11 19:00:03
问题 Hi I want to create a pdf in my ASP.NET Application and for this I use iTextSharp . My idea is it to create a pdf out of a HTML file. I want that if I click on a Button I read a HTML file with a background-image and much styles. My Application must do.. Read a HTML file from the Folder App.Data . (using System.IO) Create a PDF out of this HTML file with this styles! ( using iTextSharp.text; using iTextSharp.text.pdf; ) 3.send the PDF file as email. (using System.Net.Mail;using System.Net.Mime

itextsharp: pdfptables are running into each other

谁说我不能喝 提交于 2019-12-11 18:39:12
问题 Does anyone know why my tables are lapping over each other? Dim datatable As PdfPTable = New PdfPTable(4) Dim page As Rectangle = document.PageSize datatable.TotalWidth = page.Width - document.LeftMargin - document.RightMargin datatable.DefaultCell.Border = 0 Dim datatable1 As PdfPTable = New PdfPTable(4) datatable1.TotalWidth = page.Width - document.LeftMargin - document.RightMargin datatable1.DefaultCell.Border = 0 Dim datatable2 As PdfPTable = New PdfPTable(4) datatable2.TotalWidth = page

Itextsharp make footer stick at bottom of every pdf page

烈酒焚心 提交于 2019-12-11 18:34:36
问题 Hello and thanks for reading this post. I'm using ItextSharp to create a pdf with content from my database but thats not the important part. My footer stick the bottom of every page except the last page because there might not be enought content to "push" it down. Document ResultPDF = new Document(iTextSharp.text.PageSize.A4, 25, 10, 20, 30); PdfWriter Write = PdfWriter.GetInstance(ResultPDF, new FileStream(Server.MapPath("~") + "/PDF/" + fileName, FileMode.Create)); ResultPDF.Open();

Can i break Adobe PDF password encryption with RC4/AES 128bits?

送分小仙女□ 提交于 2019-12-11 18:21:56
问题 I've encrypted some pdf files with iTextsharp lib and using AES 128bits and key length = 16bytes(protect reading).Can anyone break password or some app can do that? Thank so much. 回答1: You can set 2 kinds of possible "passwords" here: Read password Edit/Modify password Using an "edit password" is not secure at all, because it's possible to read the whole file (even without knowing the password, by using PdfReader.unethicalreading = true; ) and then creating a new unencrypted one: using System

iTextSharp .Net DLL included as “embedded resource” does not work

怎甘沉沦 提交于 2019-12-11 18:14:35
问题 I followed the instructions at VB.NET embedded DLL in another DLL as embedded resource? to implement three dlls as embedded resource in my VB.NET project. Two dlls are made with 100% managed code, they are loaded at runtime and work perfectly, however only "iTextSharp.dll" (http://sourceforge.net/projects/itextsharp/) does not load when requested from the assembly, besides I don't know if it's a managed DLL or not. Any suggestion will be very appreciated. 来源: https://stackoverflow.com

How to truly crop a PDF file?

早过忘川 提交于 2019-12-11 18:05:25
问题 I am trying to extract and save a certain portion of a PDF file using specific coordinates (x,y,w,h). I am using the following code, which seems to be working okay: Function CroppedPdf(Source As Byte(), PageNumber As Integer, Rect As System.Drawing.Rectangle) As MemoryStream Dim reader As New PdfReader(Source) Dim h = reader.GetPageSize(1).Height Dim document = New iTextSharp.text.Document(New iTextSharp.text.Rectangle( Rect.Right / 300 * 72, h - (Rect.Top / 300 * 72), Rect.Left / 300 * 72, h

iTextSharp is giving me the error: “PDF header signature not found”

荒凉一梦 提交于 2019-12-11 17:54:02
问题 Everything I have read about this error says the file must be missing a "%PDF-1.4" or something similar at the top; however, my file includes it. I am not an expert in PDF formatting, but I did double check that I don't have multiple %%EOF or trailer tags, so now I'm at a loss as to what is causing my PDF header signature to be bad. Here is a link to the file if you would like to look at it: Poorly formatted PDF Here is what I'm doing. I am getting each page of the PDF in the form of a

Generating PDF byte array

↘锁芯ラ 提交于 2019-12-11 16:48:20
问题 I have a static method like this and I am using ITextSharp to generate PDF.. public static byte[] createPDF(string htmlstr) { var html = @"<?xml version=""1.0"" encoding=""UTF-8""?> <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd""> <html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""en"" lang=""en""> <head> <title>Minimal XHTML 1.0 Document with W3C DTD</title> </head> <body> " + htmlstr + "</body></html>"; // step 1: