open pdf file through URL using uid - pdf

I work with alfresco 4.2
I want to get an image from alfresco through URL using uid
I can get the result through this link
http://localhost:8080/alfresco/service/api/node/content/workspace/SpacesStore/98996554-212 f-4846-876a-89b40999901a/test.jpg
my problem is to do the same thing but for a pdf file
with chrome I can not open the file
and firefox the file is opened in binary format
is there a way to open a pdf file through URL using the uid of alfresco file

I'd try using the download servlet. I believe the url you are using is not setting the mimetype headers correctly. This url should do the trick:
/alfresco/download/direct/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf

Possible reason could be mimetype of your pdf file is not correctly set. Normally browsers have addons avilable out of box which enable them to read pdf file correctly.
https://helpx.adobe.com/acrobat/using/display-pdf-in-browser.html
Those appliation are associated with perticular file types so whenever it detects that file type browser invoke that application to deal with it. So you can make sure your file's extension and mimetype are correct.
One more thing you can try is download that file and try to open it directly in browser.
Also, there are chances file may be corrupt. Are you able to see prview of pdf in alfresco?

Related

Cannot open pdf file in browser using fpdf

I am new to fpdf. In my application, if a user clicks on a link, then I create a pdf file and the file gets downloaded. But I wanted the file to be opened in the browser. Here is my code
$fpdf->Output("Circular.pdf", "I");
But the code isn't working. The browser is showing garbage. I don't know what I am doing wrong. In the attached image you can see the output that I can see in the browser.
read up on the Content-Type header: https://www.rfc-editor.org/rfc/rfc2616#section-14.17

File is showing instead of download

When I download file, it is not downloaded and it shows in browser.
zip file is downloaded. this say server is working,
but when i try with ipa file(the extension of file is ipa), it shows content of file in browser instead of downloading.
I am using mamp.
Please help me
You may want to set a Content-Disposition header for this file - please see more information on MDN Content-Disposition. This way the server indicates that the file is an attachment and should be saved on the disk.
Content-Disposition: attachment
Content-Disposition: attachment; filename="filename.jpg"
The filename parameter is not mandatory. However, it'll suggest the name of the file.
On the other hand, if you have a HTML5 page with an anchor tag you may want to use download attribute, e.g.:
<a href="filename.jpg" download="filename.jpg">
The problem with download attribute is - it's not supported by all of the major browsers - see download attribute support. There is still a lack of support from the IE, iOS and Opera mini.

How to make PDF in my server show instead of downloading

I uploaded a PDF File in my Web.
But the PDF file while accessed via a URL, is getting downloaded instead of showing it in the web browser.
How can I solve this issue ?
If you are generating PDF file from javascription then you should make sure you are representing your PDF file as datauri base 64 encoded data.
If your file is on server then make sure server headers sent back contains Content-Disposition: inline; filename='example.pdf' so it will tell to display inline rather than download it

Can pdf and doc files be opened in a browser using coldfusion

Can a pdf file or a doc/docx file be opened in a browser? I have a link which when clicked opens up the document as such in pdf and in MS word. But is it possible to open them in browser using Coldfusion?
thanks in advance
ColdFusion has little to do with how they are opened in the browser. That depends on how the user's browser is configured. If it is configured to open in a standalone app, then it will do so, if it is configured to open in the browser then it will do that. You have some influence if you are serving the file via ColdFusion using the <cfcontent> tag, but since you have provided no code or any explanation of how you are serving these files I will assume you are just doing something like pdf which will just load the file in the browser and the browser determines whether to download it or view it directly.
If you are using <cfcontent> to serve the file then you can also use <cfheader> and send the file as either inline or an attachment which can help tell the browser how it should load it. That said, it is still up to the browser's configuration.
Something like:
<cfheader name="Content-Type" value="application/pdf" />
<cfheader name="Content-Disposition" value="inline;filename=mypdf.pdf;" />
<cfcontent type="application/pdf" reset="true" variable="#myPDFBinary#" />
would serve a PDF binary, telling the browser to load it inline, which should, if properly configured, open the PDF in the browser.
This is not something that ColdFusion can address. This has to do with the particular web browser being used and what related software a user has installed locally.
If the user has a browser that supports PDF natively (e.g. Chrome) or they have the Adobe Acrobat browser plugin installed, then the PDF will open in the browser. Otherwise, it will open in the Acrobat program or any program they have that can view PDF documents. There is no MS Word plugin for browsers, so the browser will always try to open a .doc file in MS Word (if they have it installed) or any other program they have that can read that type of file.

how to implement pdf.js to view pdf files in the pdf viewer?

i want to open pdf files that are linked to in a document in a new page in the pdf.js viewer.
i have downloaded the zip file from github:
https://github.com/mozilla/pdf.js
and gone to both of the index.html files in the examples folder.
i get blank pages when opening either of these files.
can anyone please tell me how to implement pdf.js so that i can open pdf documents in a new page in the pdf viewer?
thank you.
Try using '?file=url' in query-string with viewer.html.
For example: www.example.com/pdf-js/web/viewer.html?File="URL"
Source: pdf-js on github
And yes, you will most definitely have cross-domain issues if not using any web-server, as mentioned by #Silent.
Cheers.
Let me guess that you tried to directly open the examples via chrome. Your url probably starts off with file:///. This is causing a cross origin request error to occur on your browser. To properly view the examples, you need a LAMP stack.