Does anybody know how instead of providing a link to users to download a doc file, I can embed PART of the file on an iframe on the same page. I want to give users a teaser on the iframe but not access to the entire document..Thanks!
Asked
Active
Viewed 1,401 times
0
-
You mean a `.DOC` file like a MicrosoftWord document? – Pointy Jan 17 '12 at 20:33
-
thanks for the quick reply..Yes a .docx,.doc or even .txt – Jon Jan 17 '12 at 20:44
-
Well it makes a big difference. If you care about a wide audience, you can't really expect everybody to have a browser that can render .doc files. Web browsers are mostly concerned with HTML, not proprietary formats like that. Thus, you could pre-export some sort of summary as HTML, or else use some server-side code to render the file as an image. I've never attempted anything like that so I'm not sure what it'd entail. – Pointy Jan 17 '12 at 20:47
1 Answers
0
Browsers can't open native MS Word files.
For the '.doc' or '.docx' files, you'll need to read the except on the server-side and convert it into HTML. For '.txt', most browsers will read those natively, but if you want to show only an excerpt, you will need to read into the file, probably server-side.
See Convert .doc to html in php. Once you have HTML on the server, you can trim it down to make your excerpt before displaying it.
The bad news is this is probably more complicated than you thought. The good news is that you won't need iframes.

Community
- 1
- 1

peteorpeter
- 4,037
- 2
- 29
- 47
-
Thanks! That seems really tough ..http://www.notehall.com/document/profile/id/2685 Thats the effect ;m going for can't figure out how they do it. – Jon Jan 17 '12 at 21:08
-
That site looks to be using Scribd.com under some custom branding. Scribd is a whole company devoted to document management, so yes it's tough to reproduce! If you scope your functionality WAY down, though, you might have a chance. Good luck. – peteorpeter Jan 17 '12 at 21:16
-
ok cool thanks a lot..It seems Google has a really cool embedding option that works great for pdf..Tring to get it to work for .docx..:) – Jon Jan 17 '12 at 21:31