Hi, I've got a rather unusual problem trying to: 1. Generate GIF image file. 2. Include this GIF file into PDF. If the GIF file size is more than a certain number of bytes - the image looks cut off in PDF (it looks OK if viewed separately). No such problem exists for PNG files, but unfortunately I have to use GIFs. Here is graph generation code:
use GD; use GD::Graph::Data; use GD::Graph::bars; my $data = GD::Graph::Data->new( [["2001", "2002", "2003", "2004", "2005", "2006", "2007", "2 +008", "2009", "2010"], [ 10.2, 7.5, 4.8, 5.5, 5.5, 5.3, 4.6, 5.3, 5.7, 3.6], [ 9.8, 8.4, 4.4, 5.2, 5.3, 5.2, 4.9, 6.1, 6.3, 3.8]]); my $graph = new GD::Graph::bars( 1200, 800 ); $graph->set( title => 'Test Graph', types => [qw(bars bars)], transparent => 0, bar_spacing => 0, bargroup_spacing => 20, show_values => 1, x_labels_vertical => 1, interlaced => 0, ); my $gd = $graph->plot( $data ); open (MYFILE, '>test.gif'); binmode MYFILE; print MYFILE $gd->gif(); close (MYFILE);
following by the PDF generation:
use strict; use warnings; use PDF::API2; my $pdf = PDF::API2->new( -file => "sample.pdf" ); my $page = $pdf->page; $page->mediabox(792,612); my $photo = $page->gfx; my $photo_file = $pdf->image_gif('test.gif'); $photo->image( $photo_file, 100,100,600,400); $pdf->save; $pdf->end();
Could you please help me to figure it out? By the way, the problem is consistent whether I use Perl under Windows or under Solaris. Thanks in advance.

In reply to Including GIF image into PDF (using GD::Graph and PDF::API2 libraries) by asulkin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.