C# - Generate PDF With ITextSharp

Apr 1 at 21:10

I am trying to add an image to the top of every page on an existing PDF. I have tried using PdfStamp but for some reason when I try to print the pdf from Chrome all I get is a black page. Also Adobe Reader only shows the original document. Does anyone have any ideas on how to get it working? Here is the code.

public partial class MakePdf : System.Web.UI.Page
public MemoryStream m = new MemoryStream();
protected void Page_Load(object sender, EventArgs e)
Document document = new Document(PageSize.LETTER);
Response.ContentType = "application/pdf";
string RESULT = @"C:UsersmaitchisonDocumentsPdfService Report Search - 650-10-067 4114.pdf";
PdfReader reader = new PdfReader(RESULT);
PdfStamper stamp = new PdfStamper(reader, m);
// Set ContentType and create an instance of the Writer.
Response.ContentType = "application/pdf";
PdfWriter writer = PdfWriter.GetInstance(document, m);
writer.CloseStream = false;
// Open Document
int n = reader.NumberOfPages;
int i = 1;
PdfContentByte cb = writer.DirectContent;
PdfContentByte over;
Barcode128 barcode128 = new Barcode128();................


How To Generate Itextsharp PDF Using XML And XSL In C#.net Web Application?

Apr 3 at 7:11

I am looking for code to create a itextsharp pdf file using XML and xslt in an ASP.net application.I was unable find any code from the internet whihc uses xslt transform before converting to pdf.

View 1 Replies View Related

Generate A Pdf File Using Itextsharp In C#

Mar 1 at 11:06

i am trying to generate a pdf file using itextsharp in asp.net c#.

I came across table concept in itextsharp n i am trying to use it ie my application. I am having the following problem while using tables.The pdf cell which contains Name of treasery the word treasery comes on next line. I am setting width for each cell. if i increase the width than also no changes come. The gap which is shown using arrow in below image remain as it is al the time. Why is that gap?How to remove that gap?I want a dotted line as a border to only one cell. how to do that?here is my code

PdfPTable line6table = new PdfPTable (3);
float[] width = new float[] { 2.5F, 1.5F, 3.0F };

View 2 Replies View Related

Web Forms :: Generate Gridview To Pdf Using Itextsharp

Oct 05, 2010 09:28 AM

i'm genarating a pdf using itextsharp.in my gridview there are many feilds(100).i want to increase my page width. Document pdfDoc = new Document(PageSize.A1, 10f, 10f, 10f, 0f);

View 1 Replies View Related

C# - Generate Table Of Content Using Itextsharp?

Jul 27 10 at 13:24

What I am doing is to generate a pdf booklet from database. I need go generate a content table with page numbers. E.g there are two chapters with page number like:

Content table
Chapter 1 ----- 3
Chapter 2 ----- 17

The text "Chapter 1 ----- " is normal paragraph. But the page number "3" has to be produced using PdfTemplate because it can only be known later. But the pdfTemplate is absolutely positioned. How can I know where to position the PdfTemplate? Am I right on this ? How could I figure this out or should I use other methods?

View 1 Replies View Related

Forms Data Controls :: Generate PDF Report From Datagrid Using Gios PDF .NET Or Itextsharp Library?

Dec 06, 2008 12:10 PM

I am developing my web application using csharp on visual studio 2003. I am able to generate datagrid without any problem. But I want records on datagrid to be exported on pdf document. Have tried using Gios PDF .NET library, from [URL]. But the problem I have is when declare in my code using Gios PDF. it is saying that it does not know about Gios PDF. I have tried to put references but not working. How can I do it? So that I use this powerful library. The problem I have is calling the Gios PDF .NET library in my files. Apart from from that I have tried itextsharp from [URL]. I am still facing the same problem. All want I want is to export data from datagrid to pdf report.

View 12 Replies View Related

How To Use PdfSmartCopy From ItextSharp

Nov 25 10 at 10:27

I am trying to use PdfSmartCopy from ItextSharp but I cannot find any relevant examples in c#. The ideea is that I have a pdf containing form fields and the fields add 700kb to the size of the pdf document. The original document without form fields was 100kb. Any other sugestions are welcome, especially o reduce the pdf size consistently. (I optimised the generated PDF with adobe acrobat, and it reduced it to 44kb. So there must be a glitch somewhere.) Is there any way to reduce the PDF size? Edit: FormFlatenning doesn't . The pdf template file contains only text, lines and tables, no images.

