Displaying a PDF from AWS S3 in WebView causes download instead of displaying inline - react-native

When I try to view a PDF from an S3 bucket in a WebView, it downloads even though the Content-Type is set to application/pdf and the Content-Disposition to inline (tried without it as well) in the AWS Management Console.
<WebView source={{ uri: this.tosData.link }} />
When getting the URL directly from S3 and pasting into Chrome, it displays as expected, without downloading. If I host the PDF on something like Google Drive, and use that link instead, it also displays as expected. Any thoughts on what could be wrong?

while uploading pdf file into s3 add 'ContentDisposition': "inline" into header, this will help you to view the content instead of downloading.

ALL PDF viewers must in one way or another download a full web page including any referenced content such as a PDF whichever way it is embedded.
A browser may not or does not have to display the PDF since if it was a viral file it would be run without your permission. For that reason hardened browsers will download the pdf and not run the content.
You can add a flag to indicate, you say the pdf may be trusted for inline viewing, if the site page is trusted. that is why there is a setting that on handing ownership dis-position from server to client there are flags download or inline
download only
download and optionally view inline, is preferred by the site, but does not have to be complied with.
Globally PDF viewing is controled by the PDF viewer application and the browsers security settings, such as no window.open or other pop-up.

Related

How do I add a link inside a PDF document that opens the same PDF in a user's default browser?

A client has asked that I include a "View in browser" link to a pdf attached to an email. This should open the same PDF in the user's default web browser. I have a PDF editor (PDFescape Desktop) that I can successfully use to add links to webpages, and it seems capable of opening files, and even executing javascript, though I've never tried it (I am proficient in JS though so that's an option if anyone has any ideas).
The only thing I can think of is to host the PDF somewhere and then link to it's location, but I'd rather not use a third party server if I can help it.
Is there any way to reference a link in a PDF to the same PDF the link exists in?

How to handle pdf files from server response?

I am working on React-Native mobile app and I need to handle pdf file coming from the server. The idea is when the user clicks on button, a request to the server is made and a pdf file is returned. My question is how to download and parse this file and show it to the user?
You can do it in app BUT you are going to have a lot of pain, especially with android devices.
My advice is using the Linking api and open a webbrowser:
https://facebook.github.io/react-native/docs/linking
The idea is to check if your url contains a .pdf. You can use a mix of:
https://lodash.com/docs/#includes
https://lodash.com/docs/#filter
https://lodash.com/docs/#split
When you are sure that your url is a pdf, you can use:
Linking.openURL(url);

Display Bitstreams in Google Docs Viewer

I've been embedding Google Docs Viewer in my DSpace instance, an online digital repository, using an iframe.
This is my site link: http://202.78.89.123:8081/xmlui/handle/123456789/145
DSpace generates bitstream links to each item/pdf in the repository. When I click the preview link, an iframe appears in my page but doesnt load any document. But when I change the source of my iframe to a pdf path file, which is publicly accessible in the world and not a bitstream, the viewer loads the document.
I have done everything I can, from checking whether my web server is publicly accessible by google docs viewer. My web server is publicly accessible and I suspect Google Docs Viewer doesnt anymore support bitstreams?If that's true then how will I display a pdf file in an iframe within my page? Any idea?
Below is my page that says "Apologies. There is no Preview Available"
The reason why I cant display the bitstreams on my google docs viewer is that even though my IP is publicly accessible, my ports are private. What I did is, make the ports public by setting it on the router.

Opening a saved pdf on client

I am exporting crytsal report to pdf format and saving the pdf on azure cloud. This code is written in web api. I am also able to download the pdf on client. Is there any way with which I can open this saved pdf file on client side by either using server side code or using jQuery. I just want to keep the file open for the user to view.
Maybe you can have a link point to the PDF file address with response header "response-content-disposition": "inline; filename=this.pdf", "response-content-type": "application/pdf". Then I think the browser will launch proper PDF plugin to show it.

JavaFX WebVIew - PDF on popup window

I have posted some other smaller questions regarding the problem I describe below and got some feedback but now I will try to explain it in more depth hoping to get through the problem.
I built a desktop application using JavaFX 2.2 which uses a WebEngine to access a website built using Oracle ADF Pages. The application tracks the users actions on the pages and stores data to a database. All fine so far until the point where I need show a PDF file on a user click.
On the actual website the user clicks a button and a new popup window opens up that displays the PDF.
My problem is that due to the lack of PDF support in JavaFX I cannot display the pdf. The actual link to the PDF is dynamic and it doesn't have a .pdf at the end of it so I can't use the actual URL to send it to an external bowser or something to display it. Additionally the connection is secure so I can't open the URL with Chrome for example.
Possible solutions I thought about are to read the binary data of the response from WebView and create the PDF file locally and then open it using Adobe of Chrome or something. Is that possible at all?
Another solution I thought about (while I am writing this question) is maybe to open the URL which the users default browser but how can I go about sending the secure connection cookie from the application to the browser.
Is any of the above even possible? Am I missing something?
Any help, clues, links, ideas would be very much appreciated.
Thanks
I think the best way to do what you want is to download the PDF and display it locally.
Downloading using WebView sounds like it could work but I'm not familiar with the user experience. As an alternative try using curl or wget. You can pass in the authorization cookie to those tools and use them to download the file