Opening a Document (.doc, .xls, .pdf) in the browser using an action
Hello
I´m using JavaScript to open a document in the browser using the property Onclick from Command Button: onclick="#{backing_archivos.rutaArchivo}"
and in the backing_archivos.rutaArchivo I have the String window.open("file://c://tmp/document.pdf", "title page", "top=100, left=100")
but the browser doesn't open anything.
What can I do?
Thank.
You can do an external file by using a stream and and the response object. I have this in a backing bean, and it gets called with a command button.
public String runQCReport_action()
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("PromotionRequestQCReport");
Object result = operationBinding.execute();
FileInputStream bis = null;
ServletOutputStream bos = null;
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
response.setContentType("application/pdf");
response.setHeader("Content-disposition","inline=filename=file.pdf");
try {
File fileName = new File("applications/reports/output/PromotionRequestQCReport.pdf");
bis = new FileInputStream(fileName.getAbsolutePath());
bos = response.getOutputStream();
byte[] buff = new byte[2048];
int bytesRead;
while (-1 !=(bytesRead = bis.read(buff,0,buff.length)))
bos.write(buff,0,bytesRead);
//response.getOutputStream().write(yourdata[]);
response.getOutputStream().flush();
response.getOutputStream().close();
context.responseComplete();
catch (IOException e) {
e.printStackTrace();
return null;
}
Similar Messages
-
How to view crawled documents of file system in the browser using sharepoint search
Hi,
I think this should be pretty obvious. However, somehow I am not able to do it. Here is what i am working on:
I created a folder on my D:\ drive on the SharePoint server. Added a few word documents there.Created a new content source in my Search Service Application and configured it to crawl above folder from file system. Ran a full crawl. All the documents are
crawled successfully. I can see the documents on the search page. Now, the problem is:
How can I open this document directly in the browser? Becuase the path i get is of the folder on the server. If this isn't possible then I think,there is no use of this feature. I just see the title and a short description of the document.
But, I think it should be possible. I just don't know how to do it.
Any ideas will be highly appreciated.Hi Mohan,
According to your description, my understanding is that you want to open the documents in file shares in the browser by clicking the link in search results.
As the files are not stored in SharePoint, so we need to configure Office Web Apps for the documents to open the files in the browser.
Here is a similar thread for you to take a look:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/70541f55-6a66-4d55-8f2c-9f9a356b9654/how-to-open-sharepoint-search-results-from-file-server-using-office-web-apps-server-2013?forum=sharepointsearch
Best regards.
Thanks
Victoria Xia
TechNet Community Support -
When I click to view a word, excel, PDF or other file on a website I am presented with a window that says
"you have chosen to open ........etc What should Firefox do with this file?
Open with
Save file....."
If I choose the option "Open with" the file opens and I can view the file but the file is automatically downloaded and saved. I then have to navigate to the folder on my hard drive by right clicking on the item in the downloads window, selecting open containing folder and then physically deleting the file. If I don't do this then the containing folder saves the unwanted downloaded file.
Do I have a setting wrong/how can I stop Firefox/download helper from automatically downloading files I only want to view?A new tab opens by default as a blank tab (about:blank).
If that isn't the case then an extension has changed that behavior.
*https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes -
Can anyone help with this printing issue. I want to be able to print various kinds of documents to a specific printer. I have looked at the PrintDocument class and the Process class. My closest working attempt has been with the Process
Class.
Here is my code using a Process Class:
Dim Proc As New Process
Dim PrintTo As String = "\\dev003\NetPrintQueue2Fax"
Dim outfile As String = Directory & "\" & FileName
Dim psi As New ProcessStartInfo("AcroRd32.exe", "/t" + outfile + " " + PrintTo + " ")
Try
psi.CreateNoWindow = True
psi.UseShellExecute = False
psi.Verb = "print"
psi.FileName = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
psi.WorkingDirectory = "C:\Program Files\Adobe\Reader 9.0\Reader\"
psi.RedirectStandardOutput = True
psi.WindowStyle = ProcessWindowStyle.Normal
Proc.StartInfo = psi
Proc.Start()
Catch ex As System.Exception
Dim ErrorRpt As New ErrorReporting.ErrorReporting
ErrorRpt.Log_Errors(ex)
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error Raised")
End Try
My
ulimate goal is to be able to fax these documents through a Xerox copier that has printing and faxing capabilities.
Thank
You
Michael J HillThank you Mike for your friendly help and good suggestion.
Hi Michael,
Welcome to MSDN forums!
Mike pointed you to the right direction.
The following is the detailed code sample:
How to print an external document using Process.Start method in VB.NET.
Public
Class Form1
Private Sub Button1_Click(ByVal sender
As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Dim psi As
New ProcessStartInfo
psi.UseShellExecute = True
psi.Verb = "print"
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.Arguments = PrintDialog1.PrinterSettings.PrinterName.ToString()' Here specify printer name
psi.FileName = "C:\MyFile.doc"
' Here specify a document to be printed
Process.Start(psi)
End Sub
End
Class
Best regards,
Guang-Ming
MSDN Subscriber Support
in Forum
If you have any feedback on our support, please contact
[email protected]
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Hi all,
I could not able to open a .doc,.xls,.ppt inside the iframe tag in IE7.
what should i do?Hi,
Question is,: when ever i call the .doc,.ppt,.xls files are not coming inside the iframe tag in IE7
I am keeping the all files in separate storage area lik d:/StorageLoc/Docs/Sample.doc
when ever i am calling the sample.doc through web,
http://localhost:8080/VContext/OpenFile
i am accessing the word,ppt,xsl files inside iframe
like
var fils= "d:/StorageLoc/Docs/Sample.doc";
<iframe src="/VContext/OpenFile?r2=fils"></iframe>
OpenFile.java [servlet file]
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException
try
String s2 = request.getParameter("r2");
String s3 = null;
String s4 = "txt";
if(s3 != null && s3.equals("download"))
response.setHeader("Content-disposition", "attachment;filename=output." + s4);
if(s4 != null && s4.equals("pps"))
response.setContentType("application/vnd.ms-powerpoint");
if(s4 != null && s4.equals("doc"))
response.setContentType("application/vnd.word");
if(s4 != null && s4.equals("tif"))
response.setContentType("image/tif");
}else
response.setHeader("Content-disposition", "inline;");
if(s4 != null && s4.equals("pdf"))
response.setContentType("application/pdf");
else
response.setContentType("application/octet-stream");
try
javax.servlet.ServletOutputStream servletoutputstream = response.getOutputStream();
File fileFound = new File(s1 + s2);
if(!fileFound.exists())
s2 = "Photos/notfound.gif";
FileInputStream fileinputstream = new FileInputStream(s1 + s2);
ByteArrayOutputStream bytearrayoutputstream = new ByteArrayOutputStream();
byte abyte0[] = new byte[0x500000];
do
int i = fileinputstream.read(abyte0);
if(i != -1)
bytearrayoutputstream.write(abyte0, 0, i);
} else
byte abyte1[] = bytearrayoutputstream.toByteArray();
response.setContentLength(abyte1.length);
servletoutputstream.write(abyte1, 0, abyte1.length);
servletoutputstream.flush();
servletoutputstream.close();
return;
} while(true);
catch(Exception e)
System.out.println("IGST-INFO:" + e.getMessage());
e.printStackTrace();
} -
I have a Word doc with lots of Excel/Pdf attached doc inside. Can I convert this word doc in PDF keeping the attached documents inside the PDF? or do I have to attach all af them again? thank in advance
Attach all of them again.
Be well... -
Hi,
I want to attach files like .doc, .xls, .pdf. etc in my Design editor, instead of importing those files. Is there any way to do that. Please help.
Thanks,
Vinay Jaassiel Kankipati
Technical WriterHi Vinay.
Would these files be editable and if so, where would they reside? If you want people to be able to edit the files, you need to consider where the files are located. If you link directly to a file in RoboHelp, a local copy is copied into your project as a baggage file. If a user then clicks on the link, the local copy is opened and any edits can not be saved back to the WebHelp's output location. However if you were to create an image (like the ones you used above) and added a hyperlink to the file's location - i.e. on a network drive outside the project, this would enable users to edit and save changes to the original file location. Hope this helps.
The RoboColum(n)
@robocolumn
Colum McAndrew -
Opening a document file while clicking on the hyperlink
Hello friends,
I am having some requirements like some technical documents are prepared for specialized information related to materials. And the link of technical document as per material is stored in material master.
I need to open the file (.doc, .xls) based upon the link. Can anyone of you tell me the suitable function that I can use to open the file based upon the location?
Thanks in adwance.
Regards,
Navinif path of the file is know then you can use
cl_gui_frontend_services=>execute method to open it -
Question: why is it that when I email either a word document or a pdf file the receipient of my email get these files in an unreadable format i.e. not in word file nor in pdf file formats, and consequently they are unable to open these files and read them? Thank you!
<Email Edited by Host>On what Mac using what verison of OS X?
-
Acrobat does not opens a PDF in the Browser at all times
Required:
I need to ensure Acrobat opens a PDF in the Browser at all times, and not have Reader hijack the task. All fixes for this I have found won’t work as they render Reader inoperable. i.e. uninstalling Reader or denying users to the Reader executable AcroRd32.exe
Situation:
I have a problem with Adobe Reader and Acrobat Standard 8.2.5. This is on a Terminal Server 2003 with 10 users. They require both Acrobat and Reader be accessible due to specific 3rd party applications related to banking software.
Problem:
They must open PDFs in a browser with Acrobat so they may fill the forms and save them. Acrobat doesn’t consistently open the file; Reader hijacks the file when clicked to open and their ability to fill the forms is hindered.
- Open PDF in browser is checked in Acrobat
- Open PDF in browser is NOT checked in Reader
Sometimes when the Acrobat desktop icon is clicked, Reader opens instead. Having Acrobat open in the background does help but is not consistent.
Also uninstalling Reader from the Server is unacceptable due to a 3rd party banking application for loans. This application is hard coded to open AcroRd32.exe within the application for opening PDFs.
Any suggestions would be greatly appreciated.
KenTry this, when I right clicked on the document to rotate the image a noticed a tool bar appeared at the bottom of the page with the save icon. It then disappeared, but by hovering at near the bottom of the document the tool bar appears and I can save the PDF.
-
WHY DOES PAGES CLOSE QUICKLY AFTER OPENING A DOCUMENT .DOC AND REPORTS ERROR?
WHY DOES PAGES CLOSE QUICKLY AFTER OPENING A DOCUMENT .DOC AND REPORTS ERROR?
HAVE YOU UPGRADED PAGES, WHATEVER VERSION THAT MAY BE BECAUSE YOU HAVEN"T TOLD US, TO THE LATEST VERSION WITH SOFTWARE UPDATE…?
AND WHY IS YOUR CAPS LOCK STUCK DOWN?
PETER -
Sorry, we couldn't open...Error opening office documents from SharePoint 2013 in the desktop applications
One of our Managers encounters the error 'A problem occurred while accessing the Office document cache. Do you want to repair this problem?'
Then When he says yes it give a warning that the cache will be backed up and replaced
Then it says 'A new office document Cache has been created...'
Then it loads this cache with an error
Then After all that the next time he tries to open the document it says is encountered "Sorry, we couldn't open 'URL."
We have Reinstalled office 2013 on the users PC repaired the cache numerous times
Followed - http://office.microsoft.com/en-gb/word-help/manually-rename-the-office-document-cache-HA101848838.aspx
Updated Lync to 2013 leaving Access as the only office 2010 application (required for legacy systems access)
Repair installed office 2010 and office 2013 again
The SharePoint site has been added to the trusted sites list and the set up assistant run from office 365
And the issue remains the Same all other users including some who also have Access 2010 for legacy systems access have no Issues OS is windows 7 32 Bit browser is IE 9
Office 365 said
Reply by Rachel Zhang MSFT Support
Hi Alex,
From your description, I notice that the issue is related to Office client. We would like to help you, but I’m sorry that our forum does not focus on this scenario and has limited resources regarding it. However, we have a dedicated support forum where
the support engineers will help you with the issues about Office client:
Microsoft Office Community:
http://answers.microsoft.com/en-us/office/forum/office_2013_release?tm=1365567547805
Feel free to sign in to the Office community and click Participate->Ask a Question to post the question with the relevant information.
Microsoft Office Community:
Feel free to sign in to the Office community and click to post the question with the relevant information.
Office team said
Hello Alex,
Thank you for posting your query in Microsoft Office Community.Check if other excel works fine
Do you have any script\macro in excel file
Check if all application pool on all servers are running
both office and IE should be same build (64 or 32 bit)
what is the error message in ULS log and Event viewer
If this helped you resolve your issue, please mark it Answered -
How to Open PDF in the browser...JSF
String strUrl = http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf
FacesContext faces = FacesContext.getCurrentInstance();
ExternalContext context = faces.getExternalContext();
HttpServletResponse response = (HttpServletResponse)context.getResponse();
response.sendRedirect(strURl); Hello,
I have to open PDF in the browser, I am trying to redirect using the above code, but it is throwing exception as below. Could some one help me in this issue?
Thanks In advance
Error Message:
java.lang.IllegalStateException: Cannot forward after response has been committed
Error details:
java.lang.IllegalStateException: Cannot forward after response has been committed
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:313)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
at com.esri.adf.web.faces.application.ADFViewHandler.renderView(Unknown Source)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at com.esri.adf.web.util.ADFSessionTimeoutFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)You cannot send two responses per request. The solution is to let the client create two requests. Common approach is to add an onclick to the commandbutton/commandlink which opens the PDF in a new browser window and let the actual command action invoke a redirect on the current browser window.
E.g.<h:commandLink value="Download PDF" action="#{myBean.action}" onclick="window.open('http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf');" />where the #{myBean.action} invokes a redirect and the http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf opens the PDF in the new window.
Edit
I've read your question/problem once more and now I am a bit confused. All you want to do is to open the PDF file in a new window and you don't need to do something in the backing bean? Just use a link with target="_blank".
<h:outputLink value="http://..../xxxxxe43cb072378947fe8c1b7bcc7201691a.pdf" target="_blank">Download PDF</h:outputLink>No need for a redirect here.
Edited by: BalusC on Nov 21, 2007 7:21 AM -
Is there any way to view a signed PDF where the signed uses Windows/Adobe and I am viewing it preview?...I do not see the signature in "signed" docs
I have already reinstalled both Adobe Reader and the full version of CS5 which includes Adobe Pro. Neither of those steps worked.
Thanks,
GiGi -
Unable to open PDF file in browser using Reader 9 with IE8
I just updated to IE8 and when trying to open a PDF file on the browser, I received a message stating to use Adobe Reader 8 or 9. I downloaded AR9 and still receive the same message and cannot open PDF files in browser window. It defaults to my Adobe Acrobat 6.0 which will not open the file. I have Windows XP. I do not have a problem opening a PDF file in Yahoo mail with AR9. I have tried many different ideas on the web to no avail. Appreciate any help to be able to default to open PDF files in the browser using AR9 which is apparently required by IE8.
Fixed problem by taking to a computer store to find that my hard drive storage was maxed out. I had the hard drive repaced with a larger amount of storage. Problem resulted from inadequate amount of storage space which prevented me from downloading and installing Adobe Reader 9.
Thanks to al that responded.
Maybe you are looking for
-
Trigger in a join table between two database
Hi an Happy new year I have two database, one is dedicated to security and the second for my multitenancy application In this two databases one have tables USER, USER_JOIN_USER_ROLE and USER_ROLE the second, USER (where fields are differents), USER_J
-
Mapviewer-demo: a empty map view
Hi, I imported the Mapviewer demo in a new schema, and deployed the Mapviewer on stand alone OC4J. I can start and configure the Mapviewer how described in the guide without errors but the created JPG is a empty blue picture. What can be wrong ? Than
-
How can I get my before icloud library back?
how can I get my before icloud library back? before I accepted Icloud i had 1,100 songs in my music library. after I only have 245 songs in my music library. how can I get my old music library back?
-
Hai, I am A.Mohammed Rafi working in Adobe Live Cycle Designer 7.0 I designed a form using Adobe Live Cycle Designer 7.0 and installed the SOAP listener in the web server. Next using WSDL connection method I connected in Adobe using a WSDL file locat
-
I have written an applet in swing and I want to display a dialog box - how do i make it so that it displays in the middle of the screen each time it is displayed? cheers David