pdf.js analog for Word Documents - javascript

I am searching for a JavaScript library that is similar to pdf.js but allows the viewing of Word Documents (.doc and .docx)
Are there any?
UPDATE:
There is an interesting library called DOCX.js
But I'm searching for something more advanced.

I doubt it. Behind pdf.js stands Mozilla, so it isn't a weekend project.
There are options to let LibreOffice run in the browser, but I have no first-hand experience with it. Apparently, some cloud projects like NextCloud use it, though.
Then you have Google Docs to import the Word file and let it be displayed there, but there is no way to embed that easily or even host the code yourself. (Also, as I understand it, there are transformations to the Word file on the server involved.)
And after all, if you compare the PDF spec with the OpenXML (aka .docx) spec, it becomes quite clear, that a fully compliant viewer will be a complex beast, to say the least.

I just found out ViewerJS, but it only supports OpenDocument formats. It's not what you were looking for, but may be worth a shot, specially if you can find a way to convert odt to doc (this question might help).

At a glance, it looks like Flexpaper can be used to this effect, but it's effectively using a server-side version of open office to convert the document into images that can be viewed on the web. This'll work in a pinch, but certainly lacks the quality of pdf.js.

You can use ViewerJS and JOD Converter (http://www.artofsolving.com/opensource/jodconverter.html) together to achieve requirement. First you can convert office documents to open office or pdf format using above converter. Then you can show those documents with the help of either pdf.js or ViewerJS

Native Documents (in which I have an interest) makes an embeddable viewer/editor for Word documents. There's an online demo where you can try your own document.

Related

How do I open the Microsoft Office Web Viewer with a search term already applied?

I want to be able to open an Excel sheet using Office Web Viewer, HTML viewing component. (This seems to also be called the "Office Web Apps Viewer".) The viewer component is a really excellent HTML office document rendering engine, but I can find absolutely no documentation online for it. It's even hard to discern what its correct name is. (Does anyone have details on the API?)
I need to be able to load the document and immediately call a JavaScript function to do a search so that the document opens with the search result already highlighted. Even better would be to be able to set the search term in the query string given to the viewer component.
Does anyone know if this is possible and if so, how?
I can say with quite some certainty that there is no such API as the viewer is not intended for such usage. Yeah, I know, not the answer you wished to hear, but then again, that's just the way it is. It's just a viewer, not a component to be used as part of applications.
The quick & dirty solution: Using an extension
One way to achieve what you want is to write an extension that would expose this functionality to you. Of course this would require your users to install this extension, but it is definitely an option and such an extension would be relatively simple to write.
The better solution: PDF.js
Convert your documents to PDF's using some server side solution.
On Linux with OpenOffice.org this could for example look like oowriter -convert-to pdf:writer_pdf_Export doc_file.doc or swriter for LibreOffice.
Present them using Mozilla's cross browser PDF.js library.
Figure out the PDFFindController how to trigger the highlighting. Take a look at this demo and next at this source file. In there they are definitely triggering the highlighting (search for the object I named before), but as it is not directly addressing this question I am not going to figure that one out for you.

Best way to design cross-platform multi-content-type file format?

I need to redesign a file format for a set of applications ( desktop/online/mobile.. ) which is to contain a set of non-linear data and multiple images.
I do not want to make it one large XML with embedded images as:
first of all it could grow to a size that would be for example slow to parse using javascript
second of all I want it to be editable 'by hand'.
The compression is not necessary. I just want to distribute this as a single files. I would like my solution to be as cross-platform as possible.
What I made up recently is a *.tar.gz archive with xmls and images inside.
The desktop (C++ / Qt) version of my application is reading the file using zlib (which was hard to code but works).
The online version is using PHP (execing tar) to uncompress the file (caches contents in database) and passes xmls and images to javascript via ajax.
When I came to develop an android version I'm kinda stuck and I don't know how to read it here.
I was wondering if there is a better / simpler solution to achieve this?
Solutions I found are for example:
Blender .blend files http://en.wikipedia.org/wiki/Blender_%28software%29#File_format But this is not readable without any special tool.
OpenOffice files which are in fact zips.
But I guess there is no big difference using this or tar.gz. It still would be a problem to read it on a mobile platform or with javascript.
Probably there is no 'best way' to do this but i hope there are some widely used solutions?
I will appreciate any thoughts on this.
I'm not sure if this will meet your "editable by hand" criteria, but to make a single-file, cross-platform binary format, Google Protocol Buffers are very useful and efficient, and work across major platforms and languages.
If "editable by hand" is critical, with a little extra work, you can write simple utilities using your own message libraries to support creating/updating/deleting portions of existing files (e.g. extract out images for editing, and support replacing them.)
If it must be editable in JavaScript, perhaps JSON might be a good option? You can insert pictures/video/other files by using base64 data url encoding, which is supported in Javascript and many other languages.

Is it possible to build a web-office application with JavaScript and OpenOffice?

I want to write a web site which can edit OpenOffice document ODF, user can upload ODF file to website, edit them, and download them as ODF again.
How can I do this? And how does docs.google.com do it?
Now I want to try OpenOffice (LibreOffice) UNO programing at server and JavaScript on website, is it possible?
If it is possible, how can I do it?
In general. Yes you can.
Open office is 'open', thus you can by browsing it's code you can learn how ODF's are created and kept. But you should find specification of all open office documents, it's out there, and it's a reason why all open offices documents have been granted ISO standard a while ago.
I think there should be a plenty of already scripts that are converting doc to odf, pdf to odf, backwards and etc, try googling for your favorite php/python/ruby/java/other script that provides such solution. Maybe there is even a solution that is changing PHP's object into doc/odf/pdf format and let to convert one format into another.
Editing it in a browser that is much harder and requires a lot more work. But google docs shows it possible.
In few words, a lot of work, and some work already done by community. Need to a google bit to find that pieces.

JavaScript edit-inplace-holders which work with Wiki sources

I'd like to dynamicly parse in text wiki-content.
I found JsWiki but its in beta form, and looks like with no community even developers). Any other?
It depends what you mean by wiki content. There are many wiki frameworks just as there are many formats for wiki text. If you're looking for something that parses mediawiki content, such as wikipedia, there's a good list of parsers here. Some are Javascript based and I've had a good experience with one of them, InstaView.
It may be that you're just looking for a form of simple markup, in which case you could try using a library like ShowDown instead.
You could use the Ra-Ajax InPlaceEdit for such things if you're on ASP.NET. It doesn't have automated built in wiki parsing, but it allows for adding up any control you wish including LinkButtons and Literals which you can then build up with the HTML you want yourself...
There is another beautiful Javascript (only) based wiki editor. I just loved the idea itself. Check it out TiddlyWiki

