Canvas - using pdf files and printing
"Henry Merryweather" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <000001c54406$6e2e7c80$0300a8c0@eveshampc> |
Converting pdf files for use in a Canvas widget
Some time ago I asked about converting pdf files so that I can see them
in a Canvas widget. I thought that at least some may like to know that
this can be done using Image Magick. The following from Graphics
Programming with Perl by Martien Verbruggen is the basic code that does
it.
use strict "vars";
use Win32;
use Image::Magick;
my $rc;
my $img = Image::Magick->new();
# read the pdf file
$rc = $img->Read('WB1.pdf');
warn $rc if $rc;
$rc = $img->Write('WB1.jpg');
warn $rc if $rc;
There are issues about:
1. what happens when the pdf file has a number of pages;
2. the resolution of the resulting image
and the Image Magick site is useful in trying to sort these.
Also you must have Ghostsript other wise you get an error about a
'missing delegate'. I found that a Ghostsript download that gives
registry entries for AFPL worked but that another version did not.
Printing from a Canvas widget
I want the print the image in the canvas widget. I appreciate that you
can create a Postscript file of the image in the Canvas. However, can
you directly send the image to a printer connected to the PC you are
using? In the past I have resorted, for text, to sending this to
something like Notepad and using its printing facilities. However I
need to do it without an additional application if this is possible.
Best regards
Henry Merryweather