mmlenz has asked for the wisdom of the Perl Monks concerning the following question:

Have you guys ever seen an issue with a page import that has a black background? I looked closer at the pages in question and they are PNG images. The source document looks fine all by itself (chrome, evince). Splitting out the pdf into individual pages those documents look fine. If I try to import these specific pages into a new pdf resulting document shows those pages with a black background. We're trying to avoid rendering pages out to images or attempting to extract images from those pages. The source documents are PDF 1.4 and other pages from these documents work fine. I know this is pretty obscure but thought maybe someone had seen and resolved something like this in the past.
  • Comment on PDF::API2 page imports with black background

Replies are listed 'Best First'.
Re: PDF::API2 page imports with black background
by Corion (Patriarch) on Jul 29, 2019 at 14:35 UTC

    Most likely, the PNG images have alpha transparency and whatever imports (or displays) the PDF doesn't render the transparency. Or maybe that transparency channel gets lost while importing things.

    I would first look at removing the alpha channel before importing, maybe using Imager.

Re: PDF::API2 page imports with black background
by holli (Abbot) on Jul 29, 2019 at 16:32 UTC
    I wrote this script some time ago (merging pdf-files: pdf-merger.pl). No idea if it still works. If anything it might help you debugging.


    holli

    You can lead your users to water, but alas, you cannot drown them.
Re: PDF::API2 page imports with black background
by vr (Curate) on Jul 29, 2019 at 16:53 UTC

    You can begin with adding immediately after line 1353:

    my $g = $s_page->find_prop('Group'); $xo->{'Group'} = walk_obj({}, $s_pdf->{'pdf'}, $self->{'pdf'}, $g) if +$g;