Commit 989ceb6b authored by William Bader's avatar William Bader Committed by Adrian Johnson

Add support for Flate compression in Level 3 PostScript output.

The changes to the build variables are from Adrian Johnson's DeflateStream
patches at https://bugs.freedesktop.org/attachment.cgi?id=89776
parent 91c0be60
......@@ -38,7 +38,8 @@ option(ENABLE_CPP "Compile poppler cpp wrapper." ON)
set(ENABLE_LIBOPENJPEG "auto" CACHE STRING "Use libopenjpeg for JPX streams. Possible values: auto, openjpeg1, openjpeg2. 'auto' prefers openjpeg1 over openjpeg2 if both are available. Unset to not use openjpeg.")
set(ENABLE_CMS "auto" CACHE STRING "Use color management system. Possible values: auto, lcms1, lcms2. 'auto' prefers lcms2 over lcms1 if both are available. Unset to disable color management system.")
option(ENABLE_LIBCURL "Build libcurl based HTTP support." OFF)
option(ENABLE_ZLIB "Build with zlib (not totally safe)." OFF)
option(ENABLE_ZLIB "Build with zlib." ON)
option(ENABLE_ZLIB_UNCOMPRESS "Use zlib to uncompress flate streams (not totally safe)." OFF)
option(SPLASH_CMYK "Include support for CMYK rasterization." OFF)
option(USE_FIXEDPOINT "Use fixed point arithmetic in the Splash backend" OFF)
option(USE_FLOAT "Use single precision arithmetic in the Splash backend" OFF)
......@@ -158,6 +159,10 @@ if(ENABLE_ZLIB)
endif(ZLIB_FOUND)
set(ENABLE_ZLIB ${ZLIB_FOUND})
endif(ENABLE_ZLIB)
if(ENABLE_ZLIB_UNCOMPRESS AND NOT ENABLE_ZLIB)
message("Warning: ENABLE_ZLIB_UNCOMPRESS requires ENABLE_ZLIB")
set(ENABLE_ZLIB_UNCOMPRESS FALSE)
endif(ENABLE_ZLIB_UNCOMPRESS AND NOT ENABLE_ZLIB)
set(USE_OPENJPEG1 FALSE)
set(USE_OPENJPEG2 FALSE)
set(WITH_OPENJPEG FALSE)
......@@ -420,10 +425,15 @@ if(JPEG_FOUND)
endif(JPEG_FOUND)
if(ENABLE_ZLIB)
set(poppler_SRCS ${poppler_SRCS}
poppler/FlateStream.cc
poppler/FlateEncoder.cc
)
set(poppler_LIBS ${poppler_LIBS} ${ZLIB_LIBRARIES})
endif(ENABLE_ZLIB)
if(ENABLE_ZLIB_UNCOMPRESS)
set(poppler_SRCS ${poppler_SRCS}
poppler/FlateStream.cc
)
endif(ENABLE_ZLIB_UNCOMPRESS)
if(ENABLE_LIBCURL)
set(poppler_SRCS ${poppler_SRCS}
poppler/CurlCachedFile.cc
......@@ -716,7 +726,8 @@ show_end_message("use gtk-doc" "not supported with this CMake build system")
show_end_message_yesno("use libjpeg" ENABLE_LIBJPEG)
show_end_message_yesno("use libpng" ENABLE_LIBPNG)
show_end_message_yesno("use libtiff" ENABLE_LIBTIFF)
show_end_message_yesno("use zlib" ENABLE_ZLIB)
show_end_message_yesno("use zlib compress" ENABLE_ZLIB)
show_end_message_yesno("use zlib uncompress" ENABLE_ZLIB_UNCOMPRESS)
show_end_message_yesno("use curl" ENABLE_LIBCURL)
show_end_message_yesno("use libopenjpeg" WITH_OPENJPEG)
if(USE_OPENJPEG1)
......@@ -747,9 +758,9 @@ if(NOT ENABLE_LIBJPEG)
message("Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained.")
endif(NOT ENABLE_LIBJPEG)
if(ENABLE_ZLIB)
if(ENABLE_ZLIB_UNCOMPRESS)
message("Warning: Using zlib is not totally safe")
endif(ENABLE_ZLIB)
endif(ENABLE_ZLIB_UNCOMPRESS)
if(NOT WITH_OPENJPEG)
message("Warning: Using libopenjpeg is recommended. The internal JPX decoder is unmaintained.")
......
......@@ -18,9 +18,12 @@
/* Do not hardcode the library location */
#cmakedefine ENABLE_RELOCATABLE 1
/* Use zlib instead of builtin zlib decoder. */
/* Build against zlib. */
#cmakedefine ENABLE_ZLIB 1
/* Use zlib instead of builtin zlib decoder to uncompress flate streams. */
#cmakedefine ENABLE_ZLIB_UNCOMPRESS 1
/* Use cairo for rendering. */
#cmakedefine HAVE_CAIRO 1
......
......@@ -344,31 +344,53 @@ fi
AC_CHECK_FUNCS(pread64 lseek64)
dnl Test for zlib
AC_ARG_ENABLE([zlib],
[AS_HELP_STRING([--enable-zlib],[Build with zlib])],
[],[enable_zlib="no"])
AC_ARG_ENABLE(zlib,
AC_HELP_STRING([--disable-zlib],
[Don't build against zlib.]),
enable_zlib=$enableval,
enable_zlib="try")
AC_ARG_ENABLE([zlib_uncompress],
AS_HELP_STRING([--enable-zlib-uncompress],
[Use zlib to uncompress flate streams (not totally safe)]),
enable_zlib_uncompress=$enableval,
enable_zlib_uncompress="no")
if test x$enable_zlib = xyes; then
AC_CHECK_LIB([z], [inflate],,
AC_MSG_ERROR("*** zlib library not found ***"))
AC_CHECK_HEADERS([zlib.h],,
AC_MSG_ERROR("*** zlib headers not found ***"))
AC_CHECK_LIB([z], [inflate],,
AC_MSG_ERROR("*** zlib library not found ***"))
AC_CHECK_HEADERS([zlib.h],,
AC_MSG_ERROR("*** zlib headers not found ***"))
elif test x$enable_zlib = xtry; then
AC_CHECK_LIB([z], [inflate],
[enable_zlib="yes"],
[enable_zlib="no"])
AC_CHECK_HEADERS([zlib.h],,
[enable_zlib="no"])
AC_CHECK_LIB([z], [inflate],
[enable_zlib="yes"],
[enable_zlib="no"])
AC_CHECK_HEADERS([zlib.h],,
[enable_zlib="no"])
fi
if test x$enable_zlib = xyes; then
ZLIB_LIBS="-lz"
AC_SUBST(ZLIB_LIBS)
AC_DEFINE(ENABLE_ZLIB)
ZLIB_LIBS="-lz"
AC_SUBST(ZLIB_LIBS)
AC_DEFINE(ENABLE_ZLIB, 1, [Build against zlib.])
if test x$enable_zlib_uncompress = xyes; then
AC_DEFINE(ENABLE_ZLIB_UNCOMPRESS, 1,
[Use zlib instead of builtin zlib decoder to uncompress flate streams.])
fi
else
if test x$enable_zlib_uncompress = xyes; then
echo " Warning: --enable-zlib-uncompress is incompatible with --disable-zlib."
fi
enable_zlib_uncompress="no"
fi
AM_CONDITIONAL(BUILD_ZLIB, test x$enable_zlib = xyes)
AH_TEMPLATE([ENABLE_ZLIB],
[Use zlib instead of builtin zlib decoder.])
[Build against zlib.])
AM_CONDITIONAL(BUILD_ZLIB_UNCOMPRESS, test x$enable_zlib_uncompress = xyes)
AH_TEMPLATE([ENABLE_ZLIB_UNCOMPRESS],
[Use zlib instead of builtin zlib decoder to uncompress flate streams.])
dnl Test for libcurl
AC_ARG_ENABLE(libcurl,
......@@ -989,24 +1011,25 @@ poppler-cpp-uninstalled.pc])
echo ""
echo "Building poppler with support for:"
echo " font configuration: $with_font_configuration"
echo " splash output: $enable_splash_output"
echo " font configuration: $with_font_configuration"
echo " splash output: $enable_splash_output"
if test x$enable_cmyk = xyes;then
echo " with CMYK support"
fi
echo " cairo output: $use_cairo"
echo " qt4 wrapper: $enable_poppler_qt4"
echo " qt5 wrapper: $enable_poppler_qt5"
echo " glib wrapper: $use_glib"
echo " introspection: $found_introspection"
echo " cpp wrapper: $enable_poppler_cpp"
echo " use gtk-doc: $enable_gtk_doc"
echo " use libjpeg: $enable_libjpeg"
echo " use libpng: $enable_libpng"
echo " use libtiff: $enable_libtiff"
echo " use zlib: $enable_zlib"
echo " use libcurl: $enable_libcurl"
echo " use libopenjpeg: $enable_libopenjpeg"
echo " cairo output: $use_cairo"
echo " qt4 wrapper: $enable_poppler_qt4"
echo " qt5 wrapper: $enable_poppler_qt5"
echo " glib wrapper: $use_glib"
echo " introspection: $found_introspection"
echo " cpp wrapper: $enable_poppler_cpp"
echo " use gtk-doc: $enable_gtk_doc"
echo " use libjpeg: $enable_libjpeg"
echo " use libpng: $enable_libpng"
echo " use libtiff: $enable_libtiff"
echo " use zlib compress: $enable_zlib"
echo " use zlib uncompress: $enable_zlib_uncompress"
echo " use libcurl: $enable_libcurl"
echo " use libopenjpeg: $enable_libopenjpeg"
if test x$enable_libopenjpeg = xyes;then
if test x$openjpeg1 = xyes;then
echo " with openjpeg1"
......@@ -1014,7 +1037,7 @@ if test x$enable_libopenjpeg = xyes;then
echo " with openjpeg2"
fi
fi
echo " use cms: $enable_cms"
echo " use cms: $enable_cms"
if test x$enable_cms = xyes;then
if test x$lcms1 = xyes;then
echo " with lcms1"
......@@ -1023,10 +1046,10 @@ if test x$enable_cms = xyes;then
fi
fi
if test x$enable_build_type != xno;then
echo " build type: $enable_build_type"
echo " build type: $enable_build_type"
fi
echo " command line utils: $enable_utils"
echo " test data dir: $TESTDATADIR"
echo " command line utils: $enable_utils"
echo " test data dir: $TESTDATADIR"
echo ""
if test x$enable_splash_output = xno -a x$enable_cairo_output = xno; then
......@@ -1041,8 +1064,8 @@ if test x$enable_libjpeg != xyes; then
echo " Warning: Using libjpeg is recommended. The internal DCT decoder is unmaintained."
fi
if test x$enable_zlib != xno; then
echo " Warning: Using zlib is not totally safe"
if test x$enable_zlib_uncompress != xno; then
echo " Warning: Using zlib for decompression is not totally safe"
fi
if test x$enable_libopenjpeg != xyes; then
......
......@@ -8,7 +8,19 @@
// This file is under the GPLv2 or later license
//
//========================================================================
#include <config.h>
#ifdef USE_GCC_PRAGMAS
#pragma implementation
#endif
#include "poppler-config.h"
#if ENABLE_ZLIB_UNCOMPRESS
#include "FlateStream.h"
FlateStream::FlateStream(Stream *strA, int predictor, int columns, int colors, int bits) :
FilterStream(strA)
{
......@@ -126,3 +138,5 @@ GooString *FlateStream::getPSFilter(int psLevel, const char *indent) {
GBool FlateStream::isBinary(GBool last) {
return str->isBinary(gTrue);
}
#endif
......@@ -82,14 +82,22 @@ endif
if BUILD_ZLIB
zlib_sources = \
FlateStream.h \
FlateStream.cc
FlateEncoder.h \
FlateEncoder.cc
zlib_libs = \
$(ZLIB_LIBS)
endif
if BUILD_ZLIB_UNCOMPRESS
zlib_uncompress_sources = \
FlateStream.h \
FlateStream.cc
endif
if BUILD_LIBCURL
libcurl_libs = \
......@@ -200,6 +208,7 @@ libpoppler_la_SOURCES = \
$(splash_sources) \
$(libjpeg_sources) \
$(zlib_sources) \
$(zlib_uncompress_sources) \
$(libjpeg2000_sources) \
$(curl_sources) \
Annot.cc \
......
This diff is collapsed.
......@@ -20,7 +20,7 @@
// Copyright (C) 2009-2013 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2009 Till Kamppeter <till.kamppeter@gmail.com>
// Copyright (C) 2009 Carlos Garcia Campos <carlosgc@gnome.org>
// Copyright (C) 2009, 2011, 2015 William Bader <williambader@hotmail.com>
// Copyright (C) 2009, 2011, 2015-2016 William Bader <williambader@hotmail.com>
// Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
// Copyright (C) 2011, 2014 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
......@@ -321,6 +321,12 @@ public:
GBool getFontPassthrough() const { return fontPassthrough; }
GBool getOptimizeColorSpace() const { return optimizeColorSpace; }
GBool getEnableLZW() const { return enableLZW; };
GBool getEnableFlate() const
#if ENABLE_ZLIB
{ return enableFlate; }
#else
{ return gFalse; }
#endif
void setEmbedType1(GBool b) { embedType1 = b; }
void setEmbedTrueType(GBool b) { embedTrueType = b; }
void setEmbedCIDPostScript(GBool b) { embedCIDPostScript = b; }
......@@ -332,6 +338,7 @@ public:
void setUseASCIIHex(GBool b) { useASCIIHex = b; }
void setUseBinary(GBool b) { useBinary = b; }
void setEnableLZW(GBool b) { enableLZW = b; }
void setEnableFlate(GBool b) { enableFlate = b; }
private:
......@@ -535,6 +542,7 @@ private:
GBool useASCIIHex; // use ASCIIHex instead of ASCII85?
GBool useBinary; // use binary instead of hex
GBool enableLZW; // enable LZW compression
GBool enableFlate; // enable Flate compression
#if OPI_SUPPORT
int opi13Nest; // nesting level of OPI 1.3 objects
......
......@@ -70,7 +70,7 @@
#include "DCTStream.h"
#endif
#ifdef ENABLE_ZLIB
#ifdef ENABLE_ZLIB_UNCOMPRESS
#include "FlateStream.h"
#endif
......@@ -3865,7 +3865,7 @@ GBool DCTStream::isBinary(GBool last) {
#endif
#ifndef ENABLE_ZLIB
#ifndef ENABLE_ZLIB_UNCOMPRESS
//------------------------------------------------------------------------
// FlateStream
//------------------------------------------------------------------------
......
......@@ -942,7 +942,7 @@ private:
#endif
#ifndef ENABLE_ZLIB
#ifndef ENABLE_ZLIB_UNCOMPRESS
//------------------------------------------------------------------------
// FlateStream
//------------------------------------------------------------------------
......
......@@ -81,9 +81,9 @@
#undef ENABLE_LIBPNG
#endif
/* Use zlib instead of builtin zlib decoder. */
#ifndef ENABLE_ZLIB
#undef ENABLE_ZLIB
/* Use zlib instead of builtin zlib decoder for uncompressing flate streams. */
#ifndef ENABLE_ZLIB_UNCOMPRESS
#undef ENABLE_ZLIB_UNCOMPRESS
#endif
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment