Does your sdk have an API that can be called to print a pdf document?
Regards,
Paul Pannozzo
iView Systems
Printing
Re: Printing
Support · Sep 18, 2007Hello Paul,
There is no such functionality in our product, which can be used for the printing of PDF documents. However in v4.0 of DynamicPDF Generator for NET we have added the functionality to add Javascript to the document. Using the Javascript you can force the document to be printed directly to the default printer without using the print preview. But the document would need to be output to the web for the Javascript action to be triggered.
SAMPLE CODE
===========
ceTe.DynamicPDF.Document document = new ceTe.DynamicPDF.Document();
ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page( PageSize.Letter, PageOrientation.Portrait, 54.0f );
string text = "Hello ASPX C# World...\nFrom DynamicPDF™ Generator for NET\nDynamicPDF.com";
Label label = new Label( text, 0, 0, 504, 100, Font.Helvetica, 18, TextAlign.Center );
// Adding Javascript to the document
DocumentJavaScript javaScript = new DocumentJavaScript( "Test", "this.print({bUI: false, bSilent: true, bShrinkToFit: true});" );
document.JavaScripts.Add( javaScript );
page.Elements.Add( label );
document.Pages.Add( page );
document.DrawToWeb( "HelloWorld.pdf" );
Thanks,
ceTe Software Support Team.
Re: Printing
Forum member · Sep 18, 2007Thanks for your reply. However, I'm trying to do this in a web form application. I have a web browser control which I'm using to view the pdf file that was generated so I'm a little confused as how to send the page to the web.
Regards,
Paul
Re: Printing
Forum member · Sep 18, 2007Sorry, I mean Winform application - not web form.
Re: Printing
Support · Sep 18, 2007Hello Paul,
You can add IE control to the winform and you can display the PDF in that IE control. You can refer to the winform examples downloaded with the product download which uses IE control in a winform and displays the PDF in the winform.
You can also use the Ghostscript Site
to accomplish your printing needs.
Following is the example which shows integration of Ghostscript with our product.
Note: In order to use the System.Diagnostics.Process class you will have to include "using System.ComponentModel" class library.
C# Code:
=======
ceTe.DynamicPDF.Document document = new ceTe.DynamicPDF.Document();
ceTe.DynamicPDF.Page page = new ceTe.DynamicPDF.Page( PageSize.Letter, PageOrientation.Portrait );
Label label = new Label( "Hello World", 0, 0, 504, 100, ceTe.DynamicPDF.Font.Helvetica, 18, TextAlign.Center );
page.Elements.Add( label );
document.Pages.Add( page );
document.Draw( @"C:\Temp\HelloWorld.pdf" );
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "C:\\gs\\gs8.50\\bin\\gswin32c.exe";
process.StartInfo.Arguments = "-dNOPAUSE -dNoCancel -sDEVICE=mswinpr2 -sOutputFile=\"%printer%<Your Printer Name>\" \"C:\\Temp\\HelloWorld.pdf\" -c quit";
process.Start();
Thanks,
ceTe Software Support Team.
Re: Printing
Forum member · Oct 5, 2007This sounds great. The problem that I am running into is that my instance of the document is the aspx page itself. For example, the only thing that I have in the page_load event of my codebehind page is the following.
Parameters.Add("RequestID", RequestID)
DrawPdfToWeb("PrintForm.pdf")
I am not creating a new instance of a document, so how do I add the javascript to the current instance?
Re: Printing
Support · Oct 8, 2007Hello Paul,
You can create a document object by using the DocumentLayout class which takes the path of the dplx file. You can also refer to the using dplx files
topic on our help documentation. Following is the sample code for this.
DocumentLayout report = new DocumentLayout(@"C:\Temp\Invoice.dplx");
ParameterDictionary dictionary = new ParameterDictionary();
dictionary.Add("RequestID", RequestID);
Document document = report.Run(dictionary);
//You can add javascript to the document here.
doc.DrawToWeb();
Thanks,
ceTe Software Support Team.
Re: Printing
Forum member · Oct 8, 2007Thanks for the reply. It now prints a copy when it displays. That rocks! The only issue that I have is that it is not displaying any information to the user to tell them that it is printing. I tried adding an alert box to the javascript, but it seemed to break the printing functionality. Is there any way to accomplish this? Is there a way to allow them to pick the printer in case their default printer is not the correct one?
Also, at risk of piggy-backing a somewhat unrelated question, whenever the document does display, is there any way to display it in 100% mode?
Re: Printing
Support · Oct 8, 2007Hello Paul,
You can add an alert after printing the PDF document to the default printer without any problem. Please make sure that you have added a correct javascript. Following is the sample code to add an alert.
// Adding Javascript to the document for printing
DocumentJavaScript javaScript = new DocumentJavaScript( "Test", "this.print({bUI: false, bSilent: true, bShrinkToFit: true});" );
document.JavaScripts.Add( javaScript );
// Adding Javascript to the document for alert
string script = "app.alert('Printed')";
document.JavaScripts.Add(new DocumentJavaScript("print", script));
It is not possible to allow the user to select a printer. The document will be sent to the default printer.
It is not possible to set the default zoom level to 100% however you can use the PageZoom enumeration to set the InitialPagezoom property of the document. You can set it to FitWidth, FitHeight, FitPage etc.
Thanks,
ceTe Software Support Team.
Re: Printing
Forum member · Oct 11, 2007I'd like to interject. I'm working on an app in which we generate PDFs using your product, and now I'm trying to print the PDFs. I found this thread and tried the code oulined in the post dated Sep 18 2007 11:38 AM.
However, we can have upwards of 500 PDFs to print, and so I placed the code in a large loop. When I tried this, the GhostScript EXEs are run in rapid succession, at virtually the same time.
Could you possibly provide some sample code that would demonstrate how best to print so many documents? I'd like to be able to run one print process at a time, and catch any exit codes from the previous process before starting the next one. Thanks in advance.
Re: Printing
Support · Oct 11, 2007Hello,
We do not have any sample code that shows how to print multiple documents in a batch process using GhostScript. We do not have any printing functionalities built into our product and there may be some switch available in GhostScript using which you may be able to perform batch printing.
You can try printing each document and then check using System.Diagnostics.Process object's HasExited property whether the current process has been terminated before starting the new process.
Thanks,
ceTe Software Support Team
Re: Printing
Forum member · Jun 18, 2008"You can add IE control to the winform and you can display the PDF in that IE control. You can refer to the winform examples downloaded with the product download which uses IE control in a winform and displays the PDF in the winform. "
Where I can find examples to use IE control?
thanks
Re: Printing
Support · Jun 18, 2008Hello,
The IE control is called the Microsoft Web Browser Control and can be added by right clicking the toolbox and clicking on "Add/Remove Item" or "Choose Item" depending on version of Visual Studio. On the COM Components tab, check the "Microsoft Web Browser" control. Click OK to add the WebBrowser control to the Windows Forms toolbox. Then drag the control on the form.
Thanks,
ceTe Software Support Team