How to print a pdf file?

  • Thread starter Thread starter ywchan
  • Start date Start date
Y

ywchan

I want to automate the action of print a pdf file in a C# Application
How can I do this?
Thanks
 
ywchan,

Add a Crystal Report to your project, set all of the properties as needed so
your report looks the way you want it. Then, add the following code:

private void Form1_Load(object sender, System.EventArgs e)
{
CrystalDecisions.CrystalReports.Engine.ReportClass x = new
CrystalReport1();
x.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
@"C:\MyPDF.pdf");
}

Try this link for additional help...

http://support.businessobjects.com/communityCS/TechnicalPapers/rtm_designerandwinformsviewer.pdf

Anthony
 
Oh... I think you have misunderstood what I mean.
Actually, I only need to automate the process of printing a pdf file and
it is not generated from crystal report. They are just some simple pdf
documents.

Thanks
 
If you have Acrobat Reader installed you can do something like this

System.Diagnostics.ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.Arguments = @"/p /h c:\yourfile.pdf";
startInfo.FileName = @"C:\Program\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe";
startInfo.UseShellExecute = true;

System.Diagnostics.Process process = Process.Start(startInfo);
process.WaitForExit();

/Henke
 
Try invoking the action verb "print" against the PDF document using
ShellExecuteEx API, or something equivalent in .NET.

thanks!
-Yasutaka
 
Back
Top