Reading remote PDF files with JavaScript - javascript

I'm working on an iphone app, that would read pdf files from the folder on web server.
I made the part of app which read PDF files and everthing is fine, now i'm trying to figure out how to load all pdf files from http:/www.blabla.com/pdf, so everytime i upload new pdf, the app would automaticly load it.
Is this possibile, and anybody has ideas how can be done?

This can only be done, by either having Directory Index enabled, or using a server side language such as PHP to read the contents of that folder and output the filenames.

Related

Opening an xlsx file from a server directly in excel via url schema

On my server I create an xlsx-file and save it to the servers file system. Afterwards the files URL is sent to the clients browser, where the file is supposed to be opened directly in excel with the help of javascript:
window.location.href = 'ms-excel:ofv|u|https://myserver.com/path/to/file.xlsx'
Now the first time it worked like a charm. The file was downloaded, the browser asked whether to open excel, I said yes and the file was opened in excel.
But as as soon as I try to open the file again or another xlsx file in the same way, it stops working. Excel gives a warning, that it could not access the file.
Does anyone have an idea what the reason could be?
I restarted excel
I looked for cached files that prevent downloading more xlsx files
I checked that the files exist and can be opened (accessed them via their urls directly in the browser)

How to get all files from a directory using ReactJs

I have a create-react-app application that has a page where it allows the user to select a .csv file to upload, this file has many columns, one of these columns is a path to a folder with a bunch of pictures.
I want to be able to access this folder and upload all this pictures using js on the client side, apparently all solutions involving the fs library do not work anymore as it's been removed from webpack.
Since the files are hosted in the client side, I need to be able to grab those files programmatically using the js running on the cliente browser, it needs to happen without the user interaction because that CSV file has thousands of lines (there will be thousands of paths to grabs the images from), so the user can't be manually opening the file browser and selecting a directory for each line of that csv file.
To be clear, the only user interaction allowed is the csv file upload, the rest needs to be handled automatically.
How can this be done? And if it can't be done, what would be a work around this issue?
Thank you.

PDF.JS Preview large pdf file (> 200MB) on client side, that was sent from server side

I'm working with a pdf viewer, that will load a pdf file from server (nodejs) and then rendering on client side to allow user reading direct in my site.
I'm using pdf.js to rendering pdf file on client side. The problem is client side must download entire pdf file before they can parse and render it, so if the file is too large (~200MB in my case), user must wait for download entire 200MB.
I researched and i think i can solve this problem by 2 ways:
Split the large pdf file into many smaller pdf files on the server side, and serve only specific small file on-demand. But this way, i will lost some important metadata like the pdf outlines,...
Using pdf.js direct in server side, get the pdf pages and then serve each page as binary to client side, client side will also use pdf.js (addPage function) to add each page to their viewer. But i don't know it is possible or not.
So what should i do to solve this problem?
Thank you so much.
The best solution is to optimize all your PDF files for web.
The default settings of pdf.js will load only the portion it needs to render.
See here for more info.

How to download pdf file using vuejs and bootstrap-vue

I'm trying to upload a pdf file to my browser, but I want to be able to download this file afterwards. I am having problems on the second task - downloading it.
I'm uploading as follow:
<b-form-file v-model="form.file" :state="Boolean(form.file)" placeholder="Choose a file..."></b-form-file>
How can I download form.file content after upload is done?
Edit:
I found this API, which handles file downloads nicely.
You need to save the file somewhere on your server or on a storage service (ie Amazon S3) and then redirect the user to a link where the file itself is served.
The specific implementation is based on your backend implementation and your architectural choices.

How to view local files in web browser by displaying and creating a link to local files stored in your computer in your webApp?

I have created a webapp using JSP,Html and Javascript which currently runs on my localhost using apache webserver. I want to display the files and folders and of a directory in local computer. I also want to create a download link or view link of those so that when anyone click on it it will be viewed in new tab or become downloadable as it happens in any ftp server. I know similar type of question has
been asked but none of them worked for me.
To create the download link I used
Download
this does not work as it is not in my webapp path and download attribute also does not work in internet explorer.
I'm not sure why you are exposing your local drive contents on the web but here's an option:
On the page that should display the files, in java code, list all
folders and files then for each file/folder show a link to some page
(for example "navigateLocalDrive" that sends the path of the clicked
file/folder like this:
Download
Now in that jsp, check if the GET variable is a path for a file or a directory,
if its a file, just send it back in the response, if its a
directory, list all files/folders and do the same as in step 1
Please note:
How I encoded the file path in the href in order to work properly.
The Access permissions for the webserver should allow write/read to that path (I'm already doing it on my Tomcat server on local host with the default setup no change needed)
For your reference, here are some helpers for this task:
How to list contents of a server directory using JSP?
Downloading file from JSP/Java
I am not sure if this is possible. In general the access rights are limited to the src and webContent Folder (for your html coding mentioned above for sure) . This is also reasonable, because you do not want to access or change data on your Computer in general, because after local development you want to deploy your web application to a server.
To make a test copy some file to the webContent and you will be able to download it. Within your Java coding you can use some IO package like java.io.File to navigate over folders and files. However keep in mind, that you will get some exceptions like
java.io.FileNotFoundException: C:\WeatherExports\export.txt (Access is denied)
if you want to access files outside the server.

Categories

Resources