Build a PDF document


In my 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
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
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.

You can use pdfsharp library to create PDF document with VB.Net. You can dowload it from this site:
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"
    End Sub
End Class

Open in new window


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 ChongSoftware Team LeadCommented:
I'm using iTextSharp.

You can get it via Nuget Package Manager.


you can further google for plenty of examples.
JS ListCommented:
I use iTextSharp because it's free (Verson .  Works like magic.  
Kind of a pain placing things in the exact area of the page.  But it works well.

I also found this to be great help when starting:
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Ryan ChongSoftware Team LeadCommented:
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.
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks very much
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi Ryan. I have asked a further question which relates to your last suggestion
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

From novice to tech pro — start learning today.