JavaScript object browser?

I was recently tasked to document a large JavaScript application I have been maintaining for some time. So I do have a good knowledge of the system.
But due the sheer size of the application, it will probably take a lot of time even with prior knowledge around the code and the source code itself in uncompressed form.
So I'm looking for tools that would help me explore classes and methods and their relationships in JavaScript and if possible, document them along the way, is there one available?
Something like object browser in VS would be nice, but any tools that help me get things done faster will do.
Thanks!
Firebug's DOM tab lets you browse the contents of the global window object, and you can inspect a particular object by entering inspect(whatever) in the command line.
You won't be able to use it to detect relationships unless an instance of one object holds an instance of a related object, but it's a start.
You can also use the Options menu on the DOM tab to restrict what's shown to user-defined functions and properties, which should help reduce clutter.
Take a look at Aptana, they have an outline that can help you to determine what are the objects and somtetimes their relationship.
Firebug + uneval(obj) is a simple trick that is often helpful.
I see a lot of people talking about examining the DOM within Firebug. However, from your question it looks like you want something like jsdoc? just add type and class information through comments and jsdoc generates documentation including class relationships. http://jsdoc.sourceforge.net/
Google has a fork of it with added functionality http://code.google.com/p/jsdoc-toolkit/
UPDATE: It's not a fork, it's a rewrite by the developer that wrote jsdoc originally as a perl script. It aims at being more adaptable so you can use whatever js inheritance/events/properties style you'd like. Another feature is that it lets you modify the templates used to generate the HTML in a much simpler way.
We don't know if this JS application is designed to run in a Web browser...
If yes, as advised, Firebug (a Firefox extension) is excellent at debugging JS and exploring Dom.
On the IE side, you have some tools like IEDocMon, Web Accessibility Toolbar (it does more than its name) or Fiddler (unrelated to your question, but still a good tool to have).
Firebug (Firefox) / Dragonfly (Opera) can help you with viewing objects in realtime
Aptana / JS/UML(Eclipse) can help with relationships of objects
This is an old question, but let me answer it anyway.
Use an IDE. Integrated Development Environments were made for jumping around rapidly among the code. The key features you will exercise during exploration are viewing the file structure or outline, jumping to a declaration or usage, and searching the entire project for all instances of a string. If you are using WebStorm, set up a custom scope for files except generated files and node.js to aid in searching.
Run 'npm la | less' which lists all your dependent modules with one line descriptions. You may have never seen moment.js and never need to read the documentation, but taking the time to read a one line summary of it is worthwhile. If you need more information on a tool than one line summary, search for the term on SlideShare. Slides are faster than ReadTheDocs.
Document a little as you go. I'm a fan of forcing people to use notebooks constantly rather than scratch paper. Also, I find adding a one line comment to each JavaScript file is worthwhile. You want to know what should be in each directory of your project. I also recommend building a glossary of the exact meaning of domain terms in your system, e.g., what does "job" in your system.
Finally, you may need to just fire up the application in a debugger and start stepping through parts of it. Most large projects have accreted worth from programmers of various skill levels and motivations.
You are aiming for a level of "conceptual integrity" (to quote Yourdon) or to "grok" the software (to quote Heinlien). It does take some time, cannot be bypassed, and can be done efficiently.

Categories

Resources