Help ! PDF.JS: how to insert dynamic value of variable

Hello everyone,

I m implementing a simple script to read PDF on the webpage (PDF.JS).

Everything is working well when it is a static address like in the software example:

inside the javascript:

var url = ‘https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf’;

but when I try to import a dynamic value from AppConnect it doesn’t work.

I tried

var url = dmx-parse(‘content.var1.value’) and other kind of things but nothing… in the browser console I got message that parse is undefined

any suggestion please ?

There is no

dmx-parse('content.var1.value')

the correct syntax is:

dmx.parse("content.var1.value")

I read dmx-parse somewhere in the community :sweat_smile:

Still doesn’t work.

The var1 is declare as following:

then the script where you can find:

var url = dmx.parse(“content.var1.value”);
console.log(url);

if in the url variable I write a static address, it works properly and I see it in the log, instead, if I write dmx.parse

When and how exactly are you calling this?

2 Likes

Maybe it is a timing issue…

When the javascript code is calling the var1, var1 contains no value yet

Check this and you better make sure that you call the javascript code AFTER all the appconect values you use there has their content (trigger it on a success event or on an update event…)

3 Likes

How can I check it ?

Just explain how and where are you calling/testing your script …

the script starts automatically when the page loads

Sorry I cannot remember how to insert the code in the forum

When the script runs on page load, it runs before the data is assigned to the variable, so no value is available. You need to run your script, after the dynamic data on the page is available.

2 Likes

Thank You very much @Teodor, it worked.
I wrapped all the script in a function called startScript and it start after var1 has a value

and yes, I bookmarked the page to format the code :wink:
thank you very much

You’re a Wappler professional now @famousmag, I see in you what I was 2 years ago

5 Likes

I’m trying my best @Apple… I began about a year ago with basic knowledge of the “WEB thing” by filling gaps day by day WITH THE HELP OF ALL OF YOU guys. Thank you all!
I think that not being afraid to “test things” combined with observation is the key to learn…

In a few days I’m finishing my project and I have 1 task pending!
Start a nodeJS project… I will make a site for my self just for learning and then I will need help from you guys on setting it up on my server ( :face_with_symbols_over_mouth: )

(Sorry @updates for talking about me in your topic)

4 Likes

We’ve integrated a client-side App Connect PDF Creator component in Wappler 6.3.0
Please check it and let us know what do you think: Using App Connect PDF Creator

Note that more options will be coming to it in the next updates!

1 Like

Thank you very much @Teodor!
Just to understand, are you planning to issue a component to show the PDF on the web page?

It’s already available to show the PDF on the page, using the Preview dynamic event:

Just add an iframe with some id on the page, and then enter the iframe id in the Preview action.

I m speaking about PDF that are stored in S3 bucket.
I would like to show it on ejs page and if possible to have prev and next to change page… is that possible ?

That’s not related to the extension we released.
If you have any specific question about your files stored in an S# storage, please post a new topic explaining in details what are you trying to achieve.

1 Like

I was supposing. Your component is great.

i already find a solution but having problems with dmx.parse to pass the s3 address to the script

This topic was automatically closed after 3 days. New replies are no longer allowed.