PDFREP

 view release on metacpan or  search on metacpan

PDFREP.pm  view on Meta::CPAN

                    $pdlgth = $pdlgth + length($pdprintline[$lcnt]) + 2;
                    $lcnt++;
                }
            }
        }
        $tmpcnt++;	
    }
    # Include image definitions go here after pages and before fonts

    foreach $item (@image_name)
    {
        my ($pt1, $pt2, $pt3, $pt4, $pt5, $i_path) = split(/:::/, $item);

        undef @pdprintline;
        $lcnt        = '0';
        $objcount++;
        $tmpoffs = $objcount;

        while (length($tmpoffs) < 4)
        {
            $tmpoffs = "0" . $tmpoffs;
        }
        #(length($objcount) < 2) ? ($tmpoffs = '0' . $objcount) : ($tmpoffs = $objcount);
        $pdoffs{$tmpoffs}   = $offset;

        $pdprintline[$lcnt] = "$objcount 0 obj";
        $lcnt++;
        $pdprintline[$lcnt] = "<<";
        $lcnt++;
        $pdprintline[$lcnt] = "/Type /XObject";
        $lcnt++;
        $pdprintline[$lcnt] = "/Subtype /Image";
        $lcnt++;
        $pdprintline[$lcnt] = "/Name /$pt1";
        $lcnt++;
        $pdprintline[$lcnt] = "/Width $pt4";
        $lcnt++;
        $pdprintline[$lcnt] = "/Height $pt3";
        $lcnt++;

        my $iname = "$i_path". "$pt2";
        my $myImage;
        my $imout;
        my $imlgth = 0;

        open (INIMAGE, "< $iname");

        $pdprintline[$lcnt] = "/BitsPerComponent 8";
        $lcnt++;
        $pdprintline[$lcnt] = "/ColorSpace /DeviceRGB";
        $lcnt++;
        $pdprintline[$lcnt] = "/Filter /DCTDecode";
        $lcnt++;

        if ($pt5 eq 'jpg')
        {
            $myImage = newFromJpeg GD::Image(\*INIMAGE) || die;
        }
        elsif ($pt5 eq 'png')
        {
            $myImage = newFromPng GD::Image(\*INIMAGE) || die;
        }
        $imout = $myImage->jpeg(600);
        $imlgth = length($imout);

        close (INIMAGE);

        $pdprintline[$lcnt] = "/Length $imlgth";
        $lcnt++;
        $pdprintline[$lcnt] = ">>";
        $lcnt++;
        $pdprintline[$lcnt] = "stream";
        $lcnt++;
        $pdprintline[$lcnt] = "$imout";
        $lcnt++;
        $pdprintline[$lcnt] = "endstream";
        $lcnt++;
        $pdprintline[$lcnt] = "endobj";
        $lcnt++;

        foreach $item (@pdprintline)
        {
            $rc = print PDFFILE "$item\015\012";

            $offset = $offset + length($item) + 2;

            if (!$rc)
            {
                return ('0', 'PDFREP Write PDF File Failure - Font $objcount Object');
            }
        }
    }
    # set the procset area

    undef @pdprintline;
    $lcnt        = '0';
    $objcount++;

    $tmpoffs = $objcount;

    while (length($tmpoffs) < 4)
    {
        $tmpoffs = "0" . $tmpoffs;
    }
    #(length($objcount) < 2) ? ($tmpoffs = '0' . $objcount) : ($tmpoffs = $objcount);
    $pdoffs{$tmpoffs}   = $offset;

    $pdprintline[$lcnt] = "$objcount 0 obj";
    $lcnt++;
    $pdprintline[$lcnt] = "[/PDF]";
    $lcnt++;
    $pdprintline[$lcnt] = "endobj";
    $lcnt++;

    foreach $item (@pdprintline)
    {
        $rc = print PDFFILE "$item\015\012";

        $offset = $offset + length($item) + 2;

        if (!$rc)



( run in 1.799 second using v1.01-cache-2.11-cpan-df04353d9ac )