I want to open a DOC or Docx file (Generally MS Office files) in the browser.
Can anyone tell me how to complete this task.
I am working on my CakePHP Project.
Any Help will be appreciated.
Thanks
you can't show docx file directly on browser.
so you can use google doc viewer for it . mostly format supported by google doc Viewer.
To render pdfs in a browser have a look at pdf.js: http://mozilla.github.io/pdf.js/
Pdf.js renders pdfs on client side, most browsers are supported.
For doc and docx I'm pretty sure this can only be done by converting them on server side to another viewable format or using googles doc viewer (be careful there are limitations)
To display the contents of doc files in browser, you can covert the doc file to html (I use zend livedocx for this) on server side and then display the converted html. An example can be seen here.
Browsers have no native way of opening documents such as DOC, PDF, ODT etc. However from the history point of view the managed to do it via usage of plugins (Adobe Acrobat, Open Office).
Some browsers (e.g. Firefox with PDF.js) have included some of these plugins in order to provide more smooth user experience when opening documents. Generally speaking most of the browsers now step back from plugins. But still there are plenty to be used, for example WebODF for Libreoffice integration.
Related
Is there is any way to displaying world document,excel sheet and power point in browser with out downloading.
I assume that you are going to use php for this, so you can try checking some libraries such as PHPWord by Microsoft for example.
If you wish to only display the document content, it is possible to do using some scripting language such as php. Basically office 2007+ formats are zipped XML documents with changed extension. Make a simple word 2007+ document, save it and change extension from .docx to .zip, than you can extract it and see what it's made of. You can find a lot of details here. Now displaying content may be a little tricky. As mentioned, there are libraries out there to handle this, but how will they handle the documents, I am not really sure. Most of them are abandoned, PHPword is in beta since 2011.
There are some indications that Apache is working on cloud version of Open office, but there is no release date yet. Once done, you will have a full featured office suite web app.
If you feel really creative you could use cron job (or scheduled task if you like Windows) to open a document, take a screenshot and basically make .jpg or .png version of the document (works fine with short documents, longer ones may be problematic), displaying it in a browser without much complication. It is also possible to schedule export to .pdf - all browsers do have Adobe PDF plugins.
To sum up, using php for parsing simple documents should be fine, but getting complex docs to display properly, may be much more difficult task and possibly not worth your time. I would go for cron export to pdf, to preserve most if not all of the document's structure.
What is, according to you, the best way to convert uploaded files of any kind (.doc, .docx,...) into a pdf-file using nothing but php. Is it even possible to do so?
I looked at FPDF, but this creates the pdf files from text.
An other solution previously given was to use the PDFlib library on your server, but unfortunately, my server doesn't support this library...
What is the best way to convert to files my users upload on my site to pdf files?
A simpler approach would be to restrict uploads to .PDF format programmatically and require your users to only upload .pdf files. Provide a link on the upload page to a free and open source pdf printer (e.g. Cuteftp) that the user can install to create .pdf documents from any file that can be printed.
Trying to do it through PHP will be problematic because the uploads could be generated from many different programs that would be impossible to cater for in their entirety. e.g. How would it handle Scribus or ABC Flowcharter or any other 'non-standard' application someone used to create a document?
Much better to filter the upload upfront.
The best server-side PDF generator from those I tried was, so far, wkhtmltopdf, a WebKit-based, self-contained invisible browser that can render any HTML+CSS and generate a PDF from it. Reasonably fast and fairly reliable, has some useful PDF options, such as page size, orientation, etc.
The second part of the job in your case is to convert documents to HTML prior to feeding them to wkhtmltopdf. If possible, have your users upload the docs in HTML (Word and Co. can export (crappy) HTML). If this is not an option, you will have to find a tool just for that, which, in my opinion, is much easier than finding a tool that converts Word docs directly into PDF.
Good thing about wkhtmltopdf is also that you can feed the output of your PHP script to it using the ob_xxx() functions.
PHP Excel best simple way to create doc, docx, xls, xlsx, pdf files with PHP. Its lot easier with clear documentation.
Use Microsoft Office to render Microsoft Office documents, if you care about accuracy at all. This is easily done by invoking Office over COM.
Get access to your server, and install what you need. Doing so would be far easier than monkeying around with sub-par solutions.
Well... I can think of one way of doing it quite easily, but it doesn't involve using PHP.
Upload your documents to a folder on your server, that are browsable by your users.
EG: http://mysite.com/docs/
Then get your users to install a virtual printer driver such as Primo PDF
http://www.primopdf.com/index.aspx
then they can load the document into their browser, and print to PDF for offline browsing.
If this is not an option, and your dealing with office documents that conform to the openXML standard, you could attempt to parse the XML doc into a PHP page for display in the browser, then use JavaScript to trigger a print.
Unfortunately, it does still depend on your user having a PDF printer installed.
Alternatively, you could just load the docs natively, and print to your own PDF printer, then upload the PDF's to the web server for download.
I can't think of any easy way of doing this otherwise, without installing all sorts of different document parser tool-kits and doing a huge amount of behind the scenes work.
hey all,
is there any way to convert a given file (this could be of any type) in to a pdf file in .net or php?
eg: suppose there is a upload link to upload your file of any type(word,excel,autocad,images..) and once the upload button is clicked the uploaded file should be converted into a pdf.
i checked out fpdf.but according to my knowledge all file types cannot be converted.a module to plugin to the CMS would also be fine.
FPDF does support images. I know because I have used it recently.
If you are wanting a pure PHP solution, you can use the PHP COM functions along with Word or Excel on the server to open up those files then copy the data out.
If I were you though, I would use Google. Load the doc into Google Docs then export it as a new format with the API.
There are a couple of 3rd party solutions available such as this one, which is optimised for use on the server and accessible from any web services capable environment, including .net. Supports loads of file types including MS-Office based documents.
Disclaimer, I worked on this product so consider me biased. Having said that, it works very well.
Anyone know of any Flash components that would do the job of displaying an external PowerPoint file (e.g. .PPT, .PPTX) file in a Flash movie on a web page? Or a way of automatically parsing uploaded PowerPoint docs from a PHP-based CMS and displaying them on a web page.
Our client needs to be able to upload a PowerPoint documents on their site without any intervention (if necessary).
I know about Slideshare and the like, but the content needs to live on the client's web server due to security restrictions. Also, Adobe Presenter seems to require Adobe software/plugins on the clients machine which wouldn't be ideal.
You could use Google Docs. It supports previewing PDF/PPT/DOC (Don't know about XLS) files.
I use it on one of my projects and it behaves very well.
You can call it using http://docs.google.com/gview?url=<your absolute file url here>
you could also use the embed=true parameter to embed it into your site, using an iframe or that sort of thing.
Hope this helps.
Using COM you can save a PPT as a PDF (see this question), and then use swftools' great (and free) pdf2swf utility to get nice swfs.
You can use http://ajaxdocumentviewer.com/. I use it on a large site with good success. It will require a flash or pdf viewer plugin.
Hmm have you looked at the new Sharepoint 2010? They do have some sort of integration with MS Office 2010. The demo i saw allows collaboration as well as uploading and viewing powerpoint slides (with all the nice transitions preserved) and even some minor edit functions.
For the browser I think they said that there isn't a need a install any plugins like flash or silverlight and works on all browsers.
Is their any Open Source Web PDF Viewer?
Which has good api through which I can modify the looks of the viewer?
I had tried the Scribd, Google Docs, FlexPaper , and this also.
But it is not giving me, as I want.
Then i had downloaded the shadowbox but it has not given me information about how to use it?
So anyone know good web pdf viewer and it would be great if it offers the customization
And that should be great if it is in php.Thanks in advance...
I don't think you're going to find a PDF viewer that's in PHP. The decoding of the PDF format happens on the client, which means your only options are either relying on the client to do the decoding work for you (Adobe Reader, Google Chrome's built-in reader, OS X's Preview app, etc.), rendering it with Javascript, or figuring out some way to convert the PDF into HTML.
PDFs are so ubiquitous these days, that it doesn't make a whole lot of sense to me to want to try to render it for a client; rather, simply tell them that the file they're downloading is a PDF and offer links to either Chrome or Adobe Reader, and let the user view the PDF in whatever app they please.
There is a wonderful pdf viewer which is opensource too. The ui implementation is basic. You will have to work on it. But its awesome.
http://view.samurajdata.se/
There is also a project from Mozilla called PDF.js. They're hoping to get it to a point where it's available as part of Firefox.
Get it at: http://mozilla.github.com/pdf.js/
I've tried it out myself and it works very well. The only issue is the source JS files are about 1.4mb which is rather large and I couldn't minify them due to some weird coding standards.