itextsharp

Applying style to div having a class name iTextSharp

元气小坏坏 提交于 2019-11-27 08:48:35
问题 i have defined my html string as: string html = @" <html><body> <div class='class1'>My Text</div> </body></html> "; To apply style, I am doing this StyleSheet style = new StyleSheet(); style.LoadTagStyle("class1", HtmlTags.FACE , "PATH" + "CustomFont.ttf"); This does not work. However, using this applies the font: style.LoadTagStyle(HtmlTags.DIV, HtmlTags.FACE , "PATH"+"CustomFont.ttf"); How to specify style to a particular class? I am generating pdf using iTextSharp dll. 回答1: You need to

Replace text in PDF file using iTextSharp(not AcroFields) [closed]

房东的猫 提交于 2019-11-27 08:42:55
问题 I am working on iTextSharp with asp.net C# to create PDF files. I created many reports(pdfs) using iTextSharp and all works well. Now my client gave me pre-formatted pdf file in which there are some text which need to be replaced with database values. Now I want to replace text in existing pdf file and create new one. But as I googled, it is not possible in iTextSharp. I have some questions now Is it really not possible to replace text in pdf using iTextSharp? Is there any other library or

Opening password-protected pdf file with iTextSharp

社会主义新天地 提交于 2019-11-27 08:41:39
I'm making an application that should display PDFs with password. This is my code: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { string filePath = Request.QueryString["filePath"]; if (filePath.ToUpper().EndsWith("PDF")) { copyPDF(filePath); } } catch { string message = "<script language='Javascript'>alert('File Not Found! Call Records Department for verification. ')</script>"; ScriptManager.RegisterStartupScript(Page, this.GetType(), message, message, false); } } } public void copyPDF(string filePath) { iTextSharp.text.pdf.RandomAccessFileOrArray ra = new

How to set zoom level to pdf using iTextSharp?

一个人想着一个人 提交于 2019-11-27 08:38:57
问题 I need to set the zoom level 75% to pdf file using iTextSharp. I am using following code to set the zoom level. PdfReader reader = new PdfReader("input.pdf".ToString()); iTextSharp.text.Document doc = new iTextSharp.text.Document(reader.GetPageSize(1)); doc.OpenDocument(); PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream("Zoom.pdf", FileMode.Create)); PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 0.75f); doc.Open(); PdfAction action =

PDFs generated using itextsharp giving error at the time of first print command

余生颓废 提交于 2019-11-27 08:35:41
问题 I am getting below for the first time giving print command. "An error exists on this page. Acrobat may not display the page correctly. please contact the person who created the pdf document to correct the problem". Print out is comming very fine. and Second time print out command not giving any error. Please help me why this error is comming for the first time print. This is part of my code to create PDF PdfContentByte cb = writer.DirectContent; cb.BeginText(); Font NormalFont = FontFactory

Why is my content overlapping with my footer?

走远了吗. 提交于 2019-11-27 08:30:25
问题 I am using itextsharp to generate pdf ...i m getting problem is my content/text coming upon footer...i want to automatically break down content to new page...if it comes upon footer.. right now i m using document.newpage() but i want to do it automatically that my page /content automatically breakdown to new page..it should not come to header/footer of page... FOr Information i create header/footer through this class public class ITextEvents : PdfPageEventHelper and i used this function

Read/Modify PDF Metadata using iTextSharp

随声附和 提交于 2019-11-27 08:29:40
I am trying to use iTextSharp to read/modify PDF metadata. I figured out how to do it using pdfreader and pdfstamper. I was wondering if I could also read/modify additional metadata information like copyright information and few others within the XMP photoshop namespace. I would greatly appreciate any pointers to the solution. Thank you, Murugesh. You can read metadata using `PdfReader'. I've read metadata like this: PdfReader reader = new PdfReader("HelloWorldNoMetadata.pdf"); string s = reader.Info["Author"]; You can try the iTextSharp.text.xml.xmp.XmpWriter class to write metadata. I've

Odd Numbered Cell Not Added To Pdf

孤人 提交于 2019-11-27 08:24:31
问题 I am trying to add PdfPCell inside a loop to a iTextSharp Table with 2 columns in a Document . But if the count inside the loop is an odd number. Then the last cell does not get added. Can someone please provide a solution to this problem? My code is below: var doc = new Document(); PdfWriter.GetInstance(doc, new FileStream(Server.MapPath("~/QrCodes/") + fileName + ".pdf", FileMode.Create)); doc.Open(); PdfPTable table = new PdfPTable(2); table.WidthPercentage = 100; foreach (var item in

iTextSharp Password Protected PDF

与世无争的帅哥 提交于 2019-11-27 07:41:29
The following question and answer on StackOverflow show how to generate a PDF that cannot be opened without the appropriate password. Password protected PDF using C# I would like to use this framework similarly, but slightly altered to allow my users to "open" the PDF without needing the password, but only allow them to EDIT the PDF if they have the password. Is that possible with iTextSharp? if this matters, I am working in C# 4.0 within a WF 4.0 custom activity. Yes, there are two passwords that you can pass to PdfEncryptor.Encrypt() , userPassword and ownerPassword . Just pass null to the

Render PDF in iTextSharp from HTML with CSS

只愿长相守 提交于 2019-11-27 07:27:35
Any idea how to render a PDF using iTextSharp so that it renders the page using CSS. The css can either be embedded in the HTML or passed in separately, I don't really care, just want it to work. Specific code examples would be greatly appreciated. Also, I would really like to stick with iTextSharp, though if you do have suggestions for something else, it's got to be free, open source, and have a license that permits using it in commercial software. It's not possible right now but nothing stops you from starting open-source project that will do it. I might actually start one, because I need it