itextsharp

Is it possible to convert PDF page to Image using itextSharp?

谁说我不能喝 提交于 2019-12-04 11:59:49
问题 Hi I have been using itextSharp for all pdf related projects in dot.net. I came across a requirement where I need to convert PDF pages to images. I could not find any sample of such a thing. I found that another tool ghostscript is able to do it the problem with that is I am on a shared hosting & I don't think ghostscript will run on server as in my local machine I had to manually copy ghost script dlls to system32 folder which is not possible in a shared hosting. 回答1: Ok I searched all over

Convert HTML file to PDF file using ITextSharp

限于喜欢 提交于 2019-12-04 11:48:27
问题 I'd like to accomplish the following: Given the path name of an html file, and the desired pathname of a pdf file, convert the HTML file to PDF using ITextSharp. I've seen plenty of code samples which do close to this but not exactly what I need. I believe my solution will need to use the iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList() function but I'm having trouble getting this to work with an actual HTML file and outputting an actual PDF file. public void GeneratePDF(string

How do I insert a background image on all pages of a pdf-document? [closed]

不羁的心 提交于 2019-12-04 10:54:21
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I need sample code in C# to insert the background image on all pages of the finished pdf-document. I'm using iTextSharp library. 回答1: You can try this; void makePDF() { Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=test.pdf"); Response.Cache

Adding text to existing pdf which is closed using itextsharp

岁酱吖の 提交于 2019-12-04 10:13:42
Hi I am creating PDF using itextsharp. Now my requirement is to add more text to the existing pdf. Is it possible if so then how can I do that? Thanks Dipa Yes, with certain limitations. It is difficult, but not impossible, to determine what is already on an existing page. If all you want to do is add "page X of Y" to the bottom left corner of all your pages, that's easy . PdfReader reader = new PdfReader( inPath ); PdfStamper stamper = new PdfStamper( reader, new FileOutputStream( outPath ) ); BaseFont font = BaseFont.createFont(); // Helvetica, WinAnsiEncoding for (int i = 0; i < reader

x and y coordinate of text using itextsharp

孤街浪徒 提交于 2019-12-04 09:50:45
When i extract text using itextsharp, i will get x and y coordinate of text. By using these 2 coordinates if i convert text from pdf to html based on x y position the text position chnages . to get x ,y coordinates i used Vector curBaseline = renderInfo.GetBaseline().GetStartPoint(); float x=curBaseline[Vector.I1]; float y= curBaseline[Vector.I2]; for example : when i extract text using above method say x=42 and y=659; " < span style=left:{0}px;bottom:{1}px;position:relative;\">",curBaseline[Vector.I1],curBaseline[Vector.I2]); the position changes . can you help me how to set position of text

Add an existing PDF from file to an unwritten document using iTextSharp

China☆狼群 提交于 2019-12-04 08:58:29
How do I correctly add the page(s) from an existing on-disk PDF file, to a currently-being-generated in-memory PDF document? We have a class that produces a PDF document using iTextSharp. This works fine. At the moment we add a Terms & Conditions as an image at the last page: this.nettPriceListDocument.NewPage(); this.currentPage++; Image logo = Image.GetInstance("/inetpub/Applications/Trade/Reps/images/TermsAndConditions.gif"); logo.SetAbsolutePosition(0, 0); logo.ScaleToFit(this.nettPriceListDocument.PageSize.Width, this.nettPriceListDocument.PageSize.Height); this.nettPriceListDocument.Add

Using itextsharp (or any c# pdf library), how to open a PDF, replace some text, and save it again?

狂风中的少年 提交于 2019-12-04 08:38:32
问题 Using itextsharp (or any c# pdf library), i need to open a PDF, replace some placeholder text with actual values, and return it as a byte[]. Can someone suggest how to do this? I've had a look at the itext docs and can't figure out where to get started. So far i'm stuck on how to get the source pdf from a PDFReader to a Document object, i presume i'm probably approaching this the wrong way. Thanks a lot 回答1: In the end, i used PDFescape to open my existing PDF file, and place some form fields

itextsharp place Pdfptable at desired position

六眼飞鱼酱① 提交于 2019-12-04 07:55:24
Header Content and Pdftable is overlapping How can I place PdfPTable at any position in the pdf page using (x, y) positioning like (100, 200) or (15, 100) at any place on the pdf page? Header Table using PdfEventHelper public override void OnEndPage(PdfWriter writer, Document document) { AddHeader(writer, document); } public void AddHeader(PdfWriter writer, Document document) { // set no of rows PdfPTable headerTable = new PdfPTable(1); // set the width headerTable.TotalWidth = document.PageSize.Width; headerTable.DefaultCell.HorizontalAlignment = Element.ALIGN_CENTER; PdfPCell company = new

Shrinking the contents of a pdf page

主宰稳场 提交于 2019-12-04 07:14:27
问题 For my current project, I am required to take a pdf and shrink the contents of the first page without changing the overall size of the page so that I can add additional information to the bottom without it overlapping with any pre-existing content. Is there a way to do this using iTextSharp? I would appreciate any help you can give! 回答1: You can shrink the content of a page by prepending a transformation matrix to that effect to the page content stream(s), e.g. like this: public void shrink

Unable to Export HTML Markup to PDF using iTextSharp API in asp.net using C#?

醉酒当歌 提交于 2019-12-04 06:26:47
问题 I have an HTML markup which has HTML Table and Images in it. I am using iTextSharp API to convert the HTML markup to PDF . But, unfortunately the iTextSharp fails to export the HTML markup containing the Images & Table to PDF. Error:The network path was not found. Result must be: Code: using iTextSharp.text; using iTextSharp.text.pdf; using iTextSharp.text.html; using System.Data.SqlClient; using System.Text; using iTextSharp.text.html.simpleparser; public string strSelectUserListBuilder = @"