homepage Welcome to WebmasterWorld Guest from 54.161.214.221
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Creating PDF's with asp.net
TheSeoGuy




msg:3287746
 9:52 pm on Mar 20, 2007 (gmt 0)

Does anyone know of a .net component they can recommend for creating pdf files dynamically and saving them on the server?

Much like creating and saving a text file to the server with code, but the file is a pdf?

I have done some research and have not been happy with what I have found.

Thanks.

 

TheSeoGuy




msg:3287748
 9:56 pm on Mar 20, 2007 (gmt 0)

Just a heads up...
I can't install any dll's on the server as it is a shared hosting environment...

TheNige




msg:3287806
 10:46 pm on Mar 20, 2007 (gmt 0)

I've used Apose.Words and Aspose.PDF. With the Words component you can open and edit MS Word documents without having Word on the server. You can then save the document in an XML format that their Aspose.PDF component can open and read/manipulate.

The two are mutually exclusive and I only mention the Words component because it is sometimes usefull to do mailmerge functions with Word and then convert to PDF.

Both are full .Net components with no install needed. Just drop in your bin folder. The company Aspose is also good at releasing lots of upgrades for their components, so you know they support it.

duckhunter




msg:3288384
 2:15 pm on Mar 21, 2007 (gmt 0)

Just got through with a project using a .NET component that has been superb. Google PDF4NET (www.o2sol.com)

Ocean10000




msg:3288531
 4:00 pm on Mar 21, 2007 (gmt 0)

I have used ITextSharp (open source) in the past, its Dot.Net port from Java version which is updated often. Offers most functions one would need to generate pdf's and rtf documents.

TheSeoGuy




msg:3288610
 4:59 pm on Mar 21, 2007 (gmt 0)

Thank you for the leads. I am currently researching these possibilities.

Ocean10000, I have not had any luck with the iTextSharp component. Do you have a source for documentation?

Thanks again.

TheSeoGuy




msg:3288690
 5:56 pm on Mar 21, 2007 (gmt 0)

For instance,

I thought I was doing things correctly, but its not working as I thought it would?

I have the dll referenced and the following code in my Sub Page_Load which I copied out of a tutorial.
' step 1: creation of a document-object
Dim myDoc As New Document()

' step 2:
' we create a writer that listens to the document
' and directs a PDF-stream to a file
PdfWriter.GetInstance(myDoc, New FileStream("Chap0101.pdf", FileMode.Create))

' step 3: we open the document
myDoc.Open()

' step 4: we add a paragraph to the document
myDoc.Add(New Paragraph("Hello World"))

' step 5: we close the document
myDoc.Close()

When I run the page, nothing happens. I would assume that either a pdf file would be created or displayed. Am I missing something?

Thanks again for all the help.

Ocean10000




msg:3288826
 8:05 pm on Mar 21, 2007 (gmt 0)

Here is a link to
ITextSharp Examples C# [ujihara.jp].

I hope this helps.

TheSeoGuy




msg:3288966
 9:51 pm on Mar 21, 2007 (gmt 0)

OCEAN10000,

Thanks for the examples. I have the pdf created, but the examples are problematic at best. I keep receiving errors when the aspx page tries to create the pdf file. "There was an error Opening this document. The file is damaged and could not be repaired."

I will continue to look into this.

Thanks again for the help.

Ocean10000




msg:3289049
 11:06 pm on Mar 21, 2007 (gmt 0)

#I did this code without compiling but should give you a general reference.

Response.Clear()
Response.ContentType="application/pdf"
Response.AddHeader("content-disposition", "inline; filename=Document.pdf")

' step 1: creation of a document-object
Dim myDoc As New Document()

' step 2:
' we create a writer that listens to the document
' and directs a PDF-stream to a file
PdfWriter.GetInstance(myDoc, Response.OutputStream)

' step 3: we open the document
myDoc.Open()

' step 4: we add a paragraph to the document
myDoc.Add(New Paragraph("Hello World"))

' step 5: we close the document
myDoc.Close()

Response.Flush();

TheSeoGuy




msg:3289645
 1:45 pm on Mar 22, 2007 (gmt 0)

Ocean10000,

Thanks for the code! It is working really well. The other sample code I found was displaying the pdf in a new window, but seemed to be very volatile. As in adding table cell content as a number ("5") for example would work, but adding table cell content as text ("this is a test") for example would cause the pdf to not load.

Thanks again for your help.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved