VB 6.0 - Creating pdf from Visual Basic 6.0 - Asked By Eric Smith on 04-Feb-10 04:00 PM

We have an application written VB 6.0 for creating EDI Invoices in Monarch 5.0 format and we have a web page that users go to view/download the invoices.  Users have to have Monarch installed on their computer to view the invoices.  At one of are user's company they recently upgraded to Windows 7 and they are getting an error messages with stating that Monarch is an incompatible program, so it doesn't look like our current version of Monarch will run on Windows 7 - their IT department is looking to see if they can get Monarch to run.  The lastest version of Monarch is 10.0 and if we upgrade to that we are looking at over $130,000 which I don't believe is in our budget.  We were looking at seeing if was possible from Vb 6.0 to pull information for the invoice from the database and create the invoices in pdf.  I have been researching for tutorials and not finding any usefull ones.  Can anyone provide some helpful links, even better would be sample project to download and play with source.  Thanks!

Venkat K replied to Eric Smith on 04-Feb-10 09:36 PM

Generate PDF documents from visual basic using mjwPDF which can download from here includes some PDF Fonts also:

http://www.vb6.us/files/tutorials/CreatingPDFdocuments/mjwPDF-class.zip

Here is how you can create a simple PDF File:

  1. Private Sub Command1_Click()
  2.     ' Create a simple PDF file using the mjwPDF class
  3.     Dim objPDF As New mjwPDF
  4.    
  5.     ' Set the PDF title and filename
  6.     objPDF.PDFTitle = "Test PDF Document"
  7.     objPDF.PDFFileName = App.Path & "\test.pdf"
  8.    
  9.     ' We must tell the class where the PDF fonts are located
  10.     objPDF.PDFLoadAfm = App.Path & "\Fonts"
  11.    
  12.     ' View the PDF file after we create it
  13.     objPDF.PDFView = True
  14.    
  15.     ' Begin our PDF document
  16.     objPDF.PDFBeginDoc
  17.         ' Set the font name, size, and style
  18.         objPDF.PDFSetFont FONT_ARIAL, 15, FONT_BOLD
  19.        
  20.         ' Set the text color
  21.         objPDF.PDFSetTextColor = vbBlue
  22.        
  23.         ' Set the text we want to print
  24.         objPDF.PDFTextOut _
  25.             "Hello, World! From mjwPDF (www.vb6.us)"
  26.    
  27.     ' End our PDF document (this will save it to the filename)
  28.     objPDF.PDFEndDoc
  29. End Sub

For complete process checkout this link:

http://www.vb6.us/tutorials/visual-basic-tutorial-pdf (This page consists of two tutorials basic and advanced)

Hope this helps!

Thanks

 

Eric Smith replied to Venkat K on 05-Feb-10 11:28 AM

Thank you for the information.  I have been playing around with that for a couple of hours and not really likely it so far, but will keep messing around in it.  I aslo have download PDF Creator Pilot found here:  http://www.colorpilot.com/pdfcreatorpilotmanual/How_to_write_text_in_a_PDF_document_4.html.  I am liking this alot better and its been easier creating the layout of the invoice so far and I think this would be better in the future if we need change the layout of the invoice. 

Keep the suggestions coming as I want to try several more options.