Solved

Print to PostScript Printer with Crystal Reports Basic in VS 2008

Posted on 2009-05-14
9
1,016 Views
Last Modified: 2012-05-07
Issue: Printing to postscript printer prompts for filename

I am trying to print via .net  to a postscript printer.  However, my version of crystal reports in Visual Studio 2008 does not come with this method...of which others claim to fix the issue?

reportDocument.PrintToPrinter(printerSettings, pageSettings, True) ?

I have checked and there does not exist an overloaded method in the .net object browser for this 'PrintToPrinter' method that would accept PrinterSettings object??

The only method I have is as below:
===============================
public virtual void PrintToPrinter(int nCopies, bool collated, int startPageN, int endPageN)
Member of CrystalDecisions.CrystalReports.Engine.ReportDocument

Summary:
Prints the specified pages of the report to the printer selected using the PrintOptions.PrinterName property. If no printer is selected, the default printer specified in the report will be used.

Parameters:
nCopies: Indicates the number of copies to print.
collated: Indicates whether to collate the pages.
startPageN: Indicates the first page to print.
endPageN: Indicates the last page to print.
===============================
My version is Crystal Reports Basic and is what comes with VS 2008 (not upgraded):

From the GAC:
CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0
FileVersion: 10.5.0.1943
.NET FRAMEWORK v3.5 SP1

Please help.

Thanks,

EM
string reportpath = Server.MapPath(string.Format(@"Reports\{0}.rpt", reportName));

            ConnectionInfo connectionInfo = SetReportConnection(PageConnection);

            ReportDocument oRpt = new ReportDocument();

            oRpt.Load(reportpath);

            SetDBLogonForReport(connectionInfo, oRpt);

            SetCurrentValuesForParameterField(oRpt, rptParams);

            PrinterSettings printerSettings  = new PrinterSettings();

            PageSettings pageSettings = new PageSettings();

          

           //CopyFrom also does not work !

            oRpt.PrintOptions.CopyTo(printerSettings, pageSettings);

            printerSettings.PrinterName = "Win2PDF";

            printerSettings.PrintFileName = szFileName;

            printerSettings.PrintToFile = true;

//other posts on forums claim that this fixes the issue, but my compiler doesn't recognize

            // and searching object browser does not find any overloaded methods. 

           // oRpt.PrintToPrinter(printerSettings, pageSettings, true);
 

            

           oRpt.PrintToPrinter(1, false, 0, 0);

Open in new window

0
Comment
Question by:RBCLS
  • 4
  • 3
  • 2
9 Comments
 
LVL 34

Expert Comment

by:James0628
Comment Utility
I don't know that I'll be able to help with your problem, because I don't run reports this way, but I may be able to help get things started by asking for some clarification.

 Are you trying to print to an actual PostScript printer, or to a "virtual" PDF printer?  I assumed that you were referring to a physical printer that used the PostScript language, but then I saw the Win2PDF in your code.

 James
0
 

Author Comment

by:RBCLS
Comment Utility
Thank you so much for your response and help. Here is the info you requested:
I stand corrected, it is a 'virtual' pdf printer. You are correct in your assumption, it is Win2PDF.  
My goal is to print to a high quality pdf document that is as close as possible to output generated from printing the crystal report directly from the crystal report viewer. The Crystal Reports Export to Pdf does not produce an acceptable level of quality for our print purposes.  It shrinks the font and page regardless of the type of font used or page margins specified. Hence, I have chosen this method of printing the report.
My problem is that regardless of the printer type, I need to specify the filename, but Crystal Reports despite offering an ability to '.CopyFrom' and CopyTo' printer/page settings, it does not seem to pass or even use the PrintFileName property (though other properties are correctly utilized in this method).  When running the application that calls the code, it still prompts for a filename? I have tried printing to XPS Document printer and I get the same problem.  
I just keep thinking..... Why would Crystal offer that functionality and then not utilize it?  I hope that my code is just incorrectly calling or using the wrong properties for the printertoprinter method, as I am now very reluctantly resorting to using a WIN32 API method to print as after talking to management, there is not any other motivation or desire to upgrade to Crystal 2008.  What is more fustrating is that previous versions of Crystal, it was very easy to print to a file, so I am feeling very silly that I can't do this in .NET.
 
EM
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
That may be the Win2PDF doesn't interface with Crystal properly.  I have printed directly to a file in code and can specify a filename.

You have to set it up before the printtoprinter

mlmcc
0
 

Author Comment

by:RBCLS
Comment Utility
Dear Mlmcc,
Thank you for your response.
In my code sample, I am specifying the filename and then I call the PrintToPrinterMethod.
From code sample posted:
-------------------------------
printerSettings.PrintToFile = true;
printerSettings.PrintFileName = szFileName;
<.......other code, etc.....>
oRpt.PrintToPrinter(1, false, 0, 0);
 -------------------------------
Can you send me a code sample of how you set the filename?  Also, are you using the basic or upgraded version of Crystal Reports that comes with Visual Studio 2008?
Thanks,
EM
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
My samples are from earlier versions of Crystal and in VB using the RDC so the code wouldn't apply.

mlmcc
0
 

Author Comment

by:RBCLS
Comment Utility
Me too! I have a version that works perfectly in VB6 and with the RDC as well that i created a few years ago, hence I feel like a complete idiot that I can't get this working in the basic version of Crystal Reports that comes bundled with VS 2008?  What is more infuriating, is that CR offers an export to PDF functionality that is really subpar in terms of output giving you the allusion that creating pdfs from crystal reports would be somewhat natively supported...but oh how misleading....I am tempted to try a trial version of the upgrade just to see if this works in that version as other forum post users claim, but I have already recieved management directive that purchasing the upgrade is NOT desired.
0
 
LVL 34

Expert Comment

by:James0628
Comment Utility
Hmm.  I've always thought that the PDF files created by CR's export function looked pretty much perfect, but maybe you just have requirements that I don't have.  It's possible that you're right about it shrinking things and it's just never been an issue here.  

 I wish I could help, but I just don't run reports from code like that.  Just for the heck of it, have you tried a different PDF "printer"?  "CutePDF Writer" is the one that I happen to use, but there are any number of others.

 James
0
 
LVL 100

Accepted Solution

by:
mlmcc earned 250 total points
Comment Utility
ACcording to his, the .Net versionn doesn't support local printing.
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f08d00a7-951e-2b10-f1a7-a279f68bfba4

mlmcc
0
 

Author Comment

by:RBCLS
Comment Utility
Thank you MLMCC. This solves my delimma as the documentation from the software clearly states that local printing is NOT supported in my edition of the product. Therefore, we need to Upgrade to Crystal Reports 2008 Professional or use Win32 API or maybe get the .net namespace system.printing to print it (of which my current implementation gives a strange GDI error!)....Anyways, at least I can confirm that the ability to print to file in my edition of Crystal has not been included by the software vendor, so I will not waste any more futile attempts at that method of printing to file. Thank you for your post.
EM
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now