Skip to content

Commit

Permalink
Automatically merge content streams during validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
deven committed Jun 23, 2022
1 parent 95ce840 commit 380da31
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/PDF/Data.pm
Original file line number Diff line number Diff line change
Expand Up @@ -551,16 +551,9 @@ sub validate_page {
my ($self, $path, $page) = @_;

if (my $contents = $page->{Contents}) {
if (is_array($contents)) {
for (my $i = 0; $i < @{$contents}; $i++) {
is_stream($contents->[$i]) or croak join(": ", $self->{-file} || (), "Error: $path\->{Contents}[$i] must be a stream!\n");
$self->validate_content_stream("$path\->{Contents}[$i]", $contents->[$i]);
}
} elsif (is_stream($contents)) {
$self->validate_content_stream("$path\->{Contents}", $contents);
} else {
croak join(": ", $self->{-file} || (), "Error: $path\->{Contents} must be an array or stream!\n");
}
$contents = $self->merge_content_streams($contents) if is_array($contents);
is_stream($contents) or croak join(": ", $self->{-file} || (), "Error: $path\->{Contents} must be an array or stream!\n");
$self->validate_content_stream("$path\->{Contents}", $contents);
}

# Validate resources, if any.
Expand Down Expand Up @@ -1460,7 +1453,7 @@ Dump an outline of the PDF internal structure for debugging.
=head2 merge_content_streams
$pdf->merge_content_streams($array_of_streams);
my $stream = $pdf->merge_content_streams($array_of_streams);
Merge multiple content streams into a single content stream.
Expand Down

0 comments on commit 380da31

Please sign in to comment.