WebODF
WebODF - JavaScript Document Engine
WebODF
I need to get XML from a ODF file. I tried using FileReader readAsText and readAsBinaryString but its not working.
FileReader readAsText returns some special characters for odf files.
with readAsBinaryString
var reader = new FileReader()
reader.onloadend=function(e){
var data = e.target.result;
//data is not in xml format
var xml = str2xml(data);
//getting error
/*
using DOM parser for xml parsing
*/
}
reader.readAsBinaryString(file);
How can get XML from ODF file using javascript FileReader?
Source: (StackOverflow)
Is it possible for webodf to read a odf / odt file from its bytes? instead of an url?
Currently using:
var odfelement = document.getElementById("odf");
var odfcanvas = new odf.OdfCanvas(odfelement);
odfcanvas.load("url/to/file.odt");
and would like something like
odfcanvas.loadFromBytes(bytes);
Source: (StackOverflow)
I am trying to add document editor support in my website. I found Opensource WebODF and tried to test it on my local server. The git repository ReadMe gives instructions on how to add Odf viewer support.
I was able to test the localeditor. Can some one explain how to setup the collaborative editor on local server.
Source: (StackOverflow)
Using javascript
, I need to create an .odt
file and populate the contents with data in javascript
variables. The only thing that I have found that might work is WebODF
. An example that seems similar to it is here.
When I am trying to do something similar to PDF
with pdfkit
(using node) I can do something like this:
PDFDocument = require('pdfkit');
var doc = new PDFDocument();
doc.pipe(fs.createWriteStream(fileName));
doc.text("Fist line");
doc.text("Second line");
Is it possible to do something similar to it using WebODF
? I've found ops.OpInsertText, but I'm not sure how I can use it to actually insert text.
Again, ideally the solution is only in javascript
.
Source: (StackOverflow)
in my application, users can edit an ODF file via WebODF (http://webodf.org/). On save, i want to send the edited file to a servlet, have it convert to PDF via ODFDOM (http://code.google.com/p/xdocreport/wiki/ODFDOMConverterPDFViaIText) and open in a new window.
Currently i am trying to do this via AJAX. Everything works fine up to the point where i try to open the received PDF file.
My Javascript:
function showPDF(pServletUrl)
{
var successCallback = function(pData)
{
var mimetype = "application/vnd.oasis.opendocument.text";
var blob = new Blob([pData.buffer], {type: mimetype});
var formData = new FormData();
formData.append("file", blob, "test.odt");
jQuery.ajax({
type: "POST",
url: pServletUrl,
async: false,
data: formData,
processData: false,
contentType: false,
success: function(pSuccessData)
{
window.open(pSuccessData);
},
error: function(pErrorData)
{
console.log(pErrorData);
}
});
}
var errorCallback = function(data)
{
console.log(error);
}
_canvas.odfContainer().createByteArray(successCallback, errorCallback);
}
My servlet:
public void handleRequest(HttpServletRequest pRequest, HttpServletResponse pResponse) throws ServletException, IOException
{
BufferedInputStream tBufferedInput = null;
BufferedOutputStream tBufferedOutput = null;
try
{
List<FileItem> tItems = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(pRequest);
for (FileItem tItem : tItems)
{
if (!tItem.isFormField())
{
String tFieldname = tItem.getFieldName();
String tFilename = FilenameUtils.getName(tItem.getName());
InputStream tFilecontent = tItem.getInputStream();
if("file".equals(tFieldname))
{
tBufferedInput = new BufferedInputStream(tFilecontent);
pResponse.reset();
pResponse.setHeader("Content-Type", "application/pdf");
pResponse.setHeader("Content-Disposition", "inline; filename=\"" + "test.pdf" + "\"");
tBufferedOutput = new BufferedOutputStream(pResponse.getOutputStream(), 10240);
this.getOdtAsPdf(tBufferedInput, tBufferedOutput);
tBufferedOutput.flush();
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
finally
{
try
{
tBufferedInput.close();
tBufferedOutput.close();
}
catch(Exception e)
{
}
}
}
private void getOdtAsPdf(InputStream pInputStream, OutputStream pOutputStream) throws Exception
{
OdfDocument tOdfDocument = OdfDocument.loadDocument(pInputStream);
PdfOptions tPdfOptions = PdfOptions.create();
PdfConverter.getInstance().convert(tOdfDocument, pOutputStream, tPdfOptions);
}
It seems like Javascript wants to parse the recieved PDF file as a URL and (obviously) fails doing so. Is there a way to just open the file in a new window or do i have to find another way to do this?
Source: (StackOverflow)
I need to edit LibreOffice Calc document programmatically in C++. I know that there is odfkit
library, which uses webodf
, but it looks like it doesn't support editing .ods files.
Is there any alternative that can deliver me this feature?
Source: (StackOverflow)
I have some old program which we use to auto-generate table/curves etc. This program dumps LaTex.
We are now moving to ODF standard instead of LaTex.
I am look for some examples on how to use webodf to render documents like table, section, reference, table of contents.
I have look at the API for webodf but I don't know where to start.
Can somebody show men some examples in ex. node.
Thank you
Source: (StackOverflow)