Solved

Save and upload a PDF via javascript bookmarklet

Posted on 2010-09-02
5
490 Views
Last Modified: 2013-11-11
Hello all,

There is a system we work with that generates reports as PDF files in the browser.  These PDF files are only able to be opened in the browser which generated the file.  Every time someone in my company generates one of these reports they must save the report to their computer, visit our website, and upload the file.  This is a time consuming process.

I have been tasked with finding a way to automate this.  My idea is to have a javascript bookmarklet that would post the location of the PDF file in the browser's cache to an upload script running on our website.  ie, when one of our employees generates a report they would click the bookmarklet.  A new tab would open on our website with the location of the PDF in the browser cache as part of the URL querystring.  Javascript on ths page would automatically start the upload.  I am not that well versed in javascript.  Is this possible?  I already have the upload script written and working.

Thanks in advance!
0
Comment
Question by:greatseats
  • 3
  • 2
5 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33596061
It is not possible to do with javascript alone since you would need to populate a file upload field with the file.

This is for obvious security reasons not possible.

I suggest you look into creating a plugin or a stand alone app for example using HTA if you can rely on IE being present.
Adobe Air is another alternative I believe
0
 

Author Comment

by:greatseats
ID: 33597804
Mplungjan,

Thanks for the info.  Since this script would only be running in a controlled environment I would know ahead of time the file structure of each computer.  Is it possible to use javascript to save the current file (ie, a PDF file) to a specific location?
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 33597887
Only if you use HTA, WSH and the file system object

But then you do have full access to do what you want since the user started the app from the filesystem too

http://technet.microsoft.com/en-us/library/ee692768.aspx
0
 

Author Comment

by:greatseats
ID: 33598217
Mplungjan,

Thanks for that link - it is very helpful.  I think that this will work for me.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 33598573
You are welcome. HTA is very useful in controlled environments.
I use it often to scrape webpages for example
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now