Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8996765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:47:55+00:00 2026-06-15T23:47:55+00:00

Following this SO solution here to notify clients of a click event in a

  • 0

Following this SO solution here to notify clients of a click event in a PDF document, how is it possible to notify the client when the PDF gets submitted by the client using this.myPDF.submitForm(“localhost/Handler.ashx?r=2) function?

The PDF File is created inside a user control then rendered into a HTML object:

string container = ("<object data='/myfile.pdf' type='application/pdf'></object>");

The JS file attached to the PDF is done like this:

 var webClient = new WebClient();
 string htmlContent = webClient.DownloadString(fileurl + "pdf_script.js");
 PdfAction action = PdfAction.JavaScript(htmlContnent, pdfstamper.Writer);
 pdfstamper.Writer.SetOpenAction(action);

And the content of the js file:

this.disclosed = true;
if (this.external && this.hostContainer) {

function onMessageFunc(stringArray) {
     try {
          this.myPDF.submitForm("http://localhost/Handler.ashx?EmpNo=12345" + "#FDF", false);

        }
        catch (e) {

        }
    }
    function onErrorFunc(e) {
        console.show();
        console.println(e.toString());
    }
    try {
        if (!this.hostContainer.messageHandler);
        this.hostContainer.messageHandler = new Object();
        this.hostContainer.messageHandler.myPDF = this;
        this.hostContainer.messageHandler.onMessage = onMessageFunc;
        this.hostContainer.messageHandler.onError = onErrorFunc;
        this.hostContainer.messageHandler.onDisclose = function () { return true; };
    }
    catch (e) {
        onErrorFunc(e);
    }
}

When the submitForm call is made the PDF contents (form fields) get saved successfully and an alert is displayed in the PDF by doing this:

message = "%FDF-1.2
                   1 0 obj
                   <<
                   /FDF
                   <<
                      /Status("Success!")
                   >>
                   >>
                   endobj
                   trailer
                   <</Root 1 0 R>>
           %%EOF");
return message;

What I’m trying to do is to get the PDF to callback the client after the form submit call sent from this client, a way to acknowledge the client that the form has been submitted, not in a form of an alert, but rather, a way to trigger a function in the host (the container, an iframe, object…etc).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:47:56+00:00Added an answer on June 15, 2026 at 11:47 pm

    The FDF response you used was unknown to me, so I’ve learned something new from your question. I’ve studied the AcroJS Reference and the FDF specification in the PDF Reference, and now I have a better understanding of what your code does. Thank you for that.

    I assume that you already know how to trigger a JavaScript message in an HTML file using a JavaScript call from a PDF. See the createMessageHandler() in the JavaScript Communication between HTML and PDF article.

    I interpret your question as: “How to I invoke this method after a successful submission of the data?”

    If there’s a solution to this question, it will involve JavaScript. I see that one can add JavaScript in an FDF file, but I’m not sure if that JavaScript can ‘talk to’ HTML. I’m not sure if you can call a JavaScript function in your initial PDF from the FDF response. If it’s possible, you should add a JavaScript entry to your PDF similar to the /Status entry.

    The value of this entry is a dictionary, something like:

    <<
    /Before (app.alert\("before!"\))
    /After (app.alert\("after"\))
    /Doc [/MyDocScript1, (myFunc1\(\)),
          /MyDocScript2, (myFunc2\(\))
    >>
    

    In your case, I would remove the /Before and /Doc keys. I don’t think you need them, I’d reduce the dictionary to:

    <<
    /After (talkToHtml\(\))
    >>
    

    Where talkToHtml() is a method already present in the PDF:

    function talkToHtml() {
        var names = new Array();
        names[0] = "Success!";
        try{
            this.hostContainer.postMessage(names);
        }
        catch(e){
            app.alert(e.message);
        }
    }
    

    I don’t know if this will work. I’ve never tried it myself. I’m basing my answer on the specs.

    I don’t know if you really need to use FDF. Have you tried adding JavaScript to your submitForm() method? Something like:

    this.myPDF.submitForm({
        cURL: "http://localhost/Handler.ashx?EmpNo=12345",
        cSubmitAs: "FDF",
        oJavaScript: {
            Before: 'app.alert("before!")',
            After: 'app.alert("after")',
            Doc: ["MyDocScript1", "myFunc1()",
                  "MyDocScript2", "myFunc2()" ]
        }
    });
    

    This will only work if you submit as FDF. I don’t think there’s a solution if you submit an HTML query string.

    In case you’re wondering what MyDocScript1 and MyDocScript2 are:

    Doc defines an array defining additional JavaScript scripts to be
    added to those defined in the JavaScript entry of the document’s name
    dictionary. The array contains an even number of elements, organized
    in pairs. The first element of each pair is a name and the second
    is a text string or text stream defining the script corresponding
    to that name. Each of the defined scripts is added to those already
    defined in the name dictionary and then executed before the script
    defined in the Before entry is executed. (ISO-32000-1 Table 245)

    I’m not sure if all of this will work in practice. Please let me know either way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This solution does not work for IE9. I have the following code: $(document).ready(function() {
I'm following the example here : http://www.codeproject.com/KB/aspnet/BilingualMvc3Part2.aspx Edit: This solution works for Firefox, and
Following this question, it seems that it is possible to open a file from
Following this tutorial (http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/handling-concurrency-with-the-entity-framework-in-an-asp-net-mvc-application), I learned how to save data and do concurrency checks
I am looking for a simple solution to the following problem: I am using
I am following this guide to installing and using MSpec, but at the step
So I found this solution on StackOverflow here: Vim 80 column layout concerns If
I have already looked at this question but there was no solution. Here is
Hi I'm trying to animate a background image using jQuery, I tried following this
While debugging, I notice the following with this C# app I have here: It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.