add "password" option to pdfload

loads at least AES128-encrypted PDFs

pdfiumload needs a similar feature

see https://github.com/libvips/libvips/issues/2635
This commit is contained in:
John Cupitt 2022-01-28 13:25:46 +00:00
parent 0a7e96a4e2
commit cb78b1b9fb
2 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@
- configure fails for requested but unmet dependencies [remicollet]
- add support for another quantiser [DarthSim]
- jpeg2000 load left-justifies bitdepth
- add "password" option to pdfload
26/11/21 started 8.12.3
- better arg checking for hist_find_ndim [travisbell]

View File

@ -122,6 +122,10 @@ typedef struct _VipsForeignLoadPdf {
*/
VipsArrayDouble *background;
/* Decrypt with this.
*/
const char *password;
/* Poppler is not thread-safe, so we run inside a single-threaded
* cache. On the plus side, this means we only need one @page pointer,
* even though we change this during _generate().
@ -182,7 +186,7 @@ vips_foreign_load_pdf_build( VipsObject *object )
pdf->stream = vips_g_input_stream_new_from_source( pdf->source );
if( !(pdf->doc = poppler_document_new_from_stream( pdf->stream,
vips_source_length( pdf->source ), NULL, NULL, &error )) ) {
vips_source_length( pdf->source ), pdf->password, NULL, &error )) ) {
vips_g_error( &error );
return( -1 );
}
@ -556,6 +560,13 @@ vips_foreign_load_pdf_class_init( VipsForeignLoadPdfClass *class )
G_STRUCT_OFFSET( VipsForeignLoadPdf, background ),
VIPS_TYPE_ARRAY_DOUBLE );
VIPS_ARG_STRING( class, "password", 25,
_( "Password" ),
_( "Decrypt with this password" ),
VIPS_ARGUMENT_OPTIONAL_INPUT,
G_STRUCT_OFFSET( VipsForeignLoadPdf, password ),
NULL );
}
static void