Skip to content

Commit

Permalink
Switch from pdftk to pdfinfo
Browse files Browse the repository at this point in the history
pdftk is no longer packaged for Alpine Linux and has an odd license.
pdfinfo is part of poppler which is licensed under GPL.
  • Loading branch information
kylemhall committed May 1, 2023
1 parent 8b2accb commit db7ba90
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ RUN install_packages \
libcups2-dev \
libcupsfilters-dev \
# Needed to count pages in encrypted PDFs
pdftk \
poppler-utils \
# Print uploads filetype detection
shared-mime-info

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ RUN apk add --no-cache \
imagemagick \
imagemagick-perlmagick \
mysql-client \
pdftk \
perl-app-cpanminus \
perl-dbd-mysql \
perl-dev \
Expand All @@ -47,6 +46,7 @@ RUN apk add --no-cache \
perl-params-validate \
perl-posix-strftime-compiler \
perl-yaml-xs \
poppler-utils \
sed \
shared-mime-info \
wget
Expand Down
7 changes: 3 additions & 4 deletions lib/Libki/Utils/Printing.pm
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ sub create_print_job_and_file {
my $pdf = PDF::API2->open_scalar($pdf_string);
$pages = $pdf->pages();
}
catch { # PDF may be encrypted, try using pdftk instead
catch { # PDF may be encrypted, try using pdfinfo instead
my ( $fh, $fn ) = tempfile();
write_file( $fn, $pdf_string );
my $output = qx{ pdftk $fn dump_data | grep NumberOfPages };
$output =~ m/NumberOfPages: (\d+)/;
$pages = $1;
my $pages = qx{ pdfinfo $fn | awk '/^Pages:/ {print \$2}' };
chomp $pages;
};

my $printers = $c->get_printer_configuration;
Expand Down

0 comments on commit db7ba90

Please sign in to comment.