Pdf files editing and saving in browser - javascript

The scenario is that I have several editable pdfs that need to be displayed edited and saved all in a web based application.
I know this question has been asked before but I'd like to review the options. I work as a junior developer and I am being asked to research this. I don't think its possible as the pdfs are opened and viewed in different browser plugins that my code doesn't have access to but I still would like to know for sure before I report back to my superior. Is there any way I can tap into some API that allows for editing and saving on a webpage?

you could try this :-
A general-purpose, web standards-based platform for parsing and rendering PDFs
https://mozilla.github.io/pdf.js/

Related

PDF javascript info resources

My goal is to create a "dynamic" PDF. Basically the wanted functionality is
Calculations
Open another PDF from the same origin
Usage monitor (notification when opened or performed something)
Submitform
I found JavaScript could be embedded in a PDF but the functionality is limited and depends greatly on the viewer.
I looked at some Adobe docs (PDF reference, JavaScript for Acrobat API Reference, Developing Acrobat Applications Using JavaScript & Acrobat JavaScript Scripting Guide) and was able to build a PDF that performed more or less as I wanted in Adobe Acrobat but when opened in Firefox (PDF.js) or Chromium (PDFium) almost nothing worked.
Before asking a specific technical question I would first like to really understand what is possible so I'm able to judge if JavaScript is an option. So any reference to good resources to increase my insight/knowledge in/of this topic would be really appropriated.
To be clear my question is NOT related to PDF generation via JavaScript but related to embedding JavaScript code inside the PDF to make it more dynamic.
Many thanks in advance.
Best regards,

(ReactJS) Saving a file to a particular user-selected folder

Working on a Data Management System in React. I want to open the explorer window to let the user choose where they want to download a particular file stored on a server. I want to override the browser setting. Only need Chrome functionality.
Researched a lot about this, I know it's apparently a browser-side security feature
But as of recent, Chrome's apparently started supporting some File System access api so if someone could help me out with that, I'd be much obliged.
Tried the saveAs package, tried this tutorial and a bunch of other stuff to no avail.
I did find some solutions for writing text to a .txt file but the problem here is that the downloaded file could be of literally any type.

Export a PDF report with charts from Node/Express/Angular/PhantomJS

I am using AngularJS in a MEAN stack based on DaftMonk’s generator (https://github.com/DaftMonk/generator-angular-fullstack). I am fairly new to pretty much everything Angular/JS/Node (and stackoverflow so please feel free to point out if I need to reword my question!).
I am aiming to produce a multipage PDF report for a user from an Angular page that contains six graphs, images and text.
There are a number of questions on stackoverflow and Google that relate to potential solutions to this, but having checked these exhaustively, they do not help with what I need to achieve (or I do not understand how I can use them in my scenario..).
Currently, when the user navigates to the ‘report page’, an http request is sent to Node/Express from the Angular controller, which checks the user role/group ID, queries the database, anaylses the data and sends it back to the browser for rendering into graphs (currently using angular-chartjs and flot).
The user selects graph type and can choose a maximum of six graphs to display from a possible list of 20+. These six graphs are what need to be exported to a PDF report (with other information). I need to make this (within reason) as browser compatible as possible (at least IE8+) although my current solution is IE10+ with PDF export disabled for older browsers using Modernizr.
From stackoverflow and Google, possible solutions include using PhantomJS in Node to capture the screen or using a client-side PDF renderer (e.g. jsPDF). Out of these, my feeling is that PhantomJS would provide the most flexibility/browser compatibility. Also, I need to produce several different reports depending on the user role, so having all the code to produce the reports within the browser is not desirable. But I am totally stuck as to how to access ‘what the client sees’ using the MEAN stack. PhantomJS would need to effectively be logged in as the client, and have access to the six choices for graphs that the client has made.
From my research, using PhantomJS would require creating an html page, somehow transferring what the client sees/data/graph choices to it, and then capturing that to render to a PDF, before sending back to the browser. One way might be to pass the required information back to Express (with a POST?) and then rendering a server-side html page which PhantomJS could be pointed to, but I have no idea how to achieve this (or if it's possible). Another possibility would be to store the client report data, choices, etc in the database and set off a task to render the PDF and send it back to the browser when done, but again, I have no idea how to achieve this.
I have read about cookies in PhantomJS or navigating through the login page using code, but this seems to be a cumbersome way to achieve this. Can an html file be created server-side, with chart.js (or another charting library) injected (and angular?) and all the required user data/chart choices for PhantomJS to render to a PDF? I guess in some ways I need to be able to use a PDF generator, charting library, etc server-side to create a PDF.
Any advice (with possible code examples) on how to achieve this would be appreciated.
I guess I had the same problem as you (only I was using Laravel in server side).
The idea I came up with was to convert the canvas generated by angular-chartjs to images (using toDataURL() on the canvas elements)
$('.theCanvas').each(function () {
var canvas=this;
img=JSON.stringify(canvas.toDataURL());
});
http://plnkr.co/edit/PkZiqYynzQXehbe6p1eH?p=preview
and then sending the images to the server to create the pdf , and finally sending the user the link to the created PDF.
In my case, they are plenty of packages to generate a PDF from an html in server side, and I don't know if a tool exists for Node.
I hope this helps.

Download web page with one single click

I need to download hundreds of web pages manually. Unfortunately I can't automate the process since I don't know the urls of the web pages in advance. What I do now is open the page in browser, right click the mouse, select save as , choose a directory on my computer, and save the web page as html file.
It is just too much work since I need to repeat hundreds of times. It would be great if there's a floating button pops up when I open a page. When I click the button, the page will be saved to a default folder on my computer. I'll probably implement this function as a Chrome extension.
I guess this function can be easily realized with simple Javascript code. Unfortunately I have little experience with Javascript at all. It may take me quite a while whereas it's just a breeze for experienced web developers. Anyone help suggest the core lines of code I need to achieve this?
This task isn't best suited for Javascript since it doesn't have the ability to easily save files to your hard drive, in addition you will run into cross-domain issues likely. I would suggest an easy server side language like Go, PHP, or Python as you could set up a script to do this for you quite easily.

Screen scrape a web page that uses javaScript and frames

I want to scrape data from www.marktplaats.nl . I want to analyze the scraped description, price, date and views in Excel/Access.
I tried to scrape data with Ruby (nokogiri, scrapi) but nothing worked. (on other sites it worked well) The main problem is that for example selectorgadget and the add-on firebug (Firefox) don’t find any css I can use to scrape the page. On other sites I can extract the css with selectorgadget or firebug and use it with nokogiri or scrapi.
Due to lack of experience it is difficult to identify the problem and therefore searching for a solution isn’t easy.
Can you tell me where to start solving this problem and where I maybe can find more info about a similar scraping process?
Thanks in advance!
I used excel web query and it works perfect. You can find a lot about scraping with excel on youtube if you search for mrexcel.
Thanks, Mello
You can try IRobotSoft web scraper. It has good frame support and is free.
Iframes aren't a problem - just access the embedded iframe URL directly. You will find that it redirects in the browser unless you disable JavaScript.
Description and date can be extracted straight from HTML source. However prices are images which will make scraping them more cumbersome.

Categories