Git Product home page Git Product logo

stephen-hardy / docx.js Goto Github PK

View Code? Open in Web Editor NEW
451.0 451.0 141.0 169 KB

DOCX.js is a JavaScript library for converting the data in base64 DOCX files into HTML - and back! Please note that this library is licensed under the Microsoft Office Extensible File License - a license NOT approved by the OSI. While this license is based off of the MS-PL, which is OSI-approved, there are significant differences.

Home Page: http://blog.innovatejs.com/?cat=17

License: Other

docx.js's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docx.js's Issues

show diff between 2 docx versions.

Given I have uploaded two versions of a docx document to the web app
When I click "View Difference"
Then I should see reds and greens of text deleted and added between the documents.

Is that possible with docx.js?

If not, can you point me in the right direction please?

License is confusing

I am not sure how the license agreement is meant to work. In LICENSE.txt, line 22:

(F) Platform Limitation- The licenses granted in sections 2(A) & 2(B) extend only to the software or derivative works that (1) are run on a Microsoft Windows operating system product, and (2) are not Excluded Products.

This is JS, meant to be run from a web page in a browser. I can't use/place this code on a Linux/Unix server?

Please upload to npm (Node Package Manager)

Hi Stephen,
If you could, please upload this package to npm (node package manager). That way you will get recognised better for your work and I can reference your library without pasting the functions.
Thank you in advance!!!

Pass file path to javascript input android

I understand that providing a physical file path to javascript is not possible due to security reasons. However, when I look at Mozilla's pdf.js and mupdf android pdf viewer I see this is very much possible. There is a mechanism by which I can pass a file path to javascript. I explored into PDF.js but it seemed little difficult to make use of when I needed a simple solution. I want to pass android internal storage file location onto the following code instead of using input id="files" type="file" which requires me to browse and select file. In my case I want to just pass file location from sdcard. The following code actually loads ms word (docx) file as html which I then will show in webview in my project. In the case of pdf.js we were using it to display pdf in the similar way.

What I found on the PDF.js code which was used to input file : In pdffile.js included in index.html file, url variable was mentioned pointing to real location of the file i.e. in assets folder which then was used in pdf.js but at that point the usage seems confusing. Is there any way by which I can use real path of file or pass real path somehow in android for my purpose of viewing docx?

I find that PDF.js by Mozilla actually treats file location as a url and so the file in the url is converted to javascript file object or blob. Hence I create a blob of the url from server using Ajax :

 var myObject;
var xhr = new XMLHttpRequest();
xhr.open("GET","10143.docx",true); // adding true will make it work asynchronously
xhr.responseType = 'blob';
xhr.onload = function(e) {
    if (this.status == 200){
        //do some stuff
        myObject = this.response;
    }
};
xhr.send();



$(document).ready(function(){
//Input File

var $files = $('#files');

//File Change Event
$files.on('change', function (e) {

//File Object Information
var files = myObject.files;

//Create DocxJS
var docxJS = new DocxJS();

//File Parsing
docxJS.parse(
  blobToFile(myObject, "10143.docx"),
  function () {
    //After Rendering
    docxJS.render($('#loaded-layout')[0], function (result) {
      if (result.isError) {
        console.log(result.msg);
      } else {
        console.log("Success Render");
      }
    });
  }, function (e) {
    console.log("Error!", e);
  }
);

});
});

function blobToFile(theBlob, fileName){
//A Blob() is almost a File() - it's just missing the two properties below which we will add
theBlob.lastModifiedDate = new Date();
theBlob.name = fileName;
return theBlob;
}
However now that I do that I get Parsing error from DocxJS like : {isError: true, msg: "Parse Error."}

Corrupted Word Document in PhoneGap / Cordova

I have used your script for generating a Word docx document in my app developed in PhoneGap / Cordova for Android and iOS. However, it fails to create a valid docx document. The generated document displays an error message stating "File is corrupt and cannot be opened" in all readers.

I suspect the problem lies while accessing the xml files packaged with your script using XmlHttpRequest object since I get the similar problem while testing on Chrome browser.

Does your script support PhoneGap / Cordova?

Any Documentation?

Just wondering if you have any documentation on how to implement docx.js with JSZip? Or anything that can help me understand how DOCX.js works with JSZip.

Thanks.

Please add a big warning that the code is licensed under the "Microsoft Office Extensible File License"

Many people assume that code on github is open source, but that is far from the truth. In fact, the Microsoft Office Extensible File License exemplifies Open Source Trolling: each clause an insult to the diligent readers' intellect.

The real problem with all code under the license is that it muddies the water. Microsoft could use your code as a reason to take legal action against others who genuinely try to innovate and use DOCX as a data format. You hurt the community far more than you help by releasing pseudopen source code. Ever think that those lawyers might want you to do this so that they can go after others later on?

@stephen-hardy I think you are a reasonable person, and I might be niggling a bit, but neither of us want to see innovation stifled by myriads of lawsuits because one person's effort to release code created a miasma around a beloved software product. Let this be a clarion call, and please share with your coworkers and superiors: unless the code can be released in a proper open source format, it's better that you don't release it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.