ASP.net VB.net Build a PDF document

Hi

In my ASP.net web app I need to email a pdf document containing information about a purchase order.
How would I build a neatly formatted pdf document using VB.net?
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MishaProgrammerCommented:
You can use pdfsharp library to create PDF document with VB.Net. You can dowload it from this site:
https://archive.codeplex.com/?p=pdfsharp
This simple code can help to crete PDF with this library:
Imports PdfSharp
Imports PdfSharp.Drawing
Imports PdfSharp.Pdf

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim pdf As PdfDocument = New PdfDocument
        pdf.Info.Title = "My First PDF"
        Dim pdfPage As PdfPage = pdf.AddPage
        Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage)
        Dim font As XFont = New XFont("Verdana", 20, XFontStyle.Bold)
        graph.DrawString("This is my first PDF document", font, XBrushes.Black, _
        New XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.Center)
        Dim pdfFilename As String = "firstpage.pdf"
        pdf.Save(pdfFilename)
        Process.Start(pdfFilename)
    End Sub
End Class

Open in new window


Source:
http://vb.net-informations.com/files/create-pdf.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I'm using iTextSharp.

You can get it via Nuget Package Manager.

iTextSharp
https://www.nuget.org/packages/iTextSharp/

you can further google for plenty of examples.
0
jshesekCommented:
I use iTextSharp because it's free (Verson 5.5.6.0) .  Works like magic.  
Kind of a pain placing things in the exact area of the page.  But it works well.
https://developers.itextpdf.com/question/generate-pdf-html-using-itextsharpdll

I also found this to be great help when starting:  https://www.mikesdotnetting.com/article/86/itextsharp-introducing-tables
0
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
in addition, you can initially created a PDF as a "template" and then let your programming codes to call it and fill up with relevant values. This was the approach I have done for my previous projects. meaning to say, you no need to create the "whole" PDF from your programming codes. hope this make sense.
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
0
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi Ryan. I have asked a further question which relates to your last suggestion https://www.experts-exchange.com/pendingQuestions/53198/ASP-net-generate-document.html#questionAdd
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.