Can you populate word fields from a react app using pdftron? - node.js

I was wondering if anyone could point me towards a solution to my issue with pdftron/webviewer. I am building a MERN app and one of the projected feature is contracts generation. I created my fields in .docx file, loaded it in with webviewer.
I tried:
having my data collecting form on the same page with webviewer and passing data via state. (...yeah)
Tried to separate contract generation page and display (webviewer) page and use localStorage/redux.
Lastly I tried to take advantage of my database, so I created new model/schema and set up the collections that on the form page the contract data gets POSTed into database and then fetches from the webview page. Mongo has a TTL flag to remove every record after 1 minute.
I can console.log(contract.name) but it just won't consistently show as {{NAME}} (consistently because on several ocassions it works..)
Any help is greatly appreciated. Can't provide console errors log/network dont show any.

It seems like you are trying to fill forms with data. You could check out this guide for form filling. PDFTron JavaScript PDF form filling library
This is an live example showing how it would work.
Let me know how this works for you.

Related

Form and Document handling in React

I am working on a project that needs to be able to select a type of form (form is a long feedback form) attached to a project and fill out details of the form. Once it’s completed it’s save to backend(mongodb) and display on front end with the date it was submitted. The form needs to have auto fill in some sections thats i am pulling the data from the backend. I’m have trouble figure out how to actually display the form and be able to save it to the backend. I was wondering if anyone has had some experience with anything related to this and could give me some tips.

Django form - How to save data or get data without having to save it to database?

I've created a form with some fields for users to enter data, and a button to submit them and run some functions, then display the results on the same page (without having to store it to the database).
Now I would like to add a button (view/download as PDF) to have the page generated as a PDF file, so that the user can save the results.
But I'm having trouble retrieving the entered data, even they are still displaying on the page. They don't seem to be stored in the variables (or I don't know where to look).
I've read that if using modelForm I can call the .save function and save data to the database. But for this app I don't really need a database (it's more like an one-off calculations). So I would like to know if there's any way to:
Get the entered data directly while they are still on display (after submitting the form).
Generate a PDF directly from what's on the page (like the print function that most browsers have, but with some customization such as without the headings and navigation bars).
Is there a way to do this? I've been searching a lot and can't seem to be able to find an answer. I'm still very new to Django and programming in general so please forgive me if I'm asking silly questions. Thanks very much in advance.

Need advice on loading and saving data on tabulator

I want to load data from a table in my DB using PHP.
+ I want to then edit the data and save it back to the table.
I can't seem to find any examples.
The examples load data that is hard coded in the HTML.
I see there is code to add rows and edit - but I see nothing for saving.
I'm hoping someone can help and give me some pointers.
(Apologies in advance if the information is there - I've looked and can't see - it's 2am and I'm not thinking straight!)
Thanks.
There is an example for loading data into a Tabulator table via ajax here
As for saving it back that depends entirely on how you handle things server side.
you can use the getData function on the table to retrieve an array of data from the table
var data = table.getData();
you would then make an ajax request to pass this data back to the server, it would then be up to you how you go about saving this to the database,there are as many ways to do this as there are backend frameworks so it would depend on what you are already using

Unable to extract data using Import.io from Amazon web page where data is loaded into the page via Ajax

Anyone know how to extract data from a webpage using Import.io where the data is loaded into the page via Ajax?
I am unable to extract data from below mentioned pages.
There is no issue in first page data extraction, but how do I move on to extract data from second page?
URL is given below.
<http://www.amazon.com/gp/aag/main?ie=UTF8&asin=&isAmazonFulfilled=&isCBA=&marketplaceID=ATVPDKIKX0DER&orderID=&seller=A13JB7253Q5S1B>
The data on that page is deployed using an interesting mix of technologies; it relies heavily on server side code and Javascript. That type of page can be a challenge, however, there are always methods to get the data. For example, some sellers have a page like this:
http://www.amazon.co.uk/gp/node/index.html?ie=UTF8&marketplaceID=ATVPDKIKX0DER&me=A2WO1PQ2OIOIGM&merchant=A2WO1PQ2OIOIGM
Which is very easy to extract data from, even using the magic algorithm - https://magic.import.io/?site=http:%2F%2Fwww.amazon.co.uk%2Fgp%2Fnode%2Findex.html%3Fie%3DUTF8%26marketplaceID%3DA1F83G8C2ARO7P%26me%3DA2WO1PQ2OIOIGM%26merchant%3DA2WO1PQ2OIOIGM
I had to take off the redirect=true from the URLs before it would work - just an FYI.
Other times some stores don't have such a URL, its a bit of a pain, and there URLs can be tough to figure out.
We do help some of our enterprise customers build bespoke APIs when the data is very important to them, so do feel free to get in touch. I imagine a larger scale workaround would be to create a dataset/API based on a the categories you are interested in and then to filter that larger dataset down (python or CSV style) by seller name. That would probably work!
I managed to get a static dataset but no API. You can find that dataset at the following GUID: c7c63f1c-7081-4d4a-ad91-afe9789a6620
Thanks

runWithDocumentContext:passing data back to the xpage

I was playing around with run With Document Context almost the whole day. Maybe someone can help to find me a feasible solution.
If i run the agent in before page load / before render response / query Open Document event i am able to pass values back to the xpage without saving the document. I tried also to save the document but it didnt help.
Beside these two events i didn't find a way to call the agent and bring the values from the lotus notes agent back. Can anybody think of an event that would work?
Calling an agent does work from anywhere you can call SSJS. Some considerations are on my blog.
However there is one big, big caveat: when you try to use a document (saved or unsaved) that is bound to a datasource in your current XPage, then the values in the datasource will overwrite the changes in the backend document. This could be your issue?
As David suggests: use SSJS & Java. It is less work than you might fear and you can pay down some technical debt
How about just creating a new Domino document, put the fields on it that you want to send, call your agent, and then get back those fields. Then populate whatever you need to on the XPage (getComponent("name").setValue(value).
There is no need to save this temporary document and it will just end up going away when your code runs.

Resources