cancel
Showing results for 
Search instead for 
Did you mean: 

[Resolved] :open pdf file directly from Alfresco

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi All

I can download the pdf file from the server to my machine. Now i have to change this functionaity.
I want to show that file to client without downloading. I have to add one link in jsp to view the pdf.
When you will click on the view link, it will go to the alfresco server and it will open the pdf file.
Can anyone please tell me how to open pdf that exists in alfresco.


Regards
Nishant
13 REPLIES 13

loftux
Star Contributor
Star Contributor

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi Loftux

Thanks for the response.
I was looking for this only. I have gone through http://wiki.alfresco.com/wiki/URL_Addre … entServlet URL.
Could you please give me some more clearity on this. Means how i need to use URL_Addressability.

I have one link in my jsp page.Using this link, i want to open pdf file directly that exist in alfresco server.
As per my understanding, i have to use URL_Addressability like this—
<a href="/alfresco/download/attach/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf">alfresco.pdf </a>

Kindly help me.

Regards
Nishant

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi Loftux

In this URL http://wiki.alfresco.com/wiki/URL_Addressability#DownloadContentServlet, it is mentioned that we need to invoke org.alfresco.web.app.servlet.DownloadContentServlet servlet using the the following url pattern–

/alfresco/download/<direct|attach>/<workspace>/<store>/<nodeId>/<filename>

1: <direct|attach>  :  This is cleared to me. According to requirement, i have to use direct because i want to open a pdf file in another window without downloading.

2: <workspace> :
    I am using this node structure in alfresco—
    Companyhome–>NEB—>a123—>alfresco.pdf
    In my code, i am using this line–
    String space = "/app:company_home/cm:neb_folder/cm:a123/cm:alfresco.pdf";
   
   So here workspace means company_home. Am i right?

3: <store> :

In my code i am using this line–

protected  final Store STORE = new Store(Constants.WORKSPACE_STORE, "SpacesStore");

then store means "SpacesStore". Am i right?

4: <nodeId> : what is nodeId. Is it uuid? How will i get nodeId?

5: <filename> :   alfresco.pdf

According to my application, i am writing the URL for invoking org.alfresco.web.app.servlet.DownloadContentServlet servlet.

/alfresco/download/<direct>/<company_home>/<SpacesStore>/<nodeId>/<alfresco.pdf>

Kindly help me.


Regards
Nishant

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi Loftux

I have resolved this. For downloading files, URL Addressability  is the best answer.
I will suggest to all it is the best way. No performance issue with this approach.

Thanks for your help.

Regards
Nishant

mau
Champ in-the-making
Champ in-the-making
Hi,
How do you get uuid? Is it possible to get uuid in php?
Thanks,
Mau

unknown-user
Champ on-the-rise
Champ on-the-rise
Hi mau

First get the file Reference object and then call getUuid() method like this–

String uuid = fileRef.getUuid();

You can also get the complete URL of content exist in Alfresco like this–

Content[] content = WebServiceFactory.getContentService().read(new Predicate(new Reference[]{fileRef}, STORE, null)  ,  "{http://www.alfresco.org/model/content/1.0}content" );
      
String url = content[0].getUrl();

After getting URL, you just need to pass ticket id after the URL like this–

url = url + "?ticket=" + ticket;

I have no idea about php. I am working on struts. Hope it'll help to you.

Regards
Nishant

fincoder
Champ in-the-making
Champ in-the-making
Hello everyone.

I'm a newbie with Alfresco WebServices and I'd like to ask about some basics.

I've made a portlet to Liferay which shows Alfresco content. Right now it is showing only html documents, which are made by Alfresco. Is it possible to use your previous example for showing pdf, doc, ppt and xls-files via my portlet too?

I'd also like to know how to make a Alfresco pdf link to Alfresco html-document? Now my porlet shows the html content from Alfresco and gets the ticket for that. (So it doesn't ask login username or password to Alfresco.) But when I insert a link into the Alfresco html-document (eg. http://localhost:8080/alfresco/d/d/workspace/SpacesStore/a6e479cc-6215-11de-8d93-611da34ece74/test.p...) and click it from the portlet, it asks for Alfresco username and password. I have no idea why it does so. It already got the ticket, so why doesn't it use the ticket.

So how will the user who makes the content, should make the Alfresco pdf-document link to the html content? Should I make a friendly url, which they could use? For example http://localhost:8080/action/showcontent?p_id=a6e479cc-6215-11de-8d93-611da34ece74&p_name=test.pdf and add ticket to the end of the link in a java code? Or is there another solution for that?

Somebody help me, please. I can explain more, if my english is not understandable. Smiley Happy


Kind regards
fincoder

sans
Champ in-the-making
Champ in-the-making
Hi Nishant,

Content[] content = WebServiceFactory.getContentService().read(new Predicate(new Reference[]{fileRef}, STORE, null) , "{http://www.alfresco.org/model/content/1.0}content" );

String url = content[0].getUrl();

After getting URL, you just need to pass ticket id after the URL like this–

url = url + "?ticket=" + ticket;

I am trying to open a pdf in a browser. I am getting the url as mentioned in your code and I am appending ticket to above url. When I paste that url in the new browser window I should be able to see the pdf file but I am getting a login page. Do you know why is this happening? Am i doing something wrong here?
Here the url i am using in the browser.
http://<hostnameSmiley Tongueort>/alfresco/download/direct/workspace/SpacesStore/<nodeId>/<filename.pdf>?alf_ticket=<ticket>

Thanks
Sans!!!

rleones
Champ in-the-making
Champ in-the-making
I'm getting the same page. I don't wanna that the users need to login in Alfresco to see the pdf file…

Does anyone know how to solve it?

Thanks!