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

Last post 02-09-2012, 1:40 PM by codewarior. 1 replies.
Sort Posts: Previous Next
  •  02-08-2012, 5:02 AM 360025

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

    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.
     
  •  02-09-2012, 1:40 PM 360501 in reply to 360025

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

    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.

    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML