Forum Moderators: open
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.
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.
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.
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();
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.