Does ExtJS support decoding of OOXML or ODF files? - javascript

I want to develop a web office project just like Google Docs and ExtJS seems good. Can ExtJS read OOXML or ODF natively? Or is there any open source project which can help ExtJS decode OOXML or ODF files and edit them?
Many Thanks!

ExtJS is a client side javascript framework. It cannot read any files be it OOXML,ODF or PDF. Are you trying to display a file or download it? there is no file handling involved with ExtJS.

try to look at odf javascript framework: http://webodf.org/demo/

You'll need to read the file with a server side script using something like PHP. Then pass this to the client side using AJAX.
ExtJS has the AjaxRequest method which you can use to get data from the server. Then pass the response text to the value property of the element you're using to display the file.
Going to be working on something similar myself soon.

If all you want to do is preview the google doc in your client side application, grab the preview url of the doc (every doc should have one) then display that document in an iframe in your extjs application.

Related

display the pdf in the same window

there is a requirement where i have to show the pdf in the same window (may be inside the embed/object/iframe).
i am getting the pdf from the service in array buffer format, when i get it i am converting it to blob and generating a temporary src for this using
URL.createObjectURL(file)
I know that createObjectURL is not going to work in IE as it is not allowed there.
now the only option i have left with is to use any third party library like pdf.js to make this thing work.i have tried the same and i had some success in it.But as it comes with the big worker.js library i am trying not to use it for just one thing.
can someone please suggest me if is there any other way of achieving this task?
i have following things or questions in my mind.
host this pdf online and just return the pdf link to the front end(i am not a bakend developer so i dont know if it is possible to host pdf dynamically somewhere in the same domain or at any third party host)
get something equivalent to 'URL.createObjectURL' for explorer and then use object/embed/iframe to show it
render the pdf in a page at server side and just return the whole document to front-end.
try a heavy library like pdf.js and make it work(last option for me)
any other solution which i am not aware of.
thanks in advance for your help.

How to print PDF data from InAppBrowser (PhoneGap)

I am using PhoneGap / Steroids for an iOS app.
In PhoneGap, I request a pdf from the server. The pdf is received in base64 format.
I am able to successfully preview the pdf using InAppBrowser:
window.open( "data:application/pdf;base64," + pdf.data, "_blank" );
However what I really need is to send this pdf data to the printer via AirPrint. Is it possible to do this using InAppBrowser? If not, what is the recommended method?
Thanks (in advance) for your help
Well, I don't think there is any use for InAppBrowser for this purpose. What you should look instead is for plugin that connects to AirPrint such as Cordova Print Plugin. This allows you to connect to AirPrint from within your JavaScript code. I'm not sure about if it fits all of your purposes, though, but take a look.

Pure JavaScript or jQuery file download function

Using Javascript, I'm trying to establish an appropriate method to display a PDF file in a new browser tab. If the browser doesn't have an in-built PDF viewer, I'd like the user to have the option to download the file. My research has led me to John Culviner's jQuery plugin jquery.fileDownload.js here, and that looks a great fit. The issue I have however is that I don't have access to the web server hosting the site in order to upload the plugin. I've also been unable to find a CDN that hosts the plugin and which I could link to.
Does anyone have a few 'best practice' suggestions to achieve my goals that I can research further? Thank you.
There is no need to involve JS. Just link to the PDF. Use the target attribute to trigger a new tab.
<a href="foo.pdf" target="_blank">
If the server lies about the content-type of the PDF or sends a header that indicates it should be downloaded instead of rendered, then you are out of luck.
If you really want to use JS, then:
window.open('foo.pdf');

Most used approach to generate a PDF report (JavaScript, node.js)?

Can anyone who worked on something like this describe the general process? I'm very confused right now. By report I mean a visually appealing document with logo, tables, headers and footers, and the data will be retrieved dynamically.
The approaches I looked at are:
Use a server side library (node.js module) that generates the PDF. Send the string representation as response with Content-Type: application/pdf.
Problem: I chose PDFKit, but it doesn't work and no content shows up at all. It uses PDF 1.3, which is old.
Generate PDF on client side.
Problem: Most popular library seems to be jsPDF, but it's not very capable of producing sophisticated-looking documents.
Write template in PDF source code and fill in the data on server side.
Problem: The encoding is weird, for example if I just do doc.text("1"), a lot of unrecognizable characters appear for just the string "1". I'm very confused about this.
Finally, it'll be super helpful if anyone provides a link that can help me understand the encoding! It's super confusing to me.
Any experience with similar tasks is much appreciated!
I haven't personally done this, but the first thing I would try would be:
On the server side dynamically build the appropriate HTML document and CSS
Use phantomJS to render that document
Tell phantomJS to convert that document to PDF, saved in a temp file
Send the PDF back as the HTTP response by writing the temp PDF file to the response body
Delete the temp file
If you are struggling with content-type, content-disposition, etc, you shouldn't have to worry about that if you have a valid pdf file on disk and just write that data to the HTTP response. With the right headers, you should be able to ask the browser to either display the PDF or treat it as a file to be saved as a download.
As the member of jsreport team, I would give it a shot.
jsreport platform provides multiple ways how to generate pdf reports. The most common included one is to transform html into pdf using headless chrome. jsreport will also compile and render handlebars or jsrender html templates if its specified, it can embed images, add header/footer, run custom javascripts and more.
You can play with the examples and see the options you have
https://playground.jsreport.net
When you are done with playing, you can use jsreport online or download and install jsreport server to your company. Then you are ready to call its REST API and generate reports.
More to your question
jsreport will provide correct content-type in the response for pdf or html. You can just let the browser to display the result
data can be sent to jsreport api or retreived by custom script
I'm not sure what the most common approach is, but personally I like to create an HTML template, populate it in my server-side code, and then use wkhtmltopdf to convert the HTML into a PDF. If you're using .NET you should check out WkHtmlToXSharp (which is a .NET wrapper for wkhtmltopdf.)

How to read and display XML file from url using javascript or jquery mobile?

I'm working on creating an android application with PhoneGap. What I'm trying to do is to display the content of a xml file from the website (.php format) that I have created. Any suggestion? Thanks.
You need to whitelist your domain like mentioned over here after that you can simply use jQuery ajax

Categories