How to edit underlying xml files of a .docx archive? [closed] - javascript

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 days ago.
Improve this question
Basically I need to generate dynamic .docx files at runtime. I initially wanted to generate them on the client side to lighten the server workload, since all the necessary data is on the client side. But to simplify the problem, I decided at first to do everything on the server side with Node.JS.
My first attempt was to use docx.js to create the document from scratch before sending it to the client to download. This part is simple and works fine, but the problem is that I have to create more than 10 templates that are quite complicated in design. I was thinking of uploading a document via docx.js to modify it afterwards but this library does not allow to do that.
Then I opened a .docx file and I realized that its underlying structure was an archive containing several XML files, including a document.xml which seems at first sight to contain the text of my document.
So I had the idea to create via OpenOffice or other my templates, and to write functions on my server to open these archives, to modify the values of the document.xml file and to reformat the .docx archive and send it using response.setHeader("Content-type", "application/vnd.openxmlformats-officedocument.wordprocessingml.document") and response.end(blob, "binary").
Any ideas on how I could edit the underlying .xml files in the .docx archive?

Related

Reading a JSON file to edit [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I was given a JSON file and told to read it to get a better understanding of how JavaScript programming works and edit this file to do what I need it to do. It's supposed to be a file to run some cleaning processes on client computers, so I just need to edit it so that they file will run all the processes I want it to run without having to send multiple commands to the computer through my RMM.
When I open the file however in Sublime Text 3 it looks like this. How do I get it to read as JavaScript programming language so I can edit it?
{"os":3,"procedure_type":1,"name":"Clear_PrinterSpool_DNSCache_EventLogs","description":"","version":"2.0","payload":"cX8e1mZa4ffL5OfFuWnR+cqMYnnhpC5Myt22X+nx5dMeS1BYFK5yLlxTPWDPMiw3c0XnZD7Y5zrPIRD9EIxuYLEAa3MYYHZVHhfIUb5MeDifqw3+FHhA/IjFcyL9eSzJ/Nmt2TLu5bPSTQkzqBT9GAdiL0YsDxqn8mpttL0mDCa0g5gJ0vfI41lynD0L8pma6dQ5b3+I+JhSq9irNcHMRrhUkL8dfRUrzIasT/s0q0Ksy0jVu/lcMH+ab0CFlxRMB3aP5dZkBkjTPa4n54pX8yOHejnTbi0qXxVJSBLmFeV4Usw8f/dzbzdR+NN/qSaLP2JU4GXdHjgAIwk0Xb09oFbOhJIu4r7rPku0zLcaq5YXufXXWgzHmBo0AFg1xkGztsfA639dlxZXECxVx4ykMJWnFGl4nowGqsflHSddA4/Q72Nr0ZUm0nM2VAyBhQe8HZ2Z1FwRdBzM8i/YsC6LTGXXjgnn0xin/W2+y+7P+t4n0UFFFAaRT68GuvA/IuwuRjNEIfwhRo5s+qf5D9N1Rbxb/+dvzVVIuwrUIa8HZFHLJM1m4NURNCOTI3aW2o+Qigeah2AOVK4i/mIo94GJ4cnm4odFlli70R8XuKVFzNuKAHfn/TvMorlTdeWaYlLGB67EMtVvGEgSDPCk0mSJkWMzzHm+bxZo+LIAAspBjZuivP68kSm+2FKpMWqlmlKvlx9M+oy+P0koePHx3Ndi4p+Lsm9/mgHyvp3ZdfgmPuMdzOvrMlcibzdAi6e+TohtcQIJpk/yk5OIHgTysbSahwACiwaSLwqLh4SfcQRmmBAn8GoIA+PyD4g3zyErJmaJo6HcpJUcH0g7ytV/rotVvpr+2zW49fPRnCcm8q5pt12qROby42bLUMp/rm03EM+MUKB6I+YzWHENm8tg/O7UDanCyz7DIBbDl4hob8KtL7PA0QDjd9KQ61l/Ld7fNQ9vjNDD+uVaGyDim1ANhwdPMX/nJmvKmVc37XOgEd0AsmicZ8W2FobZpM3yfAdxD3to52N9fwC7T9exYE50RG7+McS+mtd8BRicXe5QfSH5P12GDM9+LaaUVdKzm63FZzhyX/0xpGN97q1VNKPAa6CfO5D/LD21mCrrPeOCeYJ2lHtTo7cW2iu7AXx0WRusz9PX162D+eqeo/ZFmflQv4MpMxnc00pT+QRxX3YZhX/50YU=","payloadChecksum":"d80877609ce0b19f6dcbe3c35d57cd03"}
You can just create a backend call, the URL being pointed to the location of this JSON file.
In the result of that backend call, you will get the contents of the JSON file.

Node-Red save to local file [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
have looked serveral days now to find a Possibility to save data from my MySQL Database to a local file (on the client PC not the server) to analyze the Data there.
I have tried the standard file out node but that only saves to the server File system.
the Flow i am currently using is like this:
If the Button is clicked the data collected by the Function node is send to the Template node.
The last approach i have found some minutes ago was this: Data URI, but I dont get how to put my msg.payload to the file content.
Sorry for this dumb questions but im barely new to HTML and using it in node-red.
Thanks in advance.
Use the http-in and http-out nodes to create a HTTP endpoint that will return the data you want.
If you wire the output from the http-in to the input of the database node then the output from the function node to the input on the http-out.
You can then just point your browser at the URL you configure in the http-in node and the browser should download the data so you can save it locally. You may need to set the Content-Type header to make sure the browser does the right thing with the data.

Echoing HTML or generate it through JS [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a functional project that is basically a database table editor. You load a table and you can get the rows info, edit it, add, delete, add child rows, etc.
I am rewriting the entire thing because it is very unorganized. I am attempting to create a class based system (yes I had 0 classes). This is my first class based project and, that being another issue, I would like to know the best (performance, maintainability, ease-of-writing) way to generate dynamic HTML. I use Javascript and PHP
Really the options, when outputting dynamic HTML are:
Echo it directly, or JSON encoded, from a PHP function or class
Build it from Javascript and append things to the document
I can either make a request from JS and append the data directly from PHP, or I can just get back raw data from PHP (database) and build it using JS. I really don't know what the optimal way to go here is. Currently I am raw echoing my tables and editing forms, and it works, but it's a mess.
To provide data (via php) to your WebApp, you should build a REST-Service (in php simply a new php file), perform the database requests in the php file and give the data as JSON String back to the client.
So in your client App you can make a AJAX request to get your data and parse the responseText with JSON.parse(responsetext) to a javascript object. Now you can access the data in the object.
For building webapps with databindings you should have a look on AngularJS. Angular is using a very interesting model to build nice Apps without thinking to much about DOM.
Best regards
Dustin
P.S.: You should also have a look on nodeJS. It's much faster than php and you can code javascript on client and serverside. Furthermore it has a bunch of features like Socket.IO where php cannot hold.

create PDF file in JS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am developing a web application using client side MVC. The technology stack is Backbone JS, HTML5 and Spring at the Server side.
I have a requirement where I do some data manipulation at the client side using Javascript by using JSON files as the data payload kept on the web server directly. This is a high traffic part of the app and I don't want to hit my app server for such siple data manipulations.
Now on the same module - I have a requirement where I need to generate a PDF file which effectively contains a static template and then I need to fill the template using effectively the same data that I already have at client side. I need to generate the PDF and let the user download it.
Any idea how can I acheive it completely at the client side in a clean and robust way.
From what I understand is you have an html template that you want to fill with certain data and then render it as a pdf?
For client side, have tried looking at something like jsPdf (http://parall.ax/products/jspdf)? The html renderer is still in early stages but it seems to work decently.
As Bogdan pointed out, a backend solution is also possible. You could look at pd4ml (http://pd4ml.com/) or even call into something like pandoc (http://johnmacfarlane.net/pandoc/) or even phantomjs (http://phantomjs.org/) to perform the conversion and then pass the generated pdf back to the client.
If it is not an html template, I am sure a number of the above solution should work regardless.

extract text from pdf file using only javascript [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How can I extract data from pdf file, using only javascript, in client side and with any browser?
pdf.js is a JavaScript pdf reader:
http://mozilla.github.com/pdf.js/
Some similar projects:
for docx and xlsx: http://blog.innovatejs.com/?p=184
jsPDF is a pdf generator: https://github.com/MrRio/jsPDF
If you are asking how to load the file, this can be done via an ajax request, but you won't be able to directly read the file content.
What you're asking is practically impossible.
PDF is a heavyweight format optimised towards efficient display of large complex documents, not towards further processing. (In fact, PDF documents primarily consist of letter shapes and other graphics absolutely positioned on pages. Any data representing "paragraphs of text" is an optional feature of tagged PDFs.)
Text extraction tends to be a feature of (usually expensive) PDF libraries, and to the best of my knowledge no such library exists for Javascript. Scribd and Google Docs do this, but they probably don't share how, and my guess is they do this on the server side.
tl;dr: PDF, as a format, is terrible for this. Unless basically the entire point of your application is extracting text from PDFs, your time would be better spend on figuring out how to not have to do it.

Categories

Resources