3

Here is the context :

I am writing a Python code that converts an HTML page to a PDF file using the instructions in this link. I work now on the POST request that will have as an input an HTML file, and have some parameters precised in the latter link.

The link states that the HTML input file has to be defined by some parameters, grouped in this example:


image

in this example, I don't get what's the meaning of this part : "json": "[\"a\": \"b\"]" ? and how can I adapt it to my case.

So I am struggling with how to precise the parameter highlighted in yellow in the image above.

Here is the question :

The litterature states concerning this field (cpf:inputs > params > cpf:inline > json) states the following:

json(string, optional)

JavaScript variables to be placed in global scope to reference while rendering the HTML.
This mechanism is intended to be used to supply data that might otherwise be retrieved using ajax requests.
The actual mechanics of accessing this content varies depending if rendering from a zip file or from a url.
When rendering from a zip file, the source collateral must include a script element such as:

<script src='./json.js' type='text/javascript'></script>

When rendering from a URL, the content of this json object is injected into the browser VM before the page is rendered.

default: {}

It will help if someone can just read and explain to me the meaning of this quoted text above. thanks!

CBroe
  • 91,630
  • 14
  • 92
  • 150
A. B.
  • 41
  • 4

1 Answers1

0

If you don't want to do an Ajax request every time you use your script, you can visit the ajax page, copy the entire content with Ctrl+A, and then paste it into an empty javascript file you can save as module.js for example. When you come to the point where you'd usually do the request, you can replace it by . Good luck!

PS: Your question is very well formulated, I would have upvoted it, but I haven't got enough reputation now...

Lvn Rtg
  • 54
  • 6
  • Thanks! in that text (by the end of my question), what do they mean by "the source collateral" ? thanks! ___ they said : "When rendering from a zip file, the **source collateral** must include a script element such as: ````" – A. B. Jul 20 '21 at 12:19
  • The part in yellow is JSON encoded JSON. To your second question, it means your HTML file has to include that line. That's how it reads in your source JSON. – Raymond Camden Jul 21 '21 at 13:35