builds, links and mostly runs
This commit is contained in:
parent
56fe608cfb
commit
05456125b6
@ -202,6 +202,13 @@ via imagemagick instead.
|
||||
The usual SVG loader. If this is not present, vips will try to load SVGs
|
||||
via imagemagick instead.
|
||||
|
||||
### PDFium
|
||||
|
||||
If present, libvips will attempt to load PDFs via PDFium. This library must be
|
||||
packaged by https://github.com/jcupitt/build-pdfium
|
||||
|
||||
If PDFium is not detected, libvips will look for poppler-glib instead.
|
||||
|
||||
### libpoppler
|
||||
|
||||
The usual PDF loader. If this is not present, vips will try to load PDFs
|
||||
|
@ -1169,14 +1169,14 @@ fi
|
||||
# Gather all up for VIPS_CFLAGS, VIPS_INCLUDES, VIPS_LIBS
|
||||
# sort includes to get longer, more specific dirs first
|
||||
# helps, for example, selecting graphicsmagick over imagemagick
|
||||
VIPS_CFLAGS=`for i in $VIPS_CFLAGS $GTHREAD_CFLAGS $REQUIRED_CFLAGS $EXPAT_CFLAGS $ZLIB_CFLAGS $PANGOFT2_CFLAGS $GSF_CFLAGS $FFTW_CFLAGS $MAGICK_CFLAGS $PNG_CFLAGS $EXIF_CFLAGS $MATIO_CFLAGS $CFITSIO_CFLAGS $LIBWEBP_CFLAGS $LIBWEBPMUX_CFLAGS $GIFLIB_INCLUDES $RSVG_CFLAGS $POPPLER_CFLAGS $OPENEXR_CFLAGS $OPENSLIDE_CFLAGS $ORC_CFLAGS $TIFF_CFLAGS $LCMS_CFLAGS
|
||||
VIPS_CFLAGS=`for i in $VIPS_CFLAGS $GTHREAD_CFLAGS $REQUIRED_CFLAGS $EXPAT_CFLAGS $ZLIB_CFLAGS $PANGOFT2_CFLAGS $GSF_CFLAGS $FFTW_CFLAGS $MAGICK_CFLAGS $PNG_CFLAGS $EXIF_CFLAGS $MATIO_CFLAGS $CFITSIO_CFLAGS $LIBWEBP_CFLAGS $LIBWEBPMUX_CFLAGS $GIFLIB_INCLUDES $RSVG_CFLAGS $PDFIUM_INCLUDES $POPPLER_CFLAGS $OPENEXR_CFLAGS $OPENSLIDE_CFLAGS $ORC_CFLAGS $TIFF_CFLAGS $LCMS_CFLAGS
|
||||
do
|
||||
echo $i
|
||||
done | sort -ru`
|
||||
VIPS_CFLAGS=`echo $VIPS_CFLAGS`
|
||||
VIPS_CFLAGS="$VIPS_DEBUG_FLAGS $VIPS_CFLAGS"
|
||||
VIPS_INCLUDES="$ZLIB_INCLUDES $PNG_INCLUDES $TIFF_INCLUDES $JPEG_INCLUDES"
|
||||
VIPS_LIBS="$ZLIB_LIBS $MAGICK_LIBS $PNG_LIBS $TIFF_LIBS $JPEG_LIBS $GTHREAD_LIBS $REQUIRED_LIBS $EXPAT_LIBS $PANGOFT2_LIBS $GSF_LIBS $FFTW_LIBS $ORC_LIBS $LCMS_LIBS $GIFLIB_LIBS $RSVG_LIBS $POPPLER_LIBS $OPENEXR_LIBS $OPENSLIDE_LIBS $CFITSIO_LIBS $LIBWEBP_LIBS $LIBWEBPMUX_LIBS $MATIO_LIBS $EXIF_LIBS -lm"
|
||||
VIPS_LIBS="$ZLIB_LIBS $MAGICK_LIBS $PNG_LIBS $TIFF_LIBS $JPEG_LIBS $GTHREAD_LIBS $REQUIRED_LIBS $EXPAT_LIBS $PANGOFT2_LIBS $GSF_LIBS $FFTW_LIBS $ORC_LIBS $LCMS_LIBS $GIFLIB_LIBS $RSVG_LIBS $PDFIUM_LIBS $POPPLER_LIBS $OPENEXR_LIBS $OPENSLIDE_LIBS $CFITSIO_LIBS $LIBWEBP_LIBS $LIBWEBPMUX_LIBS $MATIO_LIBS $EXIF_LIBS -lm"
|
||||
|
||||
AC_SUBST(VIPS_LIBDIR)
|
||||
|
||||
|
@ -6,6 +6,7 @@ libforeign_la_SOURCES = \
|
||||
gifload.c \
|
||||
cairo.c \
|
||||
pdfload.c \
|
||||
pdfload_pdfium.c \
|
||||
svgload.c \
|
||||
radiance.c \
|
||||
radload.c \
|
||||
|
@ -31,6 +31,20 @@
|
||||
|
||||
*/
|
||||
|
||||
/* TODO
|
||||
*
|
||||
* - more code sharing with pdfload.c, eg. vips_foreign_load_pdf_is_a_buffer()
|
||||
* and get_flags etc.
|
||||
* - could share the page layout code too
|
||||
* - make pdf.c with base stuff in?
|
||||
* - FPDF_GetMetaText() results needs mapping from utf16 to utf8
|
||||
* - what about filename encodings
|
||||
* - do we need to clear the background to white in generate()?
|
||||
* - I guess we must write RGBA to match poppler output
|
||||
* - new_from_buffer stuff
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
#define DEBUG
|
||||
*/
|
||||
@ -45,6 +59,10 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
/* Just until we get rid of the final bits of poppler
|
||||
*/
|
||||
#include <cairo.h>
|
||||
|
||||
#include <vips/vips.h>
|
||||
#include <vips/buf.h>
|
||||
#include <vips/internal.h>
|
||||
@ -52,6 +70,7 @@
|
||||
#ifdef HAVE_PDFIUM
|
||||
|
||||
#include <fpdfview.h>
|
||||
#include <fpdf_doc.h>
|
||||
|
||||
typedef struct _VipsForeignLoadPdf {
|
||||
VipsForeignLoad parent_object;
|
||||
@ -93,27 +112,6 @@ typedef VipsForeignLoadClass VipsForeignLoadPdfClass;
|
||||
G_DEFINE_ABSTRACT_TYPE( VipsForeignLoadPdf, vips_foreign_load_pdf,
|
||||
VIPS_TYPE_FOREIGN_LOAD );
|
||||
|
||||
static void *
|
||||
vips_pdfium_init_cb( void *dummy )
|
||||
{
|
||||
FPDF_LIBRARY_CONFIG config;
|
||||
|
||||
config.version = 2;
|
||||
config.m_pUserFontPaths = NULL;
|
||||
config.m_pIsolate = NULL;
|
||||
config.m_v8EmbedderSlot = 0;
|
||||
|
||||
FPDF_InitLibraryWithConfig( &config );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_pdfium_init( void *dummy )
|
||||
{
|
||||
static GOnce once = G_ONCE_INIT;
|
||||
|
||||
VIPS_ONCE( &once, vips_pdfium_init_cb, NULL );
|
||||
}
|
||||
|
||||
static char *vips_pdfium_errors[] = {
|
||||
"no error",
|
||||
"unknown error",
|
||||
@ -123,7 +121,6 @@ static char *vips_pdfium_errors[] = {
|
||||
"unsupported security scheme",
|
||||
"page not found or content error"
|
||||
};
|
||||
static int vips_pdfium_n_errors = VIPS_NUMBER( vips_pdfium_errors );
|
||||
|
||||
static void
|
||||
vips_pdfium_error( void )
|
||||
@ -145,8 +142,30 @@ vips_foreign_load_pdf_dispose( GObject *gobject )
|
||||
VIPS_FREEF( FPDF_CloseDocument, pdf->doc );
|
||||
VIPS_FREEF( FPDF_ClosePage, pdf->page );
|
||||
|
||||
G_OBJECT_CLASS( vips_foreign_load_pdf_parent_class )->
|
||||
dispose( gobject );
|
||||
G_OBJECT_CLASS( vips_foreign_load_pdf_parent_class )->dispose( gobject );
|
||||
}
|
||||
|
||||
static void *
|
||||
vips_pdfium_init_cb( void *dummy )
|
||||
{
|
||||
FPDF_LIBRARY_CONFIG config;
|
||||
|
||||
config.version = 2;
|
||||
config.m_pUserFontPaths = NULL;
|
||||
config.m_pIsolate = NULL;
|
||||
config.m_v8EmbedderSlot = 0;
|
||||
|
||||
FPDF_InitLibraryWithConfig( &config );
|
||||
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
static void
|
||||
vips_pdfium_init( void )
|
||||
{
|
||||
static GOnce once = G_ONCE_INIT;
|
||||
|
||||
VIPS_ONCE( &once, vips_pdfium_init_cb, NULL );
|
||||
}
|
||||
|
||||
static int
|
||||
@ -154,6 +173,8 @@ vips_foreign_load_pdf_build( VipsObject *object )
|
||||
{
|
||||
VipsForeignLoadPdf *pdf = (VipsForeignLoadPdf *) object;
|
||||
|
||||
vips_pdfium_init();
|
||||
|
||||
if( !vips_object_argument_isset( object, "scale" ) )
|
||||
pdf->scale = pdf->dpi / 72.0;
|
||||
|
||||
@ -328,17 +349,14 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
||||
pdf->image.width = 0;
|
||||
pdf->image.height = 0;
|
||||
for( i = 0; i < pdf->n; i++ ) {
|
||||
double width;
|
||||
double height;
|
||||
|
||||
if( vips_foreign_load_pdf_get_page( pdf, pdf->page_no + i ) )
|
||||
return( -1 );
|
||||
pdf->pages[i].left = 0;
|
||||
pdf->pages[i].top = top;
|
||||
pdf->pages[i].width = FPDF_GetPageWidth( pdf->page ) *
|
||||
pdf->scale;
|
||||
pdf->pages[i].height = FPDF_GetPageHeight( pdf->page ) *
|
||||
pdf->scale;
|
||||
pdf->pages[i].width =
|
||||
FPDF_GetPageWidth( pdf->page ) * pdf->scale;
|
||||
pdf->pages[i].height =
|
||||
FPDF_GetPageHeight( pdf->page ) * pdf->scale;
|
||||
|
||||
if( pdf->pages[i].width > pdf->image.width )
|
||||
pdf->image.width = pdf->pages[i].width;
|
||||
@ -381,7 +399,7 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
|
||||
*/
|
||||
|
||||
/* Poppler won't always paint the background. Use 255 (white) for the
|
||||
* bg, PDFs generally assume a paper backgrocund colour.
|
||||
* bg, PDFs generally assume a paper background colour.
|
||||
*/
|
||||
vips_region_paint( or, r, 255 );
|
||||
|
||||
@ -419,7 +437,7 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
|
||||
*/
|
||||
if( vips_foreign_load_pdf_get_page( pdf, pdf->page_no + i ) )
|
||||
return( -1 );
|
||||
poppler_page_render( pdf->page, cr );
|
||||
//poppler_page_render( pdf->page, cr );
|
||||
|
||||
cairo_destroy( cr );
|
||||
|
||||
@ -566,6 +584,7 @@ vips_foreign_load_pdf_file_header( VipsForeignLoad *load )
|
||||
VipsForeignLoadPdfFile *file = (VipsForeignLoadPdfFile *) load;
|
||||
|
||||
char *path;
|
||||
GError *error = NULL;
|
||||
|
||||
/* We need an absolute path for a URI.
|
||||
*/
|
||||
@ -645,11 +664,11 @@ G_DEFINE_TYPE( VipsForeignLoadPdfBuffer, vips_foreign_load_pdf_buffer,
|
||||
static int
|
||||
vips_foreign_load_pdf_buffer_header( VipsForeignLoad *load )
|
||||
{
|
||||
/*
|
||||
VipsForeignLoadPdf *pdf = (VipsForeignLoadPdf *) load;
|
||||
VipsForeignLoadPdfBuffer *buffer =
|
||||
(VipsForeignLoadPdfBuffer *) load;
|
||||
|
||||
/*
|
||||
if( !(pdf->doc = poppler_document_new_from_data(
|
||||
buffer->buf->data, buffer->buf->length, NULL, &error )) ) {
|
||||
vips_g_error( &error );
|
||||
|
41
m4/pdfium.m4
41
m4/pdfium.m4
@ -6,7 +6,7 @@ dnl
|
||||
dnl Find pdfium libraries and headers
|
||||
dnl
|
||||
dnl Put -I stuff in PDFIUM_INCLUDES
|
||||
dnl Put PDFium objects in PDFIUM_LIBS (add this to link line untouched!)
|
||||
dnl Put PDFium objects in PDFIUM_LIBS (add this to the link line untouched!)
|
||||
dnl Define HAVE_PDFIUM if found
|
||||
dnl
|
||||
AC_DEFUN([FIND_PDFIUM], [
|
||||
@ -15,6 +15,29 @@ AC_REQUIRE([AC_PATH_XTRA])
|
||||
ZLIB_INCLUDES=""
|
||||
ZLIB_LIBS=""
|
||||
|
||||
# PDFium has a set of object archives that must be linked firectly into your
|
||||
# app, and a couple of true libraries. The objects must be linked in this
|
||||
# order.
|
||||
pdfium_objects="\
|
||||
libpdfium.a \
|
||||
libfpdfapi.a \
|
||||
libfxge.a \
|
||||
libfpdfdoc.a \
|
||||
libfxcrt.a \
|
||||
libfx_agg.a \
|
||||
libfxcodec.a \
|
||||
libfx_lpng.a \
|
||||
libfx_libopenjpeg.a \
|
||||
libfx_lcms2.a \
|
||||
libfx_freetype.a \
|
||||
libjpeg.a \
|
||||
libfdrm.a \
|
||||
libpwl.a \
|
||||
libbigint.a \
|
||||
libformfiller.a \
|
||||
libjavascript.a \
|
||||
libfxedit.a"
|
||||
|
||||
AC_ARG_WITH(pdfium,
|
||||
AS_HELP_STRING([--without-pdfium], [build without pdfium (default: test)]))
|
||||
# Treat --without-pdfium like --without-pdfium-includes
|
||||
@ -52,13 +75,15 @@ if test "$PDFIUM_INCLUDES" = ""; then
|
||||
CPPFLAGS="$pdfium_save_CPPFLAGS"
|
||||
fi
|
||||
|
||||
# Now for the libraries ... if there's nothing set, try $PREFIX/lib and
|
||||
# $PREFIX/obj
|
||||
# Now for the libraries ... if there's nothing set, try $PREFIX/lib
|
||||
if test "$PDFIUM_LIBS" = ""; then
|
||||
pdfium_save_LIBS="$LIBS"
|
||||
pdfium_save_CPPFLAGS="$CPPFLAGS"
|
||||
|
||||
LIBS="$prefix/lib/pdfium-obj/*.a $LIBS"
|
||||
LIBS=""
|
||||
for i in $pdfium_objects; do
|
||||
LIBS="$LIBS $prefix/lib/pdfium-obj/$i"
|
||||
done
|
||||
LIBS="$LIBS -L$prefix/lib -lc++ -licuuc -lm -lpthread"
|
||||
CPPFLAGS="$PDFIUM_INCLUDES $CPPFLAGS"
|
||||
|
||||
@ -96,9 +121,11 @@ AC_MSG_RESULT([libraries $pdfium_libraries_result, headers $pdfium_includes_resu
|
||||
|
||||
if test x"$PDFIUM_LIBS" != x"no"; then
|
||||
dir="$PDFIUM_LIBS"
|
||||
PDFIUM_LIBS="$prefix/lib/pdfium-obj/*.a"
|
||||
# needs -lm -lpthread too, but they will be added by other packages
|
||||
PDFIUM_LIBS="$PDFIUM_LIBS -L$dir/lib -lc++ -licuuc"
|
||||
PDFIUM_LIBS=""
|
||||
for i in $pdfium_objects; do
|
||||
PDFIUM_LIBS="$PDFIUM_LIBS $prefix/lib/pdfium-obj/$i"
|
||||
done
|
||||
PDFIUM_LIBS="$PDFIUM_LIBS -L$dir -lc++ -licuuc -lm -lpthread"
|
||||
fi
|
||||
|
||||
AC_SUBST(PDFIUM_LIBS)
|
||||
|
Loading…
Reference in New Issue
Block a user