NodeJs construct Excel file and export in PDF - node.js

As the title said, I'm searching for a NodeJS library to construct Excel (xlsx), with cell format (color, font size, images...). Importantly, it must has the capability of exporting the resulted .xlsx file to .pdf format.
I know some libs that call Excel API but I'm running a linux server and that's impossible for me.

Thanks to jcaron comment I finally found out that I can build a PDF file directly without passing through xls.
I used pdfmaker for nodejs that support creating PDF file pretty well.

Related

How to redact texts in a pdf file in NodeJs

I am struggling to apply text redaction in a PDF file in a aws lambda function written in NodeJs. Here is a list of libraries that I have tried with no success:
pdf-lib: This library almost fulfils all the requirements except that it doesn't redact the text permanently as part of its limitations https://github.com/Hopding/pdf-lib/issues/827
PDF.js: To overcome the above limitation, tried to covert the pdf to an image, so the redaction black boxes are applied permanently. Example code here: https://github.com/mozilla/pdf.js/blob/master/examples/node/pdf2png/pdf2png.js However, this lib is not reliable as this cannot extract contents from most pdfs during the process.
Finally, Pdf2Pic: This library helps to overcome the limitation of the first library (pdf-lib) by the converting the pdf into images. But this library internally uses two non node based libraries (graphicsmagick and ghostscript) which I am trying to avoid.
Is there a nodejs based solution that can be used to apply redaction permanently on a pdf file or any solution that can be used to covert a pdf to images to overcome limitation of pdf-lib.

Excel file (.xlsx) to PDF Conversion using microsoft graph api is ignoring page setup instructions

I already have excel file in .xlsx format.I am trying to convert to pdf using microsoft graph api (by uploading the file to one drive and then downloading it as pdf). I am using the following API call
https://graph.microsoft.com/v1.0/me/drive/items/[item-id]/content?format=pdf
I see that the pdf conversion process in above API doesn't consider all the page setup parameters that are set in the underlying .xlsx file. More specifically, I see that converted pdf is always rendered in landscape mode and seems to be ignoring fit to width/height/page settings. If I open the same excel file locally using Excel and save the document as pdf, it renders the document correctly by interpreting all the page setup parameters properly.
Any help would be greatly appreciated as to how I can get pdf conversion API to render pdf as per orientation(portrait/landscape) and page width/height settings on the .xlsx file
I have tried multiple smaller files with different page setup parameters but pdf conversion (using rest api) always returns the document in landscape mode and seems to be ignoring fit to page/width/height settings

Convert any document, image, text file into PDF

I want to convert any documents or image or text file into PDF for all the OS.
I tried the approach with node-msoffice-pdf, and its working fine for Windows OS but not working in other OS.
Question:
How to convert docs, images, textfile to pdf in nodejs?
I used wkhtmltopdf from years to manage pdf conversion.
https://github.com/devongovett/node-wkhtmltopdf
You can either render an html file and pass it to the module, or render a pdf directly from an url.
If fidelity/conversion quality is important to you, for Word documents (doc/docx) you could try our freemium https://www.npmjs.com/package/#nativedocuments/docx-wasm which will perform the conversion locally (ie where node is running), without the need to LibreOffice etc.

Opening xlsx file created with SpreadSheetGear

I have created a simple Excel file using SpreadSheetGear. If I save it as an xls file
workbook.SaveAs("file.xls", SpreadsheetGear.FileFormat.Excel8);
and attach it to an email, I can open it on my phone (tested both with iPhone and Android).
If I save it as an xlsx file
workbook.SaveAs("file.xlsx", SpreadsheetGear.FileFormat.OpenXMLWorkbook);
and attach it to an email, I CANNOT open it on my phone.
If I open the xlsx file attachment on my computer and save it with no changes and attach it to an email, I now can open it on my phone.
Apparently Excel saves the file differently than SSG. The file size of the xlsx file attachment is 9 KB. When I open it on my computer and save it, the new file size is 24 KB.
Some of my users prefer the xlsx format. Is there anything I can do with to make the SSG generated file attachment open like an Excel generated file attachement?
iOS depends on certain attributes being present in the worksheet data of the Open XML file format to properly parse these files. SpreadsheetGear does not write these attributes out because they are listed as optional in the Open XML file format specification and, also, omitting them reduces file size, as you have noted. Excel, for whatever reason, always writes out these optional attributes and other third-party components often times rely on their presence to function correctly. SpreadsheetGear V5 added a workaround to write out these attributes by enabling a certain "Experimental" option. This option was added because the OLE DB provider also exhibits this errant behavior. You might try something like the following and see if this helps in getting SpreadsheetGear to better work with your viewer:
IWorkbookSet workbookSet = Factory.GetWorkbookSet();
workbookSet.Experimental = "OleDbOpenXmlWorkaround";
IWorkbook workbook = workbookSet.Workbooks.Open(#"C:\temp\BadWorkbook.xlsx");
workbook.SaveAs(#"C:\temp\GoodWorkbook.xlsx", FileFormat.OpenXMLWorkbook);
Please see the SpreadsheetGear.IWorkbookSet.Experimental property for more information on this feature.
From what I can tell, iOS/Andriod/etc often also depend on other certain optional features available in the file formats that SpreadsheetGear either doesn't support or write out by default. For instance, iOS depends on a "data cache" stored within charts to display chart series data points and SpreadsheetGear's support for writing out this data cache is limited. This can result in charts not displaying as expected in iOS, Android, etc.

Which content type when uploading *.xlsx files vie gd sdk?

I'm trying to upload a Excel spreadsheet (*.xlsx) to my google drive account via google drive sdk (ruby). I'm using a top level function which does a put request and I'm not sure, which content_type I have to provide. I'm currently using 'application/vnd.ms-excel', which is the known content type for excel files. The response looks like this:
Response code 400 for put https://docs.google.com/feeds/upload/create-session/default/private/full?v=3&convert=true&upload_id=AEnB2Upn7o44iQmyG3PCM86jrGKW4dK4AngPYsTTv5lsi8l3noa7sOkq1KZjZ0axAX-AF4SOAb6xf3JQbvOVNziapflya5lu3g: http://schemas.google.com/g/2005'>GDataInvalidEntryExceptionThe conversion cannot be performed since we do not recognise the file types involved or there is no pathway between them. (GoogleDrive::Error)
It states that they do not know how to convert *.xlsx files to google spreadsheets. But when I can import excel files in spreadsheets via the ui on google.com. Any suggestions?
best regards
Valid mimetype for xlsx file is application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Also if you want to convert that file into Google Spreadsheet format you have to use the convert flag and set it to true.

Resources