itextsharp

Get exact cordinates of the page to add a watermark with different page rotation using iTextSharp

旧巷老猫 提交于 2019-12-12 01:42:50
问题 I have been trying to position a Text Water marks on PDF file using iTextSharp and i am struggling to find the coordinates on each page. it works fine when all the pages in pdf file are of same rotation but if the rotation is different then the coordinates are completely different. PdfImportedPage page = stamper.GetImportedPage(pdfReader, i); var rotationValue = page.Rotation; and to add the watermark cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "This is WaterMark 1", 20, 20, 90f); this code

Backgroundimage in landscape and cover whole pdf with iTextSharp

感情迁移 提交于 2019-12-12 01:05:15
问题 I have a image, that i like to use as a background on my pdf. My pdf is in LANDSCAPE, so the background image must fit into my landscape pdf. How can i do that? This is my code, but the image doesnt show right in landscape :( string imageFilePath = Server.MapPath(".") + "/images/test.jpg"; iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageFilePath); Document pdfDucment = new Document(new Rectangle(288f, 144f), 10, 10, 10, 10); pdfDucment.SetPageSize(iTextSharp.text.PageSize

Itextsharp export to pdf NullReferenceException

点点圈 提交于 2019-12-12 00:32:22
问题 I am trying to export the aspx page to pdf. I am using this code on Button2_Click, but i take a System.NullReferenceException on htmlworker.Parse(str);: string attachment = "attachment; filename=Article.pdf"; Response.ClearContent(); Response.AddHeader("content-disposition", attachment); Response.ContentType = "application/pdf"; StringWriter stw = new StringWriter(); HtmlTextWriter htextw = new HtmlTextWriter(stw); dvText.RenderControl(htextw); Document document = new Document(); PdfWriter

Replace the text in pdf document using itextSharp

自作多情 提交于 2019-12-12 00:28:46
问题 I want to replace a particular text in PDF document. I am currently using itextSharp library to play with PDF documents. I had extracted the bytes from pdfdocument and then replaced that byte and then write the document again with the bytes but it is not working. In the below example I am trying to replace string 1234 with 5678 Any advise on how to perform this would be helpful. PdfReader reader = new PdfReader(opf.FileNames[i]); byte[] pdfbytes = reader.GetPageContent(1); PdfString oldstring

Using ContentByteUtils for raw PDF manipulation

大兔子大兔子 提交于 2019-12-12 00:24:09
问题 This is a follow up question to: Programmatically change the color of a black box in a PDF file? I have a pdf I created in Illustrator that has basically a black shape in the middle of the page and nothing else. I need to change the color of that shape dynamically. From the response to the post above I am using iTextSharp (.NET C#) to get the raw contents of the PDF through ContentByteUtils.GetContentBytesForPage() and changing the color at the raw level. Problem is that I can't find any way

How can I prompt the user for a save location from a Sharepoint page?

混江龙づ霸主 提交于 2019-12-12 00:14:42
问题 I have a related question here, where I was trying to create a link to the location of the saved file (where the location and filename are taken care of for the user). Unfortunately, the link won't open the file, due to path access denial (as described in Update 4 in the link above). What I really would rather do, if possible, is prompt the user for a save location (without requiring them to enter into an input text element something like "C:\Bla\Blee"); I don't think, though, that the tried

How to create nested column using itextsharp?

狂风中的少年 提交于 2019-12-11 23:55:49
问题 How can I create a table mentioned below,using iext sharp. Below is my code but I am stuceked. Help me to make such a type table. My code var subTable2 = new PdfPTable(new float[] { 100, 100, 100, 100, 100, 100,100,100 }); subTable2.TotalWidth = 510f; subTable2.LockedWidth = true; subTable2.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; subTable2.AddCell(new Phrase("Examination", time51)); subTable2.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; subTable2.AddCell(new Phrase(

GdiCharSet & iTextSharp

冷暖自知 提交于 2019-12-11 23:43:05
问题 Is there the way to create iTextSharp font using additional info (such as gdiCharSet etc) from System.Drawing.Font object? 回答1: Short answer: Yes. Long answer: Each attribute is a bit different, but all that information can be expressed within PDF in general, and iText[Sharp] in specific. You can specify a font's encoding when you create it, but you must do so in a way iText understands. Specifically, encoding values are strings within iText[Sharp]. BaseFont has a number of public static

itextSharp acrofields format as Number

戏子无情 提交于 2019-12-11 22:29:53
问题 I use ITextSharp from c# code. I use acrofields to populate a form with data. I am just learnt how to format percentage. Next I need to learn how to format numbers. Stream os = new FileStream(PDFPath, FileMode.CreateNew); PdfReader reader = new PdfReader(memIO); PdfStamper stamper = new PdfStamper(reader, os, '9', true); AcroFields fields = stamper.AcroFields; fields.SetField("Pgo", "1.0", "100%"); // Works fine fields.SetField("value", "1217000.000000", "$1,217,000"); // Drops Dollar sign

iTextSharp error document has no page before open it

旧街凉风 提交于 2019-12-11 22:13:28
问题 I've a problem, i want to add an header and a footer into me pdf document. For that, i used to PdfPageEventHelper. i've created a class : public class PDFFooter : PdfPageEventHelper { // write on top of document public override void OnOpenDocument(PdfWriter writer, Document document) { base.OnOpenDocument(writer, document); } // write on start of each page public override void OnStartPage(PdfWriter writer, Document document) { base.OnStartPage(writer, document); EnTeteDePage(document); } //