Has anyone tried using this sample project to select/file print a .pdf? What is supposed to happen? All I get is errors with any .pdf I pick...
C:\Program Files (x86)\Tracker Software\PDF-XChange 4 API\Examples\APIExamples\C#Examples\PDFdriverAPI
Error : No application is associated with the specified file for this operation
Error on : printJob.Start();
C#Examples \ PDFdriverAPI
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: C#Examples \ PDFdriverAPI
NRSGNT wrote:Has anyone tried using this sample project to select/file print a .pdf? What is supposed to happen? All I get is errors with any .pdf I pick...
C:\Program Files (x86)\Tracker Software\PDF-XChange 4 API\Examples\APIExamples\C#Examples\PDFdriverAPI
Error : No application is associated with the specified file for this operation
Error on : printJob.Start();
Hello,
This error occurs because the print system must execute a program associated with the file type you are printing to render it before passing it to the print driver. In the example code there is a filter that only allows you to open .txt and .doc files, but you can change it to allow other file types as well. If you are trying to load a .doc or .txt file with the sample application, check to ensure that (within windows) you have a default application (for example notepad, or MS Word) associated with the .txt or .doc file type.
It sounds like you have changed the filters to allow it to load a PDF file (and then save a new PDF). If you do this, it will call whatever program is associated with PDF files (at the Windows operating system level), which loads the PDF, renders it, and passes it on to the print driver. If you install our PDF-XChange Viewer and ensure it is associated with PDF files, this would work. Presumably it will work with other PDF viewers, but I have only tested this example specifically with our PDF viewer.
Sincerely,
Walter Ash
Tracker Support
Re: C#Examples \ PDFdriverAPI
I have Adobe Reader installed, hmmm. Can I use the PDFXviewer in a console application (i.e. no GUI) to print a pdf to the default print driver (i.e. PDFXchange)?
-
- User
- Posts: 381
- Joined: Mon Jun 13, 2011 5:10 pm
Re: C#Examples \ PDFdriverAPI
In the example project (PDFdriverAPI) you can replace this function with the following code and it will print to PDF silently, assuming you have PDFXViewer set as your default PDF viewer in Windows.NRSGNT wrote:I have Adobe Reader installed, hmmm. Can I use the PDFXviewer in a console application (i.e. no GUI) to print a pdf to the default print driver (i.e. PDFXchange)?
Code: Select all
private void bFilePrint_Click(object sender, EventArgs e)
{
PDFPrinter.SetAsDefaultPrinter();
bPXCPrinterDefault = true;
PDFPrinter.set_Option("Save.ShowSaveDialog", false);
PDFPrinter.set_Option("Save.File", "c:\\test.pdf");
System.Diagnostics.Process printJob = new System.Diagnostics.Process();
printJob.StartInfo.FileName = "c:\\testinput.pdf";
printJob.StartInfo.UseShellExecute = true;
printJob.StartInfo.Verb = "print";
printJob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
printJob.Start();
}
Code: Select all
PDFPrinter.set_Option("Save.WhenExists",1); // value of "1" overwrites as documented in the PDFX driver API documentation
Code: Select all
PDFPrinter.set_Option("Save.RunApp",false);
Hope this helps.
Walter Ash
Tracker Support