We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Pdf for Java - Include the auto print capability via javascript in an existing pdf file

Hello,
I have an existing pdf created using Aspose.Words for java api.
Now I want to include in this pdf an auto print capability, so that, when the user open the pdf, he'll get automatically the acrobat print dialog.
Question : the Aspose.Pdf for java include Javascript(s) classes, is it possible to do that with Aspose.Pdf (I mean Aspose.Pdf NO Aspose.Pdf.Kit).
Here is a snippet of my code which fails on "You are in direct-to-file mode,please use Close() instead of Save()".

...
// create PDFContentEditor object
Pdf pdf = new Pdf(new BinaryFileStream(pdfFile.getName()));
// Add the javascript auto print capability
pdf.setJavaScripts(new JavaScripts());
pdf.getJavaScripts().add(new JavaScript("this.print(true);"));
pdf.save(pdfOutputPath);
...

Thanks by advance.

Hello
Gilles,


Thanks for using our products and sorry for replying you late.

Aspose.Pdf for Java is a component which provides the capability to create PDF documents from scratch. Whereas Aspose.Pdf.Kit for Java is a component which provides the facility to edit/manipulate existing PDF files. As per your requirement, you need to add JavaScript to an existing PDF file so in current circumstances, you need to try using Aspose.Pdf.Kit for Java. For more information, please visit Adding Javascript actions to a PDF file

PS, Aspose.Pdf for .NET is a single component which provides the feature to create as well as manipulate existing PDF documents. Please note that recently we have merged Aspose.Pdf for .NET and Aspose.Pdf.Kit for .NET and now this single product provides the combined features. The merged version of Aspose.Pdf for Java is under development and once this product is ready, it will provide the capability to create as well as manipulate existing PDF files.