NodeJS execute flow in background (server side) and grab the html - node.js

I am having a website which has many sections and multiple pages in each section.
There is a feature called "Generate PDF" which will traverse through all the sections and pages one by one and grab the HTML from the browser and then generate its PDF. This is working fine as of now.
But this is holding the user from doing anything until the PDF is generated.
I want to have some help on how I can do the same process in background (on server side) ? I have heard from someone that node-curl may help in this but I am not familiar with that.
Can anyone suggest me some ways to proceed further?
If anyone aware about node-curl and just can give hint that it may help me to resolve the issue then also it will be good. I will learn about it and invest my time to get it done.
Or else if someone came across the same kind of problem and have any idea then it will be good.
I am open to use any npm to get it done.
We are also using EmberJs so if any suggestions on that part then also welcomed.
Thank you.

Do you mean you implemented 'Generate PDF' in your client side emberjs code?
If you are running a nodejs based server, you can use node-curl to grab the HTML from intended URL. It is can be risky and you might end up in similar problem of blocking because nodejs runs on single thread. Better you fork a new process to execute 'Generate PDF' logic on separate thread. For details - https://nodejs.org/api/child_process.html

Related

Is there a way to deploy my app on a hosted platform?

Dear Stackoverflow people,
I am facing the following problem:
For an internship in a company I have created a leaflet map with several custom features such as custom popups, markerstyle etc. The thing is, in the end they are supposed to manage the whole thing. Since they don´t know anything about code they asked for the easiest possible way for them to add data to the map.
So I came across the serverside tutorial by CodingTrain using Node.js and thought its perfect for me. Now I created basically a webform that takes up all information, converts it into a geoJSON feature, stores it in a database and sends it to the map to be displayed, great easy GUI to add new features...
Now comes the bummer which I didnt know would be a problem: The website is on a hosted service called Bitrix. I uploaded my project and it does not recognize the routes and cant write to the database or anything. I actually dont know whether I can run node on this platform?
I had the idea to launch the whole thing on a Service like Heroku or Glitch and just take the map from there and include it into the other website via an Iframe or something like that. Do you guys think thats feasible? Are there any other better ways?
Sorry for my obvious cluelessness but I´m completely new to serverside programming and thought I´d found an easy way out... I am grateful for any kind of suggestions or help!

postman apps into nodejs, how it works?

I am still new to learning backend, I think I skipped too quick and I'm trying to push or simple post or call ? or request ? to localhost:3333/api/notifybut using or implement in node.js or cli ? or just use coding, not using application like this below picture (using postman-apps), so everytime i run the program, it will trigger and push to that localhost rather than using postman-apps. also so i know how it works because this postman is a simulation right?
basicly I still lack of knowledge about this so I don't really know what is this postman, is this like a server then does get.req ? or something, I was searching a lot but also I really have no idea. I will be happy if you show me some sources too for me to learn this.
because this postman apps only input http://localhost:3333... and then somehow there are some JSON from the apps itself created ? anyway just answer my very first question, probably i will understand later, thankyou.
nevermind, I learnt it, it was REST-API things

Best way to generate PDF from a template using nodejs

Now, I'm looking for the solution to generate pdf (invoice with barcode, etc..) from template(html, css) in nodejs environment. I found there are several ways to do that such as wkhtmltopdf, phantom.js & handlebars.js, html-pdf. What I'm concern is which is the best way to solve this problem.
Also, I have look at jsPDF, an client side generation, but it seem not suitable for production right now.
So, Anyone have used one of these library in production, please give me an advised.
Many thanks !
UPDATED:
Headless chromium is now ready for use.
Have some limitation (e.g: custom header, footer), but work great in almost cases.
https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
UPDATED: 4/2019
Now, Puppeteer is a major library for generating pdfs
https://github.com/GoogleChrome/puppeteer
If the invoice is on a static webpage, PhantomJS will allow you to generate a PDF . Here are a link to the screen-capture section of the docs. It shows you how simple it is do perform this :)

Browser based web Console

Do any one know how does the sites like codeacademy.com or runnable.com allows us to execute our code online. Through webserver it even has c++ which can be executed online.
If any one know about it please suggest me some links about it.
and is there any api for those operations.
I don't know how specific sites work, but there are at least two ways:
1) they create an interpreter in javascript for the language, or
2) they pass the code to the server, it executes it, and sends the results back.

Mootools not loading fast enough IE6

Very random and annoying problem with IE6. We keep our common JS files on a resources server so we only have to update them in one place. As well as our custom classes we also keep our build of mootools and more on the resources server and link to it in the head of our sites.
This is fine in all the browsers accept IE6. In IE6 it seems to not loads the core quick enough from the external link before trying to process the mootools code in my site.js file. It will go wrong on the first line "windows.addEvent".
If i put a mootools core in a folder where the site is though its fine. Does anyone know why it might be doing this and if so a way around it, but still keeping the files on the resources domain?
Thanks
Tom
#neil . Yeah exactly. Quite frankly i didn't want to be rude but the first two responses were a waste of their time and mine. Someone correcting a typo and someone else saying not to bother supporting a browser that still has 9% share of the market, quite brilliant.
#Dimitar Thanks for your response. I can't change the event to load unless you mean in native JS because no mootools will work. I don't like mixing the native JS when i'm using a framework if i can help it. Never heard of "defer" though, i will def try that. Thanks for your help.
IE6 probably pipelines the download as an extra host gives it the ability to do it in parallel.
perhaps you can either try adding defer='defer' for IE6 for your chunk of code that relies on mootools or change the event from domready to load instead (also for IE) (I tend to use the latter)

Resources