Wednesday, January 19, 2011

PDF::Reuse and Wide characher in compress

If you have control characters in your $content string you should remove them by forcing the encoding utf-8 for the PDF::Reuse module.

use Encode;
use PDF::Reuse;
# remove the codec formating to avoid 
# "Wide character in compress at /usr/lib/perl5/site_perl/5.10/PDF/Reuse.pm line" 
$content = encode( "utf8", $content );