Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print to pdf file from VB.Net (not export)

Status
Not open for further replies.

klgrube

Programmer
May 29, 2002
28
US
Hi!

I have a VB.Net program that currently exports a report to a pdf file. The problem is that it comes out funny looking. For some reason the export capability for PDF files just isn't quite perfect yet.

However, when I manually print the report to a pdf file using the "Adobe PDF" printer, it comes out fine. So, what I'd like to do is change the VB.Net program so it prints to a PDF file. However, I can't figure out how to specify an output filename within the code. Here's the original code:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
strPDFFilename = "\TodaysReport.pdf"
rpt.Load("c:\CrystalReports\TodaysReport.rpt", OpenReportMethod.OpenReportByTempCopy)
rpt.ExportToDisk(ExportFormatType.PortableDocFormat, strPDFFilename)
Application.Exit()


This works, but the output has some formatting problems.
So I need to replace the export file code with the following:

rpt.PrintOptions.PrinterName = "Adobe PDF"
rpt.PrintToPrinter(1, True, 1, 999)

However, I don't know how to specify the output file name for the PDF file.

Any guidance would be greatly appreciated.

Thanks!
Karen Grube
klgrube@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top