PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

add willprint event to pdf
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3798
Page 1 of 1

Author:  hamayr [ Wed Jun 06, 2018 5:25 am ]
Post subject:  add willprint event to pdf

Hi, how can i add a will print event using pdfsharp? i am trying to add make it so that it can add a watermark if anyone tries to print the pdf. according to pdfreference, i need to add AA catalog but i dont know how to proceed from there. here is my code to try adding the willprint event.


Code:
                string action = "app.alert(\"Hello!\", 3);";
                dict.Elements["/S"] = new PdfName("/O");
                dict.Elements["/JS"] = new PdfStringObject( document , action);

                document.Internals.AddObject(dict);
                document.Internals.Catalog.Elements["/AA"] = PdfSharp.Pdf.Advanced.PdfInternals.GetReference(dict);




any help is appreciated.

Author:  TH-Soft [ Wed Jun 06, 2018 5:36 am ]
Post subject:  Re: add willprint event to pdf

Hi!

Maybe you already used this sample as a reference:
http://pdfsharp.net/wiki/WorkOnPdfObjects-sample.ashx

I have no idea what a "will print" event can achieve and how to use it.

Author:  hamayr [ Wed Jun 06, 2018 5:49 am ]
Post subject:  Re: add willprint event to pdf

TH-Soft wrote:
Hi!

Maybe you already used this sample as a reference:
http://pdfsharp.net/wiki/WorkOnPdfObjects-sample.ashx

I have no idea what a "will print" event can achieve and how to use it.



I already read that wiki. and I did have it working with a openaction event. but i cant use the other event triggers like will print, did save, etc. according to pdfreference "Event triggers" page, it says in order to use the other actions, i need to use "additional actions". but i cant figure out how to add the key for the event and the javascript itself

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/