Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










C# - Generate PDF With ITextSharp


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);
try
{
// Set ContentType and create an instance of the Writer.
Response.ContentType = "application/pdf";
PdfWriter writer = PdfWriter.GetInstance(document, m);
writer.CloseStream = false;
// Open Document
document.Open();
int n = reader.NumberOfPages;
int i = 1;
PdfContentByte cb = writer.DirectContent;
PdfContentByte over;
Barcode128 barcode128 = new Barcode128();................


View 2 Replies (Posted: Apr 1 at 21:10)

Sponsored Links:

Related Forum Messages For ASP.NET category:
How To Generate Itextsharp PDF Using XML And XSL In C#.net Web Application?
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.

Posted: Apr 3 at 7:11

View 1 Replies!   View Related
Generate A Pdf File Using Itextsharp In C#
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 };
line6table.SetWidths(width);[code]....

Posted: Mar 1 at 11:06

View 2 Replies!   View Related
Web Forms :: Generate Gridview To Pdf Using Itextsharp
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);

Posted: Oct 05, 2010 09:28 AM

View 1 Replies!   View Related
C# - Generate Table Of Content Using Itextsharp?
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?

Posted: Jul 27 10 at 13:24

View 1 Replies!   View Related
Forms Data Controls :: Generate PDF Report From Datagrid Using Gios PDF .NET Or Itextsharp Library?
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.

Posted: Dec 06, 2008 12:10 PM

View 12 Replies!   View Related
How To Use PdfSmartCopy From ItextSharp
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;
SetFieldsInternal(acroFields);
pst.Close();

Posted: Nov 25 10 at 10:27

View 2 Replies!   View Related
Printing A PDF While Using The ITextSharp.dll?
So I have been using the open source libraryiTextSharp.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 beactually 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.

[Code]....

Posted: Jan 11, 2011 04:26 PM

View 6 Replies!   View Related
SQL Server :: Failed To Generate A User Instance - Only An Integrated Connection Can Generate
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.

Posted: Dec 16, 2010 08:25 AM

View 4 Replies!   View Related
Read A PDF And And Save The Changes Using Itextsharp.dll?
I have web pagenamed 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

Posted: Jul 01, 2010 06:51 AM

View 4 Replies!   View Related
Create PDF File Using ItextSharp?
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.

Posted: Dec 17 10 at 14:25

View 5 Replies!   View Related
Convert Doc / Docx To Pdf With ITextSharp.dll?
I Need to convert doc/docx to pdf with iTextSharp.dll. May i know how can i do that?

Posted: Jan 21 at 10:51

View 1 Replies!   View Related
C# - Get The Export Value Of A Checkbox Using ITextSharp?
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);

[code]...

Posted: Dec 20 10 at 15:37

View 1 Replies!   View Related
Use Itextsharp To Convert Html To Pdf(using C#)?
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 !!

Posted: Mar 18 10 at 18:26

View 1 Replies!   View Related
C# - Displaying A Pdf To Webpage Using ITextSharp?
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.AddCreator("Myself");
doc.AddTitle("Sample PDF Document");
doc.Open();
doc.Add(new Paragraph("Hello, World!"));
doc.Close();

Posted: 2 days ago

View 2 Replies!   View Related
C# - Generating Html To Pdf Using Itextsharp?
public void pdfgenforffd(TextBox TextBox3, HiddenField HiddenField1, HiddenField HiddenField4, AjaxControlToolkit.HTMLEditor.Editor Editor1)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/pdf";

[Code]....

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?

Posted: Feb 18 at 5:41

View 1 Replies!   View Related
Web Forms :: Converting HTML To Pdf Using ItextSharp?
Iwant to convert my currentasp.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?

Posted: Aug 27, 2010 11:05 AM

View 3 Replies!   View Related
HTMLparser In Itextsharp - Create Pdf From Html
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.

Posted: Jun 8 10

View 1 Replies!   View Related
VS 2008 How To Export Gridview To Pdf Using ITextSharp
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.

Code:

[code]....

Posted: Jan 26th, 2011, 05:46 AM

View 3 Replies!   View Related
How To Extract Specific Pages In Pdf Using Itextsharp
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.

Posted: Dec 6 10 at 7:17

View 1 Replies!   View Related
Web Forms :: ITextSharp Open Document As 75%?
i am using iTextsharp to generate pdf ,i would like to open a pdf at 75%

Posted: Apr 27, 2010 12:15 PM

View 1 Replies!   View Related
Web Forms :: Dynamic Pdf Generation Using ITextSharp?
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.

Posted: Dec 21, 2009 08:29 PM

View 5 Replies!   View Related
C# - ITextSharp Insert Text To Existing Pdf
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.

Posted: Oct 21 10 at 22:46

View 1 Replies!   View Related
C# - ITextSharp - Opening PDF Document From Memory?
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.

EDIT:

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));

