ASP.net Add Image to PDF and Download

bcorbett

Active member
Joined
Oct 16, 2006
Messages
27
Programming Experience
Beginner
I have an image on a form and I want to Convert (or create) to PDF and then send a stream for download.

I don't want to create a physical file, just create the pdf and then allow the user to download the PDF.

I'm not against buying a Control, but I haven't been able to find one that does this.

Any help will be appreciated!!!
 
I would use SourceForge.net: iTextSharp library, code example:
VB.NET:
'add reference to itextsharp.dll
'Imports iTextSharp.text

Protected Sub PdfUploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PdfUploadButton.Click
    Response.AppendHeader("content-disposition", "attachment; filename=sample.pdf")
    Response.ContentType = "application/pdf"
    Dim doc As New Document
    pdf.PdfWriter.GetInstance(doc, Response.OutputStream)
    doc.Open()
    Dim img As Image = Image.GetInstance(Server.MapPath("111006.jpg"))
    img.Alignment = Image.ALIGN_CENTER
    doc.Add(img)
    doc.Close()
    Response.End()
End Sub
You should be able to find learning resources for this library on the web if you need it.
 
Back
Top