here's my code snippet

PdfReader reader = new PdfReader(GetTemplateBytes());
pst = new PdfStamper(reader, Response.OutputStream);
var acroFields = pst.AcroFields;
pst.FormFlattening = true;
pst.FreeTextFlattening = true;

View 2 Replies View Related

Printing A PDF While Using The ITextSharp.dll?

Jan 11, 2011 04:26 PM

So I have been using the open source library iTextSharp.dll for reading and writing to a pdf file. For the most part I've been developing an extension to an application which a user can select a pdf (as a template) and then be able to print a list of the labels for each field within the PDF so we can easily create backcode for how every different form will eventually be handled.

Now I have stepped forward into another application where I will be actually creating a print button which will print a populated pdf but will not save it. This is due to the fact our forms are permanently locked and a local copy of a filled form cannot be saved for security reasons. I'm having trouble printing the pdf and I actually do not even know if it is properly populating yet but I will deal with that once I can get it to print.

This is my code, where there is a function called "FillForm()". It locates the template file and the printable file and then utilizes a in-house function called "SelectString" which will return a string value for the value of a column within the database. All I really need to know is how to print the pdf once I am done.


View 6 Replies View Related

SQL Server :: Failed To Generate A User Instance - Only An Integrated Connection Can Generate

Dec 16, 2010 08:25 AM

Windows 7 Ultimate 64bit Visual Studio 2008 Team System Using C# SQL Server 2005 Express Management Studio (Service Pack 3) By using Visual Studio 2008,I opened Server Explorer and tried to modify Database connection,i wanted to use SQL Authentication,I entered User name and Passwored after pressing OK button,i got the following... Error message Failed to generate a user instance of SQL Server.Only an integerated connection can generate a user instance.The connection will be closed.

View 4 Replies View Related

Read A PDF And And Save The Changes Using Itextsharp.dll?

Jul 01, 2010 06:51 AM

I have web page named DocComments.aspx in which i created one table . one td contains document options for a pdf file which will be displayed in another td.I used iframe to display the td.

document.getElementByID('tdDocview').innerHTML="<iframe src='DocView.aspx?DocID="+Id+"' frameborder='0' name='docview' width='100%' scrolling='no' id='docview' title='docview' height=" + iHeight + " ></iframe>";

Document options are Move/copy-move a pdf file or create a pdf based on page number and range. Rotate page - rotate 90,180,270 Along with this option i need to add typewriter function in the pdf file which is going to load. I have used itextsharp dll for all the document options.Also i enabled the typewriter option in pdf file.If a user uses the typewriter and add comments,then i need to save that changes.I have stored all the pdf's in db. My problem is how to read that pdf file and save the changes using itextsharp.dll

View 4 Replies View Related

Create PDF File Using ItextSharp?

Dec 17 10 at 14:25

I am creating an ASP.net website where some articles can be uploaded. I need that my users can get PDF version of it by clicking on a button. For this functionality I am using itextSharp. I am considering the following two options.

1. I will create the PDF file once(on first request) and reuse it always by checking for the existence of it.

2. I will create it on the fly and delete it as soon as the PDF file is delivered to the client. The first approach will lead to faster PDF delivery where as the second approach will lead to saving space.

I am also wondering if this can be possible without saving the PDF on the server in the first place.

View 5 Replies View Related

Convert Doc / Docx To Pdf With ITextSharp.dll?

Jan 21 at 10:51

I Need to convert doc/docx to pdf with iTextSharp.dll. May i know how can i do that?

View 1 Replies View Related

C# - Get The Export Value Of A Checkbox Using ITextSharp?

Dec 20 10 at 15:37

I'm working on dynamically filling in the fields on a pdf document using ITextSharp. I'd like to be able to determine the "export value" of the checkbox is from the codebehind in order to determine what value to send to this checkbox if it should be checked. Most of the documents I've worked with in the past had the same export value for every check box but the one I'm currently working with varies from checkbox to checkbox. I could go through all of the text boxes and make them consistent but it would save a lot of time in the future if I could just determine what the export value of these checkboxes are at runtime and set them accordingly.I tried to implement the solution below in C# and ended up with the following code:

