itextsharp

how to set width for PdfPCell in ItextSharp

岁酱吖の 提交于 2019-11-30 06:46:14
问题 i want set width for PdfpCell in Table, i want design this i Write this code PdfPCell cell; PdfGrid tableHeader; PdfGrid tmpTable; PdfGrid table = new PdfGrid(numColumns: 1) { WidthPercentage = 100, RunDirection = PdfWriter.RUN_DIRECTION_LTR, ExtendLastRow = false }; string imagepath2 = HttpRuntime.AppDomainAppPath + "Header.JPG"; cell = new PdfPCell() { Border = 0, RunDirection = PdfWriter.RUN_DIRECTION_RTL }; cell.Image = iTextSharp.text.Image.GetInstance(imagepath2); table.AddCell(cell);

Hiding table border in iTextSharp

拟墨画扇 提交于 2019-11-30 05:38:48
How can i hide the table border using iTextSharp. I am using following code to generate a file: var document = new Document(PageSize.A4, 50, 50, 25, 25); // Create a new PdfWriter object, specifying the output stream var output = new MemoryStream(); var writer = PdfWriter.GetInstance(document, output); document.Open(); PdfPTable table = new PdfPTable(3); var bodyFont = FontFactory.GetFont("Arial", 10, Font.NORMAL); PdfPCell cell = new PdfPCell(new Phrase("Header spanning 3 columns")); cell.Colspan = 3; cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right table.AddCell(cell); Font arial =

how to get the particular paragraph in pdf file using iTextSharp in C#?

て烟熏妆下的殇ゞ 提交于 2019-11-30 05:28:49
I am using iTextSharp in my C# winform application.I want to get particular paragraph in PDF file. Is this possible in iTextSharp? Yes and no. First the no. The PDF format doesn't have a concept of text structures such as paragraphs, sentences or even words, it just has runs of text. The fact that two runs of text are near to each other so that we think of them as structured is a human thing. When you see something that looks like a three line paragraph in a PDF, in reality the program that generated the PDF actually did the job of chopping up the text into three unrelated text lines and then

itextsharp: what is the height of a regular PDF page in pixels?

守給你的承諾、 提交于 2019-11-30 04:56:03
What is the height of a regular PDF page in pixels? I heard it was something like this: Dim pgSize As New iTextSharp.text.Rectangle(595, 792) but I am adding an image that takes up maybe half the height, and even though pgSize looks like a full page and the image takes up only half of it, I am getting a height of like 619 for the image? I do not know if it is in the same units? Your page size depends on what you set it when you create the document, probably using the PageSize object (eg. PageSize.LETTER). Once you've established that, most elements in iTextSharp use points and 1 in = 2.54 cm =

iTextsharp landscape document

大憨熊 提交于 2019-11-30 04:50:36
I am trying to create Landscape PDF using iTextSharp but It is still showing portrait. I am using following code with rotate: Document document = new Document(PageSize.A4, 0, 0, 150, 20); FileStream msReport = new FileStream(Server.MapPath("~/PDFS/") + "Sample1.pdf", FileMode.Create); try { // creation of the different writers PdfWriter writer = PdfWriter.GetInstance(document, msReport); document.Open(); PdfPTable PdfTable = new PdfPTable(1); PdfTable.SpacingBefore = 30f; PdfPCell PdfPCell = null; Font fontCategoryheader = new Font(Font.HELVETICA, 10f, Font.BOLD, Color.BLACK); for (int i = 0;

Merging Memory Streams to create a http PDF response in c#

Deadly 提交于 2019-11-30 04:29:05
问题 I am trying to merge 2 crystal reports into single pdf file and I'm using Itextsharp v5.1.1. But it says the document cannot be opened. It might be corrupted. There are no build errors. but the pdf is malformed and cant be opened. Here is the order I chose to accomplish this. Export the Crystal report to MemoryStream1 in pdf format Export the second report into MemoryStream2. Merge the Memory Streams Send the Streams to Http Output Response as PDF. Here is the Code for each step in the order.

iTextSharp - Is it possible to set a different font color for the same cell and row?

和自甴很熟 提交于 2019-11-30 01:11:49
问题 I am using the iTextSharp.dll with the following code: var Title = "This is title"; var Description = "This is description"; Innertable.AddCell(new PdfPCell(new Phrase(string.Format("{0} {1}", Title, Description.Trim()), listTextFont)) { BackgroundColor = new BaseColor(233, 244, 249), BorderWidth = 0, PaddingTop = 4, PaddingLeft = -240, PaddingBottom = 5, HorizontalAlignment = Element.ALIGN_LEFT }); Can we set different font colors for title and description, but only using single cell (ie

Search Particular Word in PDF using Itextsharp

こ雲淡風輕ζ 提交于 2019-11-30 00:42:09
This is my first post in StackOverflow. I have a PDF file in my System drive... I want to write a program in C# using Itextsharp.dll reference to search for a Particular word in that PDF ... say I want to search "StackOverFlow"... If the PDF contains the Word " StackOverFlow" , it should return true. Else it should return false. I have looked into many articles but didn't get the solution till now ..:-( What I have tried till now is : public string ReadPdfFile(string fileName) { StringBuilder text = new StringBuilder(); if (File.Exists(fileName)) { PdfReader pdfReader = new PdfReader(fileName)

How to add a form field to an existing pdf with itextsharp?

独自空忆成欢 提交于 2019-11-29 21:57:30
How to add a form field to an existing pdf with itextsharp? I have an existing pdf document, I'd like to add form fields to it without creating a copy and writing out a new document. After further review, the ruling on the field is overturned. Turns out if you form flatten the stamper the fields do not show on the resulting document (because they lack 'appearance' settings). BTW, form flattening prevents further edits of a form field. Now we can add appearance to the form, however, an easier way is to use the TextField class and not worry about explicitly setting up 'appearance' objects.

iTextSharp Can not Convert All HTML to PDF

喜你入骨 提交于 2019-11-29 18:44:49
Using the sample codes from here I come up with these codes - var my_html = this.GetmyReportHtml(); var my_css = this.GetmyReportHtmlCss(); Byte[] bytes; using (var ms = new MemoryStream()) { using (var doc = new iTextSharp.text.Document(PageSize.LETTER)) { using (var writer = PdfWriter.GetInstance(doc, ms)) { doc.Open(); try { using (var msCss = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(my_css))) { using (var msHtml = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(my_html))) { iTextSharp.tool.xml.XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msHtml, msCss); } } } catch