Edit documents with JavaScript in browser
This library depends on zip.js library and these APIs optionally:
docx
txt
fb2
odt
csv
tsv
rtf
gif
jpg
jpeg
pjpeg
png
svg
tiff
icon
wbmp
Include script on your page:
<script src="js/jDoc.v.js"></script>
or
<script src="js/jDoc.v.min.js"></script>
where v
- library version
You will be available to the global object jDoc
Read the document. Example:
var jd = new jDoc();
jd.on('readstart', function () {
console.log("START ", arguments);
});
jd.on('readend', function () {
console.log("END ", arguments);
});
jd.on('read', function (fileData) {
console.log("READ ", arguments);
});
jd.on('error', function (error) {
console.log("ERROR ", arguments);
});
jD.read(file);
file
- File object or Blob objectfileData
- object with methods:html
- return result as documentFragmentdata
- return result as object {}
error
- object, {message: ""}
error
can be:
- {message: 'Invalid file format'} - invalid file format
- {message: 'Can not read file'} - System error reading file
- {message: 'First argument must be type of File'} - argument 'file' must be instanceof File
- {message: 'Invalid file type'}
- {message: 'Can't load the file'}
- {message: 'Not have the required technology'} - unsupported browser
Bind a callback function to an object. The callback will be invoked whenever the event is fired.
Just like on, but causes the bound callback to only fire once before being removed.
Remove a previously-bound callback function from an object. If no context is specified, all of the versions of the callback with different contexts will be removed. If no callback is specified, all callbacks for the event will be removed. If no event is specified, callbacks for all events will be removed.
This event will always trigger when we will start to read the file.
This event will always trigger when we will finish to read the file (with/without errors).
This event will always trigger when we will success read the file. In the handler of this event we can have one argument - fileData, result of reading.
This event will always trigger when we will have some errors. And we will one argument in the handler of this event - error object.
Return clone of obj
The deep copying obj2
to obj1
. Return extended obj1
Return css rules for A4 format of sheets in dimensions. For example:
{
width: {
value: 792,
unit: "pt"
},
height: {
value: 612,
unit: "pt"
}
}
This browser support required technologies for jDoc or no. Return true/false;
Return Array with supported document formats.
name
- custom name of engine. F.e. "ODF" for ODF document formatformats
- array with supported document formats as MIME types. F.e. ['text/csv', 'text/tab-separated-values']engine
- object inherited from jDoc.Engine
protoProperties
- object with properties for new Engine prototype
Build a library:
grunt readers
- build all readers engines for supported formatsgrunt readers:include
- build all readers engines for supported formatsgrunt readers:include --rtf --oxml
- build onlyrtf
andoxml
enginesgrunt readers:exclude
- exclude all readers engines from buildgrunt readers:exclude --rtf --oxml
- build all readers engines for supported formats exceptrtf
andoxml
engines
- 2013-09-10 v0.1.0 Work in progress, not yet officially released.
- 2013-11-10 v0.2.0 Support of RTF format.
- 2014-01-12 v0.3.0 Add web workers support.
- 2014-08-01 v0.4.0 New architecture of jDoc and new features. NEW VERSION ISN'T COMPATIBLE WITH 0.3.
- 2014-08-19 v0.5.0 Add images engine support. Bug fix.
Library submitted by "webschik" Knyazevich Denis