itextsharp

How to get a list of the fields in an XFA form?

[亡魂溺海] 提交于 2019-11-28 07:52:38
问题 I am trying to get a simple list of all the fields in my XFA form. I am using this code: private void ListFieldNames() { string pdfTemplate = @"C:\Projects\iTextSharp\SReport.pdf"; MemoryStream m = new MemoryStream(); // title the form this.Text += " - " + pdfTemplate; // create a new PDF reader based on the PDF template document PdfReader pdfReader = new PdfReader(pdfTemplate); PdfStamper pdfStamper = new PdfStamper(pdfReader, m); AcroFields formFields = pdfStamper.AcroFields; AcroFields

iTextSharp set document landscape (horizontal) A4

做~自己de王妃 提交于 2019-11-28 07:07:51
How can I set an A4 document in landscape (horizontal) format in iTextSharp? You can set the page size to a rotated A4. E.g. (assuming PDF, but should apply regardless): iTextSharp.text.Document doc; // ...initialize 'doc'... // Set the page size doc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate()); I've done this with PDF without trouble, haven't tried it with other doc types. Alexei Bondarev You can initialize a new document like that: Document doc = new Document(iTextSharp.text.PageSize.A4.Rotate(), 10, 10, 10, 10); In this mode all pages will be in landscape mode. To change the layout of

Centered, multiline text using iTextSharp ColumnText

人走茶凉 提交于 2019-11-28 06:59:59
问题 I am trying to center a block of multiline text using iTextSharp. I thought that using the ColumnText would do the trick, but I'm having some trouble getting both center alignment, as well as proper wrapping working at the same time. Here is some code which shows the 2 methods I'm trying: private void PrintLocationAddress(PdfContentByte Canvas, string Address) { //define the regions for our ColumnText objects Rectangle rect1 = new Rectangle(150f, 300, 350f, 450f); Rectangle rect2 = new

Itextsharp text extraction

▼魔方 西西 提交于 2019-11-28 06:28:35
I'm using itextsharp on vb.net to get the text content from a pdf file. The solution works fine for some files but not for other even quite simple ones. The problem is that the token stringvalue is set to null (a set of empty square boxes) token = New iTextSharp.text.pdf.PRTokeniser(pageBytes) While token.NextToken() tknType = token.TokenType() tknValue = token.StringValue I can meassure the length of the content but I cannot get the actual string content. I realized that this happens depending on the font of the pdf. If I create a pdf using either Acrobat or PdfCreator with Courier (that by

Print PDF Created using itextsharp

南笙酒味 提交于 2019-11-28 06:23:24
问题 My Goal is to print a RDLC report on the client machine without preview. I can not use the ReportViewer print button since it requires the installation of ActiveX object and there are no permissions for that. So, I'm using ITextSharp to create a PDF from the byte array returned from the rendered LocalReport, and add a JavaScript for print. During Debug, I can see that the PDF is generated and has 2 pages, and everything looks OK. I don't receive any errors and the function exits OK, but it

underline portion of text using iTextSharp

*爱你&永不变心* 提交于 2019-11-28 06:10:12
问题 I have an application that uses itextsharp to fill PDF form fields. One of these fields has some text with tags. For example: <U>This text should be underlined</>. I'd like that the text closed in .. has to be underlined. How could I do that? How could I approch it with HTMLWorker for example? Here's the portion of code where I write my description: for (int i = 0; i < linesDescription.Count; i++) { int count = linesDescription[i].Count(); int countTrim = linesDescription[i].Trim().Count();

ITextSharp returning same size pdf when I'm trying to compress pdf file with different levels

不想你离开。 提交于 2019-11-28 05:13:39
问题 I'm reading a pdf and injecting some content using itextsharp. The resulting byte[] is passed to the method below along with the compression level. public static byte[] method(byte[] pdf,int compressionlevel) { using (MemoryStream outputPdfStream1 = new MemoryStream()) { //PdfReader reader1 = new PdfReader(pdf); //PdfStamper stamper1 = new PdfStamper(reader1, outputPdfStream1); //int level = (int)compressionlevel; //if (level <= 9) // stamper1.Writer.CompressionLevel = (int)compressionlevel;

itextSharp - htmlString to pdf Unicode are missing

天涯浪子 提交于 2019-11-28 05:12:13
问题 When I am trying to generate PDF from HTML, some Turkish characters like ĞÜŞİÖÇ ğüşıöç are missing in PDF, I see a space in place of these characters but i want to print that character. My code is: public virtual void print pdf(string html, int id) { String htmlText = html.ToString(); Document document = new Document(); string filePath = HostingEnvironment.MapPath("~/Content/Pdf/"); PdfWriter.GetInstance(document, new FileStream(filePath + "\\pdf-"+id+".pdf", FileMode.Create)); document.Open(

Save pdf file with user input filename (iTextSharp)

北慕城南 提交于 2019-11-28 05:07:34
问题 I want to allow user to enter his own file name, just like save file dialog and stream (Example: Stream s = File.Open(sfdPdf.FileName, FileMode.CreateNew) Here is my code: private void btnSave_Click(object sender, EventArgs e) { System.Drawing.Rectangle bounds = this.Bounds; using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); } bitmap

Need to give page break in inner PdfPTable of iTextSharp

為{幸葍}努か 提交于 2019-11-28 04:38:35
问题 I am printing my html string in to pdf using iTextSharp. I have nested table hierarchy. I need the Inner table should be break if its not fit in the current page and Start printing on new page. I have putted the KeepTogether = true; SplitLate = false; LockedWidth = true; For all the tables that is for parent as well as all the child tables. But in my case the Inner table is not breaking. Here is the Image. I am adding main parent table in document.add(parentTable). I have checked that If I