Click here to Skip to main content
12,399,799 members (46,434 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
how to create pdf file in vb.net Wink | ;)
Posted 20-Feb-11 19:29pm
Comments
Whilone33 5-Feb-16 5:58am
   
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Member 12314871 8-Feb-16 17:13pm
   
If I'm looking for a VB.NET solution, why would I want to look at a C# example?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

You can also just use the CrystalDecisions.CrystalReports.Engine.ReportClass to export to a pdf file.
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 5

Microsoft .NET doesn't yet include a PDF component, so you'll need to use a third-party component, unless you enjoy doing stuff the hard way, and have plenty of time to spare.

Here are a few popular components for the task - ABCpdf.NET, iTextsharp, PDFSharp.

Some of these are free for personal use, but for commercial purposes you may need to purchase a license. It's certainly worth checking the small print before you begin Wink | ;-)

Here's a quick example in VB.NET to show how easy PDF generation can be...

Dim theDoc As Doc = New Doc()
theDoc.FontSize = 96
theDoc.AddText("Hello World")
theDoc.Save("simple.pdf")
theDoc.Clear()

The example above uses the ABCpdf component from WebSupergoo.

All these components feature their own native drawing commands, which enable you to draw and construct pages and documents. One of the differences between these components is what other methods of layout and formatting they offer, e.g. HTML & CSS, Drawing2D, WPF, Flash, PostScript. If you already know one of these, and your chosen components support it, this can help you get up to speed and generate more complex layouts sooner.
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 8

I am not try this code
You can try and give me reply what happen


Private Sub prn_PrintPage(ByVal sender As System.Object, _
                             ByVal e As System.Drawing.Printing.PrintPageEventArgs)
 
       e.Graphics.DrawString("Hello from VB.NET", New Font("Arial", 60, FontStyle.Regular), _
                             Brushes.Blue, 100, 100)
 
   End Sub
 
   Private Sub PrintTest()
       Dim DC As Object = CreateObject("Neevia.docCreator")
 
       DC.setParameter("DocumentOutputFormat", "PDF")
       DC.setParameter("DocumentOutputName", "testVBNET")
       DC.setParameter("DocumentOutputFolder", "d:\")
 
       Dim prn As New System.Drawing.Printing.PrintDocument
       AddHandler prn.PrintPage, AddressOf prn_PrintPage
       prn.PrinterSettings.PrinterName = "Neevia docCreator"
 
       Dim tempFile As String = DC.getParameter("TempDir") + DC.GUID + ".ps"
 
       prn.PrinterSettings.PrintFileName = tempFile
       prn.PrinterSettings.PrintToFile = True
 
       prn.Print()
 
       DC.setInputDocument(tempFile)
 
       Dim RVal As Integer = DC.create()
       DC.fileDelete(tempFile)
 
       prn = Nothing
       DC = Nothing
 
       If (RVal <> 0) Then
           MsgBox("Error while creating document!!!")
       Else
           MsgBox("Done !!!")
       End If
   End Sub
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 9

There is a CodeProject article that explains how to create PDFs and includes a C# library that you can use to create PDFs. You can call the C# library from VB .NET.

See PDF File Writer C# Class Library[^]
  Permalink  
Comments
Member 12314871 8-Feb-16 17:16pm
   
If I am looking for a VB.NET solution why would I view a C# example? Isn't there a C# section on this site these responses could be moved to?
Mike Meinz 8-Feb-16 17:46pm
   
You could use one of the online C# to VB.NET converter tools to make a VB.NET version for your use.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Please look into following link

http://itextsharp.com/[^]
  Permalink  
Comments
Member 12314871 8-Feb-16 17:17pm
   
If I am looking for a VB.NET solution why would I view a C# example? Isn't there a C# section on this site these responses could be moved to?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

What do you exactly want, creating a PDF or convert a document to PDF?
You can use itextsharp[^] to create PDF.

Here are some articles(in C# unfortunately) from where you can get idea.
ITextSharp Helper Class[^]
Tutorials on creating PDF files using C# 2.0[^]
  Permalink  
Comments
Member 12314871 8-Feb-16 17:17pm
   
If I am looking for a VB.NET solution why would I view a C# example? Isn't there a C# section on this site these responses could be moved to?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 6

I found this post when I searching for something about PDF.

Actually, others have given the solutions. But I want to show my solutions.

Code

//Create a pdf document.
PdfDocument doc = new PdfDocument();
 
// Create one page
PdfPageBase page =doc.Pages.Add();
 
//Draw the text
page.Canvas.DrawString("Hello, World!",
                       new PdfFont(PdfFontFamily.Helvetica, 30f),
                       new PdfSolidBrush(Color.Black),
                       10, 10);
 
//Save pdf file.
doc.SaveToFile("HelloWorld.pdf");

How about this? I create it with a third party component
  Permalink  
Comments
Member 10424878 6-Aug-14 6:53am
   
There must be a .DLL file that you use, it doesn't work for me...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 28 Oct 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100