I have seen other solutions for other languages (Object C/Swift/ Java) and was wondering if there was an established method/package to reduce the size of PDF's using Node. Currently I use PDFKIT to generate PDFs in my backend but I need their file sizes to be about half (currently 1mb -> 500kb) or smaller ideally. I have looked through NPM and several forums but have not found a way to compress PDFs with javascript. I notice that countless Online-PDF-Compression websites exist and they are able to compress my 1mb PDF to 55kb. So I'm sure there are solutions that exist for Javascript/Node
I faced a similar issue and after going through several forums, the solution I came up was to use shrinkpdf and to execute a shell command in node js I used shelljs library which has the following syntax,
const shell = require('shelljs')
shell.exec('./path_to_your_file')
All you have to do it execute the shell script given on the link.
Related
I'm currently coding a project in Java that will use external JavaScript files to read and analyze local files (and thus, also using Node.js for RequireJS). I usually use an application that allows me to package multiple jars (such as libraries) with the main project jar into a .exe for easy distribution, but I'm realizing that this will be significantly more difficult with the JavaScript involved.
Does anyone know how I could convert my .js files into one (or more) .jar files such that I'd be able to reference them in Java and include them in my .exe?
(I'm aware that this may not be possible, but I've seen enough things while researching this that make it seem like it might be possible that I figured it was worth asking)
I'm developing a simple node-webkit app which is similar to a product catalog. So I have lots of images, around 1500!!
Currently, I'm done with implementing and using Grunt(grunt-node-webkit-builder) for building .exe. After creating an exe file, I use IExpress to make nw.exe and helper DLLs all-in one place. Because some of users doesn't like when setup looks messy. So I have two steps:
Make a build with Grunt
After the Grunt build, use IExpress to make it one .exe
In both cases, all the images are located in the application(around ~250MB).
My problem starts when the users clicks on the application. The time of opening application is around 30-40 seconds! I need to figure out how to decrease time!(btw, in development, it is super fast)
I thought that may be if I get images from external path and caching them make the performance better. But I don't know or I have no idea how to get images from external path after using IExpress!! Maybe there are better solutions or workaround even images are located at internal path. Could you suggest me how to solve this problem? Thanks in advance.
I had the same issue as you and i don't know if you're stuck on this or you found a solution, but searching through the NWJS google group i found this:
var path = require("path");
pathstr = path.dirname(process.execPath);
This returns the path where the NW bin is running. Just treat the string to fit your case and access the external files
I have a node web app that needs to convert a docx file into pdf (using client side resources only and no plugins). I've found a possible solution by converting my docx into HTML using docxjs and then HTML to PDF using jspdf (docx->HTML->PDF).
This solution could make it but I encountered several issues especially with rendering. I know that docxjs doesn't keep the same rendering in HTML as the docx file so it is a problem...
So my question is do you know any free module/solution that could directly do the job without going through HTML (I'm open to odt as a source as well)? If not, what would you advise me to do?
Thanks
As you already know there is no ready-to-use and open libs for this.. You just can't get good results with available variants. My suggesition is:
Use third party API. Like https://market.mashape.com/convertapi/word2pdf-1#!documentation
Create your own service for this purpose. If you have such ability, I suggest to create a small server on node.js (I bet you know how to do this). You can use Libreoffice as a good converter with good render quality like this:
libreoffice -headless -invisible -convert-to pdf {$file_name} -outdir /www-disk/
Don't forget that this is usually takes a lot of time, do not block the request-answer flow: use separate process for each convert operation.
And the last thing. Libreoffice is not very lightweight but it has good quality. You can also find notable unoconv tool.
As of January 2019, there is docx-wasm, which works in node and performs the conversion locally where node is installed. Proprietary but freemium.
It appears that even after three years ncohen had not found an answer. It was also unclear if it had to be a free (as in dollars) solution.
The original requirements were:
using client side resources only and no plugins
Do you mean you don't want server side conversion? Right, I would like my app to be totally autonomous.
Since all the other answers/comments only offered server side component solutions, which the author clearly stated was not what they wanted, here is a proposed answer.
The company I work for has had this solution for a few years now, that can convert DOCX (not odt yet) files to PDF completely in the browser, with no server side component required. This currently uses either asm.js/PNaCl/WASM depending on the exact browser being used.
https://www.pdftron.com/samples/web/samples/viewing/viewing/
Open an office file using the demo above, and you will see no server communication. Everything is done client side. This demo works on mobile browsers also.
I'm kind of a noob to this kind of thing. I'm interested in using MIDI.js (https://github.com/mudcube/MIDI.js/) to build a musical web app, not too different from the demos they have listed and downloadable.
My expectation of MIDI.js, which is not well documented, is that it would be a bunch of javascript code that I can use, sort of like jquery.
So I don't have an understanding of the role of a "build" folder, or node.js, or a gruntfile (barely know what that is).
My question is, what is their to build? There are several example html files (with js) included in the download that run right away on my local apache server, so what is left to be built?
Thanks
From the repo it looks like the build step simply concatenates the various source files into a single MIDI.js file as well as creating the minified version.
There is actually a topic asking a very similar thing, however the information there is either out of date (broken links, discontinued solutions) or not suitable for my needs.
I have a showcase for my graduation wherein we have the opportunity to display our work to potential employers. The interface we have to use only allows .jpg, .flv and .exe files, however my project is in HTML / CSS / JavaScript.
Is there any way I can convert my project into a .exe?
(The ways the pre-existing question's answers suggest creating an .exe are now broken links / discontinued as far as I can tell; and alternate answers suggest ways to create standalone applications which do not generate .exes, which are not fit for my purposes)
Cheers!
Most easiest way is:
1) Download Visual Studio Express Edition(Because it's free).
2) File -> New Project -> Windows Forms Application.
3) Load your current HTML into it.
4) Add WebBrowser control to your project.
5) Deploy your application(Build -> Publish).
Note:
The WebBrowser Control use IE by-default. Take a look at this alternative as well.
Welcome to 2019!
There's all kinds of different ways to accomplish this now. One popular npm package is npm pkg. There's also the popular Electron (this is what vscode was built on), and quite a few others
You Could always turn the HTML file into a HTA file and then convert it into an exe :)
https://www.vbsedit.com/
You can create a Windows app from HTML/JS.
Actually it's one of my pet projects:
Scriptonit
I've been using it for a while to create tools for myself, but just recently I decided to make it a proper freeware product. If you're not looking for something very complex and you don't need lots of frameworks & modules, this might be just what you're looking for.
You can download Scriptonit here.
You may try creating a .exe installer to you html file using Inno Setup.
You can use the setup wizard; just select the html file instead of exe when selecting the main exe file
It works somehow like an installed application, it will open in your browser but you can see in the List of Applications. (in control panel)