How to send data into an OpenOffice word template from NodeJS - node.js

How can I get data passed from NodeJS into placeholders of a OpenOffice template file? Is there any npm packages available to parse an ODT template file so that I can print data into it?
I have a 13 page word file (a template for printing reports) and I want to populate it with certain details from the DB into the different pages of this file. I like to pass the data in JSON format.
What I know is how to write into a plain text/excel file from node, but I want to write into the placeholders of a word template without loosing other parts of the template. I did the same with VBScript (with microsoft word template) in the past. Now want to achieve the same using nodejs. Please share with me your ideas..thanks

Related

PDF form to HTML conversion in angular 2?

In my application I am uploading a PDF file after uploading, I should display the information present in PDF file to a HTML form we are using angular 2 for frontend and node js for backend. Can any one help me with this.
Please remember PDF to HTML.
You can do one thing. Convert your pdf to a JSON. Use pdf2json.
pdf2json is a node.js module that parses and converts PDF from binary to json format, it's built with pdf.js and extends it with
interactive form elements and text content parsing outside browser.
The goal is to enable server side PDF parsing with interactive form
elements when wrapped in web service, and also enable parsing local
PDF to json file when using as a command line utility.
perform npm install pdf2json
Create an empty JSON whose key values will be the main headings from the pdf like a customer, age etc. Its values are obtained from the uploaded pdf.
Using this JSON values fill your form, on saving the form using, node.js save it to your DB. Is this what you want?
Simply what you need is to render a PDF in your application.
You could use this library ng2-pdf-viewer
Almost all the basic functionalities are available as properties to this component. You could manipulate it to your requirement.

How to index binary file in ElasticSearch without using Base64

I'm using the NodeJS elasticsearch package to interact with ElasticSearch. I have a document that has a file field. I want to be able to upload a file to the index but the only way that I have found is by using the elasticsearch-mapper-attachment plugin.
The problem is that if I use it, I have to load the whole file in memory, encode it to Base64 and then pass the String to ElasticSearch.
I'd like to be able to pass a Stream to ElasticSearch (referencing any binary file: pdf, xls, doc, ppt).
The elasticsearch-mapper-attachment plugin parses the uploaded binary file and extracts text for further indexing using built-in Tika extractor.
What some applications do (for example Search Technology's Aspire) - they run binaries thru Tika locally, extract text and upload just that text with the documents to index.
It might not be the answer you are looking for but you really have just two options - use Elastic plugin (and convert the binary to base64 in yoru code prior to uploading the document to elastic), or parse the binary and extract text in your code and then upload just that text to elastic. Former is easier, latter gives you more control over the process

Creating tables within ckeditor from uploaded files

Would it be possible to create and populate tables within ckeditor from uploaded files?
A user would choose a file from their machine in any format such as word, excel etc and it could display a formatted table in the editor....
It is pretty clear that one can create a table in CKEditor. Also, it is possible to add a table automatically. Now, if you want to automatically add a table based upon the content of an uploaded file, then:
create a form where the file can be uploaded
implement the feature with which one can upload the file
make sure you know where your files are, either using a database or a deterministic algorithm
implement a server-side functionality which prepares the content (table) data
use the prepared data as input at client-side

How to split pages where it necessary when converting data to pdf using NodeJS

I have dynamic data and need to split pages somewhere. Now I'm using "html-pdf" module and don't know how to do it.

To upload an excel file as a clob

Could some one give an idea about how to convert an excel file into a CLOB in oracle through JDBC. I would like to know how to covert excel file into a String using API available as part of JDK and the conversion from string to clob should be straight forward. Thanks in advance. If a similar question was already raised, kindly provide me the link.
You will need a library out side of the standard java api to read a binary excel document.
You could use the JExcelApi to read in the Excel document then create a CSV String as you read in the document.
If you don't want to use an outside library then I would change the field type to blob and use the setBlob method of java.sql.PreparedStatment passing it a FileInputStream.
When you need to parse the data (read the contents) you can use a library like Apache POI
If you want to use the only standard API, then save the excel as CSV file and process the file as a comma seperated value list. That can easily be done with readline to read each line and split that line to values using the split method on a String.
If you do not need to parse data you should stream the data directly from file to a CLOB and not first transform the excel to a String
An example can be found here: http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
What is the representation of a spreadsheet in text format? The values indented by tabs? The formulas? What if you have more than one page in the xls file?
If what you really whant to do is to store the file in the database use a BLOB and store it as bytes.

Resources