[Code]....

Posted: Mar 3 10 at 2:46

View 3 Replies!   View Related
Web Forms :: Implementing ITextSharp In An Application?
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...

Posted: Apr 12, 2010 10:24 AM

View 3 Replies!   View Related
C# - Drawing A Line In A Pdf File Using Itextsharp?
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);
cb.Stroke();

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.

Posted: Feb 24 at 10:31

View 3 Replies!   View Related
Web Forms :: ITextSharp - Add Image To Page Header?
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.

Posted: Aug 17, 2010 09:32 PM

View 14 Replies!   View Related
Web Forms :: How To Get The Page Number In Pdf File Using ITextSharp 5.0.2.0
I wanted to get the page number in each page of the pdf generated using iTextSharp 5.0.2.0.

right now part of the code is

[Code]....

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 5.0.2.0 ?

Posted: Sep 02, 2010 04:43 PM

View 2 Replies!   View Related
C# - Create Pdf From Persian Html File By ITextSharp
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:

[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?

Posted: Feb 8 at 8:03

View 1 Replies!   View Related
Web Forms :: Mail Merge With ITextSharp Library?
i'm looking for a wayto implementa 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?

Posted: Sep 27, 2010 01:53 PM

View 1 Replies!   View Related
ITextSharp Renders Image With Poor Quality In PDF
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:

[Code]....

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.

Posted: Mar 26 10 at 15:11

View 2 Replies!   View Related
Web Forms :: ItextSharp / Cell.SetWidth Does Not Work?
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.

Posted: Jun 27, 2007 03:55 PM

View 7 Replies!   View Related
Web Forms :: ITextSharp : Change Printer's Pagesize?
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?

Posted: Sep 29, 2010 07:27 AM

View 3 Replies!   View Related
C# - ItextSharp Expected A Dict Object When Trying To Print?
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]....

Posted: Jan 31 at 11:05

View 1 Replies!   View Related
C# - Set PDF Paragraph Or Font Line-height With ITextSharp?
How can I change the line-height of a PDF font or paragraph using iTextSharp?

Posted: Apr 13 10 at 14:41

View 3 Replies!   View Related
Web Forms :: Using ITextSharp For Conversion Of Aspx To PDF File?
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.

Posted: Jul 06, 2010 08:01 AM

View 2 Replies!   View Related
C# - ITextSharp Convert A System.Web.UI.DataVisualization.Charting To Pdf?
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.

Posted: Nov 11 10 at 13:55

View 1 Replies!   View Related
Can ITextSharp Rasterize/export To JPEG Or Other Image Format
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.

Posted: Apr 26 10 at 16:00

View 1 Replies!   View Related
C# - ItextSharp Nested Table On Multiple Pages Causes NullReferenceException?
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

[Code]....

Posted: Feb 4 10 at 18:45

View 1 Replies!   View Related
Custom Server Controls :: Convert Html To Pdf Using ITextSharp?
can anyone provide me a sample code who have used iTextsharp(chapter 0707) to convert HTML to PDF..

Posted: Jan 01, 2008 03:37 PM

View 20 Replies!   View Related
Copyright 2005-08 www.BigResource.com, All rights reserved