Comments (9)
It's highly dependent on which version of gs
you have installed. Newer versions do a much better job. And, of course, we may need to tweak the parameters to get more out of it.
One thing to keep in mind is that you should specify an IMAGE_DPI environment variable when calling the script. I keep changing the default, but it's best to be explicit. I found that IMAGE_DPI=150 gives good results (balancing size and quality).
...also, the optimize-pdf script needs to be rewritten in Ruby so it can get packaged in the Gem. We might want to use rghost instead of invoking gs
directly.
https://rubygems.org/gems/rghost
Feel free to play around with the script. I'm all ears for recommendations.
from asciidoctor-pdf.
Ghostscript is 9.06 (the latest one on Cygwin), which is about two years old. Setting IMAGE_DPI didn't affect the file size. I'm not a PDF-Ghostscript-DPI expert, so "playing around" with the settings in the script won't help much.
from asciidoctor-pdf.
That's probably the difference. I have Ghostscript 9.14. I remember when writing that script that major changes were made to image optimization around 9.10 and I did see a big difference when I upgraded.
I was able to compile Ghostscript at the time since a package wasn't available for my system back then. If that's possible for you, I encourage you to give it a try.
I looked for other solutions for optimizing PDF, but unfortunately nothing does the job quite like Ghostscript. Eventually, however, I am hoping that whatever logic is going on there can make its way into Prawn so that we can optimize when generating the PDF. Prawn has some optimization flags, but at the time they were corrupting my PDF.
from asciidoctor-pdf.
Btw, I had no idea what I was doing either when writing that script. But I learned through trial and error and this reference page:
http://ghostscript.com/doc/current/Ps2pdf.htm
from asciidoctor-pdf.
I tried the Windows version of 9.14 with the script. Now the resulting PDF is of the same size as the original one. At least the size doesn't double anymore. I guess I leave the PDF optimizations for now as they are.
from asciidoctor-pdf.
Actually, that's a good point...when to use optimize-pdf. The reason I was using it...the reason I created it...is because my original PDF was 20MB. In that case, I saw a major decrease in size. Below a certain size, you might end up with a larger PDF as you have observed. I'd say if the PDF is below 5MB, then just keep it as is. A good tip for the guide.
from asciidoctor-pdf.
The action here is that if the optimized file is not smaller than the original, don't overwrite the file. There's nothing I can do about Ghostscript not actually making the file smaller. There's no guarantee of that.
from asciidoctor-pdf.
There are two solutions to this problem. In the next release, you'll be able to activate the optimizer and control the quality using the optimize
attribute. For example, -a optimize=screen
may, in fact, decrease the size.
The other solution is to use hexapdf as documented in the README.
Beyond that, this is really outside the scope of what Asciidoctor PDF can do.
from asciidoctor-pdf.
I'm going to close as a duplicate since #535 will address this in part, and using hexapdf as an alternative has already been documented.
from asciidoctor-pdf.
Related Issues (20)
- Add select combining characters to bundled fonts HOT 1
- Decompose characters using NFD normalization when performing smallcaps transformation HOT 1
- Page numbers for index entries incorrect when toc macro is used in prepress book when page-numbering-start-at is after-toc
- toc start at value don't always behave as expected
- PDF theme default values not respected HOT 1
- Incorrect warning about missing character in fallback font when using inline image HOT 1
- Surrounding text in content key of running content is dropped if image macro is on its own line
- Embedding of "built-in" fonts HOT 2
- Deactivate header/footer in inserted blank pages in prepress mode HOT 2
- listing block font-size is a fixed value? HOT 1
- Customise a block according to its type HOT 1
- Ordered list starting from 0 HOT 2
- Source location not reported if description in horizontal dlist is truncated
- Upgrade prawn-svg to 0.34.x HOT 1
- Remove link from entry in TOC
- Support prawn-icon 3.1.x in v2.3.x branch HOT 1
- Lock ttfunk to 1.7.x in 2.3.x release line HOT 2
- Producer set to Author instead of producing software in document properties
- Document exceptions to the nobreak role and non-breaking characters HOT 6
- Add support for SVG to image referece in SVG encoded as a data URI (SVG data loader) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciidoctor-pdf.