public string GetCheckBoxExportValue(AcroFields pdfDocument, string checkBoxFieldName)
AcroFields.Item item = pdfDocument.GetFieldItem(checkBoxFieldName);


View 1 Replies View Related

Use Itextsharp To Convert Html To Pdf(using C#)?

Mar 18 10 at 18:26

i have use itextsharp to convert html to pdf(using asp.net C#) and its work in english characters , but when i want to convert html including arabic characters it will give me empty pdf !!

View 1 Replies View Related

C# - Displaying A Pdf To Webpage Using ITextSharp?

2 days ago

I am generating a pdf using iTextSharp. I would like to display it on the webpage and let the user save it from the online pdf viewer. dynamicpdf has a drawtoweb() method, but it is not free to use and I cannot find the same functionality using iTextSharp. How can I display the pdf?

string newFile = "Pdf Document.pdf";
Document doc = new Document();
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(newFile, FileMode.Create));
doc.AddTitle("Sample PDF Document");
doc.Add(new Paragraph("Hello, World!"));

View 2 Replies View Related

C# - Generating Html To Pdf Using Itextsharp?

Feb 18 at 5:41

public void pdfgenforffd(TextBox TextBox3, HiddenField HiddenField1, HiddenField HiddenField4, AjaxControlToolkit.HTMLEditor.Editor Editor1)
HttpContext.Current.Response.ContentType = "application/pdf";


i am using the above code for pdf generation from html text in HTMLEditor(ajax control). If i hardcode a table with each column of different width, into HTMLEditor text than while generating pdf the column get devided equally i.e all column have fixed size on pdf even if i specify some custom width for each column.

I want to generate pdf that can convert html to pdf,also divide table column with specified width. How to do it?

View 1 Replies View Related

Web Forms :: Converting HTML To Pdf Using ItextSharp?

Aug 27, 2010 11:05 AM

I want to convert my current asp.net page which will be running, to PDF when i click a button present on the page. I have buttons textboxes and text on the page. itextsharp.dll is not showing textboxs and buttons on the page its only showing plain html text.. what should i do?

View 3 Replies View Related

HTMLparser In Itextsharp - Create Pdf From Html

Jun 8 10

I am using itextsharp-5.0.2-dll trying to create pdf from html. In that I am using HtmlParser, I dont know what should I import for this. still It getting error due to this.

View 1 Replies View Related

VS 2008 How To Export Gridview To Pdf Using ITextSharp

Jan 26th, 2011, 05:46 AM

I'm trying to export my gridview to pdf but the html parsing of the iTextSharp control seems to be failing. I have to create an HtmlForm like below and add the gridview to it because the code is in a custom control, so I cant pass the gridview directly. I get an error saying "gridview must be in a form tag with runat=server"

If I don't insert the test header like i do below, I get an error saying "document has no pages"

At the moment the pdf is generated but it only has the text "testing".

The htmlform html doesn't get parsed i think. Here is a small portion of what the newHtml variable below contains when I create it.



View 3 Replies View Related

How To Extract Specific Pages In Pdf Using Itextsharp

Dec 6 10 at 7:17

How to extract specific pages in pdf using itextsharp?Suppose i have 16 pages of pdf i want to extract page number 2,8,16 from that 16pages.

View 1 Replies View Related

Web Forms :: ITextSharp Open Document As 75%?

Apr 27, 2010 12:15 PM

i am using iTextsharp to generate pdf ,i would like to open a pdf at 75%

View 1 Replies View Related

Web Forms :: Dynamic Pdf Generation Using ITextSharp?

Dec 21, 2009 08:29 PM

I am trying to use the iTextsharp pdf library to generate dynamic pdfs.

Currently in my web project, there is one report file -- 'report.aspx' which generates a report.

report.aspx takes an input parameter and fetches all the relevant data from the DB to create a report.

I am trying to display this report as a pdf in a new web form -- 'display.aspx'.

My problem is I don't know how to call the 'report.aspx' file from within the 'display.aspx' file and "feed" the output to itextsharp to generate a pdf version of the report. I think I have to use WebRequest and WebResponse but I am not sure how.

View 5 Replies View Related

C# - ITextSharp Insert Text To Existing Pdf

Oct 21 10 at 22:46

I want to add a text to an existing PDF file using iTextSharp, however i can't find how to do it anywhere in the web. I cannot use PDF forms.

View 1 Replies View Related

C# - ITextSharp - Opening PDF Document From Memory?

Mar 3 10 at 2:46

It is possible to create a PDF document in memory with iTextSharp that gives the user a choice to "open" or "save"?, and if it opens then it opens in a browser window.

At the moment the only I have save it to disk.


ok I've got it sussed. I did end up having to write the file to a folder, but it is only temporary as gets overwritten every time. Here is the solution for what it's worth:

private void GeneratePDF() {
var doc1 = new Document();
string path = Server.MapPath("~/pdfs/");
string filepath = path + "Doc1.pdf";
PdfWriter.GetInstance(doc1, new FileStream(filepath, FileMode.Create));


View 3 Replies View Related

Web Forms :: Implementing ITextSharp In An Application?

Apr 12, 2010 10:24 AM

I'm working on a project that involves exporting HTML to PDF. I was told that this can be accomplished with a a free library called ITextSharp:http://itextsharp.sourceforge.net/This looks like it's actually a JAVA-based interface. Does anyone know how to actually inistall this and reference these dlls in your ASP.Net project? Maybe there there's a different version of ITextSharp for .Net that I missed...

View 3 Replies View Related

C# - Drawing A Line In A Pdf File Using Itextsharp?

Feb 24 at 10:31

I am generating a pdf file in asp.net c# using itextsharp. i am not able to draw a horizontal line/verticle line/dotted line.

i tried to draw a line using the following code,i am getting no errors but the line is also not getting displayed in the pdf file

PdfContentByte cb = wri.DirectContent;
cb.SetLineWidth(2.0f); // Make a bit thicker than 1.0 default
cb.MoveTo(20, pdfDocument.Top - 40f);
cb.LineTo(400, pdfDocument.Top - 40f);

What is the problem in the code.Is it because of the position of x y co-ordinates? I had used rough points to know approximate position in pdf,but the line never apears in the pdf file.

The output i am looking out for is as shown in image below.

View 3 Replies View Related

Web Forms :: ITextSharp - Add Image To Page Header?

Aug 17, 2010 09:32 PM

I am using iTextSharp to export my webpage to pdf. I have added my logo to the webpage. But I want to add it to header so that it will repeat on all the pages at the top.

View 14 Replies View Related

Web Forms :: How To Get The Page Number In Pdf File Using ITextSharp

Sep 02, 2010 04:43 PM

I wanted to get the page number in each page of the pdf generated using iTextSharp

right now part of the code is


But when i do this , it is showing the page number but the problem is it is showing same page number in all the pages. like "1" in all the pages. how to get the page number for the pdf file using iTextSharp version ?

View 2 Replies View Related

C# - Create Pdf From Persian Html File By ITextSharp

Feb 8 at 8:03

I use ITextSharp library to convert html to pdf. My users use persian language sentence in her/his html files, So this library can't convert persian word.

For resolve this and right to left problem i use bellow code:


My right to left and convert persian words was resolved, but it have another problem.

My algorithm can't parse and convert content of table tag that uses in html file.

Now the question is: How to parse html file that have table tag, div and paragraph tag with persian language sentence, and convert it to pdf?

View 1 Replies View Related

Web Forms :: Mail Merge With ITextSharp Library?

Sep 27, 2010 01:53 PM

i'm looking for a way to implement a simple ail merge with iTextSharp library.

I have data stored in database (addresses) and a pdf template.

I need to create a single pdf file where each page contains one address.

How can i do this?

View 1 Replies View Related

ITextSharp Renders Image With Poor Quality In PDF

Mar 26 10 at 15:11

I'm using iTextSharp to print a PDF document. Everything goes ok until I have to print the company logo in it.

First I noticed that the logo had poor quality, but after testing with several images, I realize that was the iTextSharp rendering it poorly.The test I did to say this was to print the PDF using my code and then edit the document with Acrobat 8.0 and I drew an image. Then printed the two documents and saw the noticeable difference.My question is that if anyone know if this can be due to a scaling problem where I'm failing to tell iTextSharp how it must render the image or is an iTextSharp limitation.

The code to render the image is the following:


The method ResizeImage() do the resizing of the width and height respecting the aspect ratio and keeping in a max width and a max height limits.

View 2 Replies View Related

Web Forms :: ItextSharp / Cell.SetWidth Does Not Work?

Jun 27, 2007 03:55 PM

I would like to set a width of the cell. e.g

Cell cell = new Cell();

cell.WIdth = 100 or cell.SetWidth does not work.

View 7 Replies View Related

Web Forms :: ITextSharp : Change Printer's Pagesize?

Sep 29, 2010 07:27 AM

in my webapplication i create a pdf document based on a pdf template which paegsize is Iso C6 (envelope ).
The documet is returned to the client in the response output stream .

If i choose to open the document (and print it) , i have the printer pagesize automatically set to the a4 pagesize;

This cause a side effect : the text printed on the envelope is not in the right position because the printer pagesize is different (on a a4 paper the envelope is centered on the paper!!!).

Can i set the printer pagesize with itextsharp?

View 3 Replies View Related

C# - ItextSharp Expected A Dict Object When Trying To Print?

Jan 31 at 11:05

I have a web page that allows a user to view a pdf and print pdf. The print pdf is a copy of the display pdf and i am using ItextSharp to inject the javascript to allow auto printing. I have a method that allows a user to upload a pdf and it calls this method below to copy the display copy into a pdf. Both pdf's are then saved in the database. However , when a user goes to click on the print button on my web page they receive the following error "expected a dict object". below is my code that adds in the auto print, which works fine for me but not on my clients site.

I am doing anything wrong that could be corrupting the file. The original pdf content is passed in as a Binary Object. Also i am using ASP.NET MVC2.

MemoryStream originalPdf = new MemoryStream(Content.BinaryData);
MemoryStream updatedPdf = new MemoryStream();
updatedPdf.Write(Content.BinaryData,0, Content.BinaryData.Length);[code]....

View 1 Replies View Related

C# - Set PDF Paragraph Or Font Line-height With ITextSharp?

Apr 13 10 at 14:41

How can I change the line-height of a PDF font or paragraph using iTextSharp?

View 3 Replies View Related

Web Forms :: Using ITextSharp For Conversion Of Aspx To PDF File?

Jul 06, 2010 08:01 AM

I am using iTextSharp for conversion of aspx to PDF file.

Is there any way I can add Horizontal scroll bar in my PDFPtable or Horizontal scrollbar in my PDF file generated.

View 2 Replies View Related

C# - ITextSharp Convert A System.Web.UI.DataVisualization.Charting To Pdf?

Nov 11 10 at 13:55

I have a report like page which displays a gridview and a chart created from .Web.UI.DataVisualization.Charting which I want to convert to pdf. Currently I am using iTextSharp which in my opinion is really great. I managed to create the table in the pdf but cannot find a way how to display the chart as well.

View 1 Replies View Related

Can ITextSharp Rasterize/export To JPEG Or Other Image Format

Apr 26 10 at 16:00

I need to be able to export PDF's that I am creating to JPEG, so that users can have a screenshot/thumbnail of the end product, which is faster than opening the whole PDF.

I am running this on an ASP.NET website running in Medium Trust in the Rackspace Mosso Cloud.

I have yet to find a library that will either work in Medium trust, or in the case of ABC PDF, which works great locally, wont load in Mosso. Maybe Mosso has a custom trust level?

I know that iTextSharp works on Mosso, but I haven't been able to figure how to "screenshot" a single page of a PDF, or export a page to JPEG.

View 1 Replies View Related

C# - ItextSharp Nested Table On Multiple Pages Causes NullReferenceException?

Feb 4 10 at 18:45

I am getting a NullReferenceException when the following code is executed. I have also noticed that the nested table appeared on a new page when I added in the code that wrote cells to the main table. It doesn't occur if I take out the two loops that write cells to the main table.

<%@ Page Title="" Language="C#" MasterPageFile="~/Main.master" %>
<%@ Import Namespace="iTextSharp.text" %>
<%@ Import Namespace="iTextSharp.text.pdf" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
Document doc = new Document(PageSize.LETTER);
// Here is some stuff needed to put the pdf into the users response stream


View 1 Replies View Related

Custom Server Controls :: Convert Html To Pdf Using ITextSharp?

Jan 01, 2008 03:37 PM

can anyone provide me a sample code who have used iTextsharp(chapter 0707) to convert HTML to PDF..

View 20 Replies View Related

Copyrights 2005-14 www.BigResource.com, All rights reserved