How do I flatten/compress a pdf which is generated with prawn? - ruby

I am using prawn to generate pdf files which have lots of images so they come out quite large. I can open the file in Adobe Acrobat and then save it using the "reduce file size" option, and a 164MB file shrunk to 7MB and retained all of the image quality. I would like to replicate this compression in Ruby. I have tried using the compression settings which prawn offers and they have not had any effect on the file size. I suspect there must be a way to do it with RMagick, but I haven't figured it out yet.
I apologize for not including any code samples showing what I have tried, but I removed the prawn compression settings when they didn't have any effect, so I don't have anything to show.

Have you tried simply making a copy of the PDF with RMagick? That is, read in the PDF and write it back out again.
Also, check with the ImageMagick folks at https://www.imagemagick.org/discourse-server/. Any advice they offer you can be implemented via RMagick.

Related

Extract images from .swf viewer?

I'm wondering how it possible to extract images from .swf viewer?
Note that .swf file have not images itself.
For example I'm trying extract images from AVON catalogue from this link - http://avon.com.ua/PRSuite/eBrochure.page?index=1&cmpgnYrNr=201404&pageNo=0
Any ideas?
Best way is to put the .swf file in a decompiler for image extraction. Decompilers are smart enough to extract images for you and arrange them.
JPEXS Free Flash Decompiler is a more popular one
http://www.free-decompiler.com/flash/
You can extract other useful content from it as well.
Just download the .swf file from the website
A while back (like around 1999) I wrote a set of tools for Flash animations.
One of the tools is swf_dump which can be used to extract objects (i.e. write the objects in a form of script that sswf can nearly recompile...)
The tool also allows for extracting images that are inline (not downloaded dynamically by the flash animation, if so, anyway, you could as well download those images manually, you'd need the URL, though.)
The command line you can use is:
swf_dump -d my-animation.swf
Then your current folder will be littered with all the images that were found in the flash file. It extracts JPEGs and PNGs. The source can be compressed (SWF or CWF are supported.)
Now, you're on your own to compile that thing... The project is here and is in great need of updating (but Flash is kind of going out too...)
https://sourceforge.net/projects/sswf/

Why pdftk produced pdf files will not render in Firefox?

I have a site - www.jcrocetta.com.
On this site I have 2 pdf files. One file has blurred data and the other is clear, both files were created with pdftk.
In order to blur out some personal data in the pdf I used Inkscape. But Inkscape only opens/edits one PDF page at a time. After I made my edits in Inkscape I saved the files as .pdf formatted files. At that point I had three separate pdf files, pages 1 through 3. I then used pdftk to concatenate the 3 files into one.
The final pdftk-produced files are on www.jcrocetta.com. Just click the public information button.
In Chrome viewing inline works fine.
Downloading the file from Firefox works fine too.
But viewing inline on Firefox it renders blank pages. How can I fix this?
Also, I know that pdf files not produced with pdftk will render correctly on both Chrome and Firefox.
Thanks for your help.
FireFox has a lovely new feature: It now uses the PDF.js library to render PDF files, instead of calling out to an Adobe Reader plugin, or forcing you to save the file to disk. Unfortunately, it seem that PDF.js isn't quite perfect yet. A quick search shows that other people have the same issue, but the only "solution" I've seen offered boils down to "file a bug report at https://github.com/mozilla/pdf.js/issues or https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox&component=PDF+Viewer".
Also: Do the three individual PDF files render in FireFox, before you use pdftk to concatenate them?

Apple's PDFKit (or anything else), extract positions of images

I need to extract the positions of all images from a pdf-file on the Mac. For now I am considering PDFKit, but that if there is a better way of doing that, i'm open to suggestions.
So the question is, how can i parse a PDF file on the Mac, receiving (images, not necessarily), their positions within a page and page numbers using PDFKit or, probably, another library or even a program (I don't have to build it into my program, i just need it done).
UPD Seems like it is possible to do that using Adobe's Acrobat SDK.
Thanks in advance,
Timofey.

Wordpress Theme (JVPress) Header Graphic Won't Display in Internet Explorer 8

I have a Wordpress site (www.nurseresumetips.com) and I'm using a theme named JVPress.
This theme lets you to upload a custom header graphic. If you open the page in Firefox the header graphic displays, however when I open it in Internet Explorer 8 the image is not found.
The link that Wordpress is generating is: http://www.nurseresumetips.com/wp-content/uploads/20110419033853_nrt.jpg
This link works in Firefox but not in Internet Explorer.
I just want to know if anyone could point me in the right direction.
Thanks
Having looked around, I think you may be tripping over a problem like this, where your JPEG is encoded in a slightly odd format. Looks like CMYK is accepted as a format by some browsers, but not others.
Depending on your software, you might be able to find a way of saving in a more usual colour encoding -- in Photoshop, for example, try the specific "save for web" option.
Given the content of your image, I'd actually suggest saving the file as a PNG, anyway. JPEG is best for photographic images; for textual images like this one, PNG will probably (a) be more efficient, (b) look better -- no encoding artefacts around the nice solid lines you have, and (c) not have this odd problem you're facing.

How to render uploaded photos with NodeJS and Express?

I generally post examples of my best shot at what I'm asking about, but in this case, I have no idea where to start (haven't uploaded photos before in other languages).
So how does one go about rendering uploaded photos. I'm using Node v0.4.2, Express 1.0.8, and Mongoose 1.0.16 and have uploading of images working (they end up in ~/tmp right now).
Thanks.
If you just want to render thumbnail versions of your uploaded images for display, try using the imagemagick wrapper node-imagemagick.
For example, you could store your hires-images in a data-folder on your server (lets say /data/images) and render thumbnail images into a web-accessible folder (on upload).
I do not recommend generating the thumbnails on the fly, as it can massively increase your server's load when a large image (especially vector formats like eps or pdf) is being rendered.
For imagemagick examples, consider reading up the docs for the convert command.

Resources