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

Free Support Forum - aspose.com

How to call a URL from PDF without letting the user know about it using ASP .Net

Hi,

I’m trying to submit user information, without their knowledge, to an api at the time of opening the pdf document.
I tried using
PDFDocument doc = new PDFDocument();
JavascriptAction action = new JavascriptAction(“app.LaunchURL(‘urlname’)”);
doc.OpenAction = action;

But this is opening the url in new browser. Please suggest some way to resolve this ?

@maddy90

You can add a submit button in your PDF document using following code snippet:

Document doc = new Document(dataDir + "inputForm.pdf");
Facades.FormEditor add = new Facades.FormEditor(doc);
add.AddSubmitBtn("btnSubmit", 1, "Submit", "mailto:myemail@mail.com?subject=My Subject&body=Here is my form data.", 400, 20, 500, 50);
add.SetFieldAppearance("btnSubmit", AnnotationFlags.Print);
add.SetSubmitFlag("btnSubmit", Facades.SubmitFormFlag.Pdf);
doc.Save(dataDir + "AddTextBox.pdf");

In the above code snippet, we used an email address to send PDF to. You may replace it with the URL where you want to send the PDF document. In case it does not satisfy your requirements, please let us know.

Hi Asad,
@asad.ali

Thanks for the reply. However, this will work on button click. I want to call URL automatically as the PDF document is opened.

and the below mentioned line is not taking the control to the mentioned URL on button click.
add.AddSubmitBtn(“btnSubmit”, 1, “Submit”, “https://urlpath”, 400, 20, 500, 50);

Please let me know if there is anything to automatically call the URL when the PDF is opened.

@maddy90

Usually, the Adobe Reader opens the Web URLs in new tab and we need to investigate whether it is possible to open or call the URL without opening new tab or not. For the purpose, we have logged an investigation ticket as PDFNET-48715 in our issue tracking system. We will furhter investigate it and keep you informed with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi @asad.ali

Any update on this issue ?

@maddy90

The ticket has recently been logged in our issue management system and we are afraid that it is pending for review. We will surely look into its details on first come first serve basis and inform you as soon as we have some additional updates regarding its resolution. Please give us some time.

We are sorry for the inconvenience.