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

Free Support Forum - aspose.com

PrintDialog NamedAction is done with JavaScript- not Adobe Named Action

I am using Aspose PDF to add a PrintDialog NamedAction as the OpenAction of a generated PDF like so:


var printAction = new NamedAction(PredefinedAction.PrintDialog);
PdfDoc.OpenAction = printAction;

However, the action of launching the print dialog is never fired when this PDF is opened in FireFox, because the action exists as JavaScript within the PDF file. Within the PDF I have found:

8 0 obj
<</Type/Catalog/Version/1.7/Pages 1 0 R/Outlines 2 0R/OpenAction<</S/JavaScript/JS(this.print(true);\015)>>/Metadata 4 0 R>>
endobj

In FireFox’s pdf.js viewer, JavaScript is blocked from running and so the print dialog is never launched (the same is probably true for other pdf readers).

Is it possible to replace how the PrintDialog NamedAction is handled behind the scenes, from JavaScript to a real Adobe named action?

For example:
56 0 obj
<</Type/Action/S/Named/N/Print>>
endobj

This would allow the action to actually be fired in affected pdf viewers.

Hi There,


Thanks for contacting support.

You can add JavaScript against page action. In order to accomplish this requirement, PageActionCollection is implemented. This class has properties:
  • public PdfAction OnOpen
  • public PdfAction OnClose
You may use following code snippet to accomplish your task.

C#

JavascriptAction javascript = new JavascriptAction(“this.print({bUI:true,bSilent:false,bShrinkToFit:true});”);
pdf.OpenAction = javascript;

Moreover, I have tested the scenario with above code and have observed print Dialogue does not appear in Firefox browser. For the sake of correction, I have logged a ticket PDFNET-42481 in our issue tracking system. We will further look into the details of this issue and will keep you updated regarding the resolution of this issue within this forum thread. Please be patient and spare us a little time.

If you still face any issue or your requirement is different as per my understanding, please feel free to contact us.

We are sorry for the inconvenience.

Best Regards,

Hello,

Is there any update with this issue? We still need the functionality as described in the original post.

Thank you.

@dfactset

Thanks for your inquiry.

We would like to share with you that earlier logged issue is currently under investigation process and we are working over resolving the logged ticket. As soon as we have some definite updates regarding its resolution, we will let you know. Please spare us little time.

We are sorry for the inconvenience.

Hi, any update on this issue? We are experiencing this issue with Edge browser as well and works when JavaScript is replaced with Adobe name action, similar to what was suggested in original post. A solution for this is greatly appreciated. Thanks!

@JawDropper

Thanks for posting your inquiry.

Please note that the issue priority is already high and its under process of investigation. However, the issue is quite complex in nature and need more time to get investigated. We have recorded your concerns as well and will definitely consider them during investigation. As soon as some definite updates are available, we will share with you. Please spare us little time.

The issues you have found earlier (filed as PDFNET-42481) have been fixed in Aspose.PDF for .NET 19.4.