itextsharp

having issue with attaching the PDF file from memory stream using ITextSharp

我只是一个虾纸丫 提交于 2019-12-07 19:17:09
问题 I am having problem with attaching the PDF file created in-memory and attaching it to email template. email goes without any problem..BUT there is no attachment. I don't understand why this is happening. here is the complete code for the process. ExtendedEmailTemplate emailTemp = new ExtendedEmailTemplate(); emailTemp.FromAddress = "ABC Ltd <info@abcTechnology.com>"; emailTemp.ToAddress = custEmail; emailTemp.Body = "This is an Test Email" emailTemp.IsHTML = true; // getting the memorystream

Setting the background color of a contentbyte itextsharp

旧时模样 提交于 2019-12-07 17:38:32
MVC3 VB.NET application using Itextsharp. I have a section of code that generates a pdf file everything looks great but I would like to alternate the line colors in that pdf file between 2 color so that the values are easy to follow for the person looking at it. Is there a way to set the background color of a whole line based on font size to a set color? A function I would be using this in is below: For Each _reg_ In _reg Dim _registrant As reg_info = _reg_ If y_line1 <= 30 Then doc.NewPage() _Page = _Page + 1 y_line1 = 670 End If If y_line1 = 670 Then cb.BeginText() cb.SetFontAndSize(BF_Times

How can I crop the PDF page

Deadly 提交于 2019-12-07 17:12:25
问题 Can any one help me that how can I cut the PDF page like as Acrobat professional? 回答1: This snippet might help you: public static void CropDocument(string file, string oldchar, string repChar) { int pageNumber = 1; PdfReader reader = new PdfReader(file); iTextSharp.text.Rectangle size = new iTextSharp.text.Rectangle( Globals.fX, Globals.fY, Globals.fWidth, Globals.fHeight); Document document = new Document(size); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(file.Replace

iTextSharp does not render Custom urdu font

北城以北 提交于 2019-12-07 17:12:16
问题 I am using custom Urdu Font Jameel Noori Nastaleeq with iTextSharp but it is not showing text at all. It shows text when I use built-in forms like times.ttf etc. Code is given below: private void button1_Click(object sender, EventArgs e) { Document document = new Document(); try { PdfWriter writer = PdfWriter.GetInstance(document, new System.IO.FileStream("C:\\iTextSharpHelloworld.pdf", System.IO.FileMode.Create)); document.Open(); string fontpath = Environment.GetEnvironmentVariable(

ItextSharp doesn't display Japanese font

三世轮回 提交于 2019-12-07 17:09:06
问题 iTextSharp doesn't display Japanese font. I found a solution but when I compile, I get an error saying: Font 'STSong-Light' with 'UniGB-UCS2-H' is not recognized. Here's my source code: BaseFont.AddToResourceSearch(serverPath + "\\lib\\iTextAsian.dll"); BaseFont.AddToResourceSearch(serverPath + "\\lib\\iTextAsianCmaps.dll"); BaseFont font = BaseFont.CreateFont("STSong-Light", "UniGB-UCS2-H", BaseFont.EMBEDDED); using (Document document = new Document()) { using (PdfSmartCopy copy = new

Signing PDF with a certificate in a certificate store

蹲街弑〆低调 提交于 2019-12-07 17:01:09
问题 I want to sign a PDF with a certificate in a certificate store. I am using iTextSharp and iSafePDF for singing PDFs, it works OK when I sign using a certificate stored as .p12 file. But I don't know how to use the library for signing with certificates obtained from a certificate store. I have an instance of System.Security.Cryptography.X509Certificate2, but the library uses a different object representation and I was not able to make it work. Can someone help? 回答1: OK, here is exactly what I

Create local link in rotated PdfPCell in iTextSharp

爱⌒轻易说出口 提交于 2019-12-07 15:50:26
问题 I'm trying to put a link to another page in my pdf using iTextSharp. link in rotated cell is not working. other cells work as expected: FileStream fs = new FileStream("TestPDF.pdf", FileMode.Create, FileAccess.Write, FileShare.None); Document doc = new Document(); PdfWriter writer = PdfWriter.GetInstance(doc, fs); doc.Open(); PdfPTable linkTable = new PdfPTable(2); PdfPCell linkCell = new PdfPCell(); linkCell.HorizontalAlignment = Element.ALIGN_CENTER; linkCell.Rotation = 90; linkCell

How do I insert a table into a PDF document with iTextSharp?

ε祈祈猫儿з 提交于 2019-12-07 15:20:23
问题 I want to insert a table into my existing PDF document. I was following a post about inserting an image into a PDF but I'm getting an null reference exception error when trying to add the table. Here is my current code public static byte[] InsertTable(byte[] pdf, DataTable dt, int pageNum, int x, int y, int columns, int rows, int[] columnWidths, float rowHeight) { using (var inputPDF = new MemoryStream(pdf)) using (var outputPDF = new MemoryStream()) { var reader = new PdfReader(inputPDF);

iTextSharp - move Acrofield

空扰寡人 提交于 2019-12-07 11:26:44
问题 I have a process that inserts a table of content into an existing Acroform, and I am able to track where I need to start that content. However, I have existing Acrofields below that point that will need to be moved up or down, based on the height of the tables I insert. With that, how can I change the position of an Acrofield? Below is code that I can use to "get" the position...but now I also need to be able to "set" it. .... // Initialize Stamper ("output" is a MemoryStream object)

How to add paragraph and then a line?

眉间皱痕 提交于 2019-12-07 11:19:41
问题 All of the examples I have seen so far using ITextSharp start from scratch and create a new document, add something to it and close it. What if I need to do multiple things to a PDF for example I want to add a paragraph and then add a line. For example if I run this simple console app in which I just create a PDF and add a paragraph and then close it everything runs fine. class Program { static void Main(string[] args) { Document pdfDoc = new Document(); PdfWriter.GetInstance(pdfDoc, new