Quilljs Downlaod .docx - javascript

I'm creating a online document creator as a feature of my site using Quilljs. I have it set up and was wondering if there is a way to download the document after it is typed up? Maybe using php or javascript and Preferably in; .doc, .docx, .txt or any other basic text formats. If there is another framework like this and it has this feature then please let me know.
Thanks!

Quill content is represented by Delta format which is a simple list of insert/retain/delete operations.
You can get the HTML on the client side with:
document.querySelector(".ql-editor").innerHTML
You can use other tools to convert the HTML to docx on the server side.

Related

How to convert DOCX to ODT format using javascript?

I am working on a in-website document editor(word and excel document). So far I am able to edit ODT files using WEBODF. Is there any way to convert DOCX file to ODT using javascript so that i can use the file in the editor? any alternatives for editing word and excel documents inside a website? I have tried saving the file in OneDrive and then using the share link to open editing on sharepoint but this editor cannot be inserted inside an website and can only be done in a new tab? i need the editor inside the website as i need to implement azure versioning of the documents
WebODF is an awesome tool to be used as an online editor. Assuming you have no restrictions implementing a separate backend server, you can use libreoffice, which gives you a command line utility to exactly perform that job. You can convert docx file to odt file using the following command -
soffice --headless --convert-to odt <input file>.docx
The approach would be to create an API
Which would take docx file as input
Store that file temporarily somewhere and run the above command
Serve the converted odt file and delete the temporary files.
If you want to store those files in the server, then you can maintain a database to achieve that as well.
To take care of restricted cross origin policy, you can implement AJAX calls in the front-end to perform file uploading and viewing operations using Javascript blobs.

How to convert RTF file to HTML in native Javascript code (no frameworks)?

I am trying to convert a .rtf file to an HTML file so in can be displayed on a mobile device in web view. I have seen a solution but it is either in a different language or requires the use of modules; however, I cannot use modules for my situation.
Thank you.
I think you should convert the RTF file on the server side before making an HTTP request for the HTML website. You will have to decide how you want the RTF to be formatted in the HTML document.

How to display Microsoft .doc or .docx formats in a webpage?

I'm trying to display word documents in a browser without relying on cloud transcoders such as google docs.
For .pdf I use pdf.js
for odt I use webodf
How can I display .doc ?
How can I display .docx ?
I'm not interested in editing files, just viewing. And I'd prefer keeping the codec on the client-side, in (compiled) javascript.
I don't think there is a way to directly show doc and docx documents in a browser, unless you first convert them on the server side, and then use a library like WebODF to display them in the browser.
You can use Node.js for such server-sided conversion, which makes it lightweight and cross-platform.

HTML5 / JavaScript: open text file, load into textarea / save textarea content to text file

I want to do two things in my browser:
Load a text file into a textarea (has to be choosen via dialog box)
Save the content of a textarea into a text file (has to be choosen via dialog box again)
Load a video file and grab the file path to use it with a video player (1)
I've been looking around for a while on the internet. There are some solutions for IE only via ActiveXObjects, which I can't use (IE, seriously?). HTML5 file API has limited usability because I can't access the selected file's path.
I also found save dialogs for textareas, but they ignored line breaks for some strange reason and I don't know how to fix that, if possible at all.
So here are my requirements and options:
Support for FF and Chrome
JavaScript, HTML5 (and PHP, if it has to be)
possibly Silverlight, but I'm not very familiar with it and may only copy and paste :-/
it has to work on Mac as well
There is a dirty hack that gets the job done without resorting to Flash or Silverlight, or using a server, and it works in most browsers:
var uriContent = "data:application/octet-stream," + encodeURIComponent(fileContentsAsString);
window.open(uriContent, 'Save Your File');
JS runs in a sandbox. That means: no access to files on the filesystem. HTML5 file API is the first „native” (as in not flash nor activex) attempt to grant limited access to the users file system.
The File API is HTML that would allow you to access data, after which you can manipulate binary blobs in JavaScript, but as written this is not possible in pure JS and HTML based on your requirements.
The big blocker is "saving to a text file." The only way I've been able to do this is by opening up an iFrame that calls a server side language (such as PHP) to set the content type in the header to a type that prompts a download.
Flash and Silverlight are "client" technologies that run outside of the sandbox, which sounds like your only option at this point.
My ideas:
Load a text file: Use a normal HTML upload form (if you want to script, maybe submit it via AJAX)
Save a text file: Use a textarea and upon submitting, create the file server-side and then offer it to download. (As mentioned before, client-side scripts do not have access to the computer's file system)
Load a video file: Is the video on the server already? Otherwise will need an upload just like the text file. Then use a flash plugin to play the file from the server (the URI should be known to you then)
All of these are relatively simple to achieve using PHP. Line breaks from a textarea stay as \n in PHP.
Tutorials: Form handling in PHP, File upload in PHP
Edit: Since PHP runs server-side you should not run into a lot of problems because of browser diversity. Alternatively, you can do all of these in Flash or Silverlight as well, although from my point of view that takes more learning and is less comfortable for the user.

Converting ppt to images

I want to convert ppt to images on the client machine and zip all the images and send it to the server.
I've read on many forums and found that it's not possible to convert ppt to images on the server where Office is not installed.
So, I had this thought if the conversion could be done in the client browser and sent to the server, using JQuery or any other client side technology.
Any example would be appreciated.
Thanks
Aspose.Slides for .NET allows you to convert the PPT slides to images on the server, without the need for Microsoft Office installed. You might want to give it a try, if that helps. It is a standard .NET assembly which can be used on the server, in your application. The conversion is simple, here is the sample code:
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation("demo.ppt");
//Accessing a slide using its slide position
Slide slide = pres.GetSlideByPosition(1);
//Getting the thumbnail image of the slide of a specified size
Image image = slide.GetThumbnail(new Size(290, 230));
//Saving the thumbnail image in jpeg format
image.Save("C:\\thumbnail.jpg", ImageFormat.Jpeg);
Disclosure: I work as developer evangelist at Aspose.
Javascript generally doesn't have the capacity to modify files on the client machine and can't automate a file upload. You may be able to get the desired effect with a Java applet, I'm not sure. The alternative is to provide a stand-alone application that will do the conversion and zipping, then have the user upload the file manually.
Edit: As an afterthought, any reason you can't simply install Office on your server and do it there?
You have no control over the client machine once your html has been rendered and so you cannot achieve this. The user would have to do it manually.

Categories

Resources