Hai frnd can give me some solution..
1.how to open ms word document without using com(word.application)
2.actually i want to edit existing document only changing content without affecting any properties?
Zend_Service_LiveDOCX is a solution that doesn't require COM. It uses a web service.
See this PHP tutorial.
You can use NPOI. It is .NET port of the POI library. I used it for excel but guess should work for word as well.
This probably isn't much help because you need a solution now:
PHPWord currently only writes and only to .docx files. It is still in the early stages of development, but is worth keeping an eye on, and readers will be forthcoming in due course, as will support for .doc.
Related
I need to generate MS Project (.mpp) file using PHP, as I tried generating .xml but when oppening that files with MS Project, dates and durations are lost.
I tried creating a project with the MS Project itself and saving it as a .xml but it loses dates and durations too.
EDIT: Need to be MS Project 2013 friendly, so .mpx solutions like PHPProject offer do not help...
There's a Java-based project called MPXJ, which lets you create and manipulate Project files. You could either look at the source code and port it, or as a quick fix, just run it on the server and generate files on demand using a PHP/Java bridge (it's mentioned in the MPXJ documentation).
===
Edit: MPXJ doesn't write .mpp files.
According to the authors of MPXJ, the .mpp format is proprietary and there is no reliable way to generate the files. (See this answer - although it's from 2012, MPXJ still doesn't support writing MPP files, and the prediction about MPPX files hasn't yet come to pass.
The only way I can think of is to have a Windows server with Project installed that generates the files for you.
I was wondering if it is possible to use SQLite in PHP when the extension is not available (due to web hosting policy). Is there a pure PHP library for that?
Otherwise, is there PHP alternative for flat file database which I can adopt without going to MySql or MSSQL?
Try following the link pointed out by Andrei B: I published a link to my implementation of a database, entirely written in PHP, which aims at full support of SQL syntax. It's an open source project, every suggestion and contribution is welcome!
https://github.com/morepaolo/PHPFileDB
Check out https://github.com/mhgolkar/FlatFire or maybe stick with XML files (and related XML and XPath functions).
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.
This question already has answers here:
Is there a PDF parser for PHP? [closed]
(7 answers)
Closed 8 years ago.
My question is that i want to open documents(pdf,doc,docx,txt) in browser page using php (without using google docs viewer) can any one help me?
Some of these are doable. Some, not so much. Let's tackle the low-hanging fruit first.
Text files
You can just wrap the content in <pre> tags after running it through htmlspecialchars.
PDF
There is no native way for PHP to turn a PDF document into HTML and images. Your best bet is probably ImageMagick, a common image manipulation program. You can basically call convert file.pdf file.png and it will convert the PDF file into a PNG image that you can then serve to the user. ImageMagick is installed on many Linux servers. If it's not available on your host's machine, please ask them to install it, most quality hosts shouldn't have a problem with this.
DOC & DOCX
We're getting a bit more tricky. Again, there's no way to do this in pure PHP. The Docvert extension looks like a possible choice, though it requires OpenOffice be installed as well. I was actually going to recommend plain vanilla OpenOffice/LibreOffice as well, because it can do the job directly from the command line. It's very unlikely that a shared host will want to install this. You'll probably need your own dedicated or virtual private server.
In the end, while these options can be made to work, the output quality is not guaranteeable. Overall, this is kind of a bad idea that you should not seriously consider implementing.
I am sure libraries and such exist that can do this. Google could probably help you there more than I can.
For txt files I would suggest breaking lines after a certain number of characters and putting them inside pre tags.
I know people will not be happy about this response, but if you are on a Linux environment and have pdf2html installed you could use shell_exec and call pdf2html.
Note: If you use shell_exec be wary of what you pass to it since it will be executed on the server outside of PHP.
I thought I'd just add that pdfs generally view well in a simple embed tag.
Or use an object so you can have fall backs if it cannot be displayed on the client.
I realise this may just be speculation, but I'd appreciate comments from anyone who has some insight into this.
Something like MS Word COM add-in, or an OO bridge, or a custom implementation.
The reason I want to know is that I want to provide basic online document editing (really basic, basically just rich text at this point) for a php web app. I'm guess I will store the markup in html format then convert to rtf/doc etc for user convenience.
The Apache POI project (written in Java) offers an interface to many file types from the MS Office suite.
You can run the Java code from within PHP using the PHP/Java bridge.
I used this once for an application where MS Word documents had to be indexed in a web application. I remember that setting everything up was quite a hassle, but then it worked very well and reasonably fast. (Unfortunately, the code was written in PHP4 and I don't own it, so I cannot help you out with any snippets here.)
P.S. I cannot post links since I'm a new user, so google for "Apache POI" and "PHP/Java bridge" to get to the respective project's homepage.
This class might help you. I've never used it but here are some links:
Reading from a Word Document with COM in PHP
create a word document
Create Word Document using PHP in Linux
They have probably written their own, maybe starting from wvWare or something similar. I have noticed that Google Desktop on Linux seems to use wvWare to parse MS Word documents.
The documentation for the Word file formats is available, but reading through it makes you realize that it would not be an easy task.
Automating Word or OpenOffice would be the easiest, but there might be licensing issues with using Word like that, and possible concurrency issues with using either of them on a web server.
A popular way to do it is to generate RTF with the file extension .doc. It works fine with Word and other editors, and users remain happy that it is "a DOC file"