From: Cliff Zhao <qzhao@suse.com>
Date: 2024-06-20 09:08:12 +0200
Subject: Drop all unused backup sources to clean up the compile env
References: bsc#1213720
Upstream: Doesn't need

--- CMakeLists.txt.orig	2024-06-29 17:32:04.996340212 +0000
+++ CMakeLists.txt.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,544 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-
-#*****************  IMPORTANT  ************* IMPORTANT **********************
-# Look at http://www.vtk.org/Wiki/CMake_HowToDoPlatformChecks
-# and the other wiki entries before you add anything. You might not need to.
-#****************************************************************************
-
-#
-# Project name and version
-#
-PROJECT(PoDoFo)
-
-SET(PODOFO_VERSION_MAJOR "0" CACHE STRING "Major part of PoDoFo version number")
-SET(PODOFO_VERSION_MINOR "9" CACHE STRING "Minor part of PoDoFo version number")
-SET(PODOFO_VERSION_PATCH "2" CACHE STRING "Patchlevel part of PoDoFo version number")
-SET(PODOFO_SOVERSION "${PODOFO_VERSION_MAJOR}.${PODOFO_VERSION_MINOR}.${PODOFO_VERSION_PATCH}")
-SET(PODOFO_LIBVERSION "${PODOFO_SOVERSION}")
-
-
-#
-# Main includes
-#
-INCLUDE(CheckIncludeFile)
-INCLUDE(CheckLibraryExists)
-INCLUDE(UsePkgConfig)
-INCLUDE(TestBigEndian)
-INCLUDE(CheckTypeSize)
-
-#
-# Setup CMake Policies
-#
-
-# Prefer files in CMAKE_MODULE_PATH over shipped ones in module directory
-CMAKE_POLICY(SET CMP0017 NEW) # https://cmake.org/cmake/help/v3.0/policy/CMP0017.html
-
-# Load modules from our source tree too
-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
-
-
-# Builds must use this CMakeLists.txt, not the one in src/ or somewhere else.
-# If users try to use something else the results can be confusing. We set a
-# variable here that we require to be set elsewhere, otherwise we'll complain.
-SET(PODOFO_MAIN_CMAKELISTS_READ TRUE)
-
-
-# If the user hasn't told use specifically what they want, build only
-# a static library.
-IF(NOT DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
-    SET(PODOFO_BUILD_STATIC TRUE)
-    SET(PODOFO_BUILD_SHARED FALSE)
-ENDIF(NOT DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
-IF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
-    SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_SHARED})
-ENDIF(DEFINED PODOFO_BUILD_SHARED AND NOT DEFINED PODOFO_BUILD_STATIC)
-IF(NOT DEFINED PODOFO_BUILD_SHARED AND DEFINED PODOFO_BUILD_STATIC)
-    SET(PODOFO_BUILD_SHARED NOT ${PODOFO_BUILD_STATIC})
-ENDIF(NOT DEFINED PODOFO_BUILD_SHARED AND DEFINED PODOFO_BUILD_STATIC)
-
-# Some 64 bit linux distros use /usr/lib64 for 64 bit libraries.
-# on these platforms we must
-IF(NOT DEFINED WANT_LIB64)
-	# TODO: detect 64-bit build and existance of /usr/lib64 and set to TRUE.
-	MESSAGE("WANT_LIB64 unset; assuming normal library directory names")
-	SET(WANT_LIB64 FALSE)
-ENDIF(NOT DEFINED WANT_LIB64)
-
-IF(WANT_LIB64)
-	SET(LIBDIRNAME "lib64")
-ELSE(WANT_LIB64)
-	SET(LIBDIRNAME "lib")
-ENDIF(WANT_LIB64)
-MESSAGE("Will install libraries to ${CMAKE_INSTALL_PREFIX}/${LIBDIRNAME}")
-
-# Some headers that tend to vary a bit
-CHECK_INCLUDE_FILE("strings.h" PODOFO_HAVE_STRINGS_H) 
-CHECK_INCLUDE_FILE("arpa/inet.h" PODOFO_HAVE_ARPA_INET_H) 
-CHECK_INCLUDE_FILE("winsock2.h" PODOFO_HAVE_WINSOCK2_H) 
-CHECK_INCLUDE_FILE("mem.h" PODOFO_HAVE_MEM_H) 
-CHECK_INCLUDE_FILE("ctype.h" PODOFO_HAVE_CTYPE_H) 
-
-# Do some type size detection and provide yet another set of typedefs for fixed
-# font sizes. We can't use the c99 / c++0x uint32_t etc, because people use
-# ancient compilers that don't and will never support the standard.
-
-CHECK_INCLUDE_FILE("sys/types.h" PODOFO_HAVE_SYS_TYPES_H) 
-CHECK_INCLUDE_FILE("stdint.h" PODOFO_HAVE_STDINT_H) 
-# See: http://msdn.microsoft.com/en-us/library/aa384264(VS.85).aspx
-CHECK_INCLUDE_FILE("BaseTsd.h" PODOFO_HAVE_BASETSD_H) 
-
-# We cache integer type detection results, and don't repeat them
-# (and overwrite the user's manual changes) if they've been done already.
-IF(NOT PDF_INT64_TYPENAME)
-  # I hate old compilers.
-  IF(PODOFO_HAVE_STDINT_H)
-    SET(pdfint8 "int8_t")
-    SET(pdfint16 "int16_t")
-    SET(pdfint32 "int32_t")
-    SET(pdfint64 "int64_t")
-    SET(pdfuint8 "uint8_t")
-    SET(pdfuint16 "uint16_t")
-    SET(pdfuint32 "uint32_t")
-    SET(pdfuint64 "uint64_t")
-  ELSE(PODOFO_HAVE_STDINT_H)
-    # No stdint.h . Try BaseTsd.h windows types.
-    IF(PODOFO_HAVE_BASETSD_H)
-       # We have BaseTsd.h, so use those types.
-       SET(pdfint8  "signed char")
-       SET(pdfint16 "short")
-       SET(pdfint32 "INT32")
-       SET(pdfint64 "INT64")
-       SET(pdfuint8 "unsigned char")
-       SET(pdfuint16 "unsigned short")
-       SET(pdfuint32 "UINT32")
-       SET(pdfuint64 "UINT64")
-    ELSE(PODOFO_HAVE_BASETSD_H)
-       # No BaseTsd.h either. Assume the standard types, and go poking
-       # for a sane 64-bit integer.
-       #
-       # First, though, make sure sizeof(int) = 4 and if not, scream, because
-       # hopefully this case will never be hit and we'll never have to write
-       # the horrible code check for
-       CHECK_TYPE_SIZE("signed char"        SZ_TINY_INT)
-       CHECK_TYPE_SIZE("unsigned char"      SZ_TINY_UINT)
-       CHECK_TYPE_SIZE("short int"          SZ_SHORT_INT)
-       CHECK_TYPE_SIZE("int"                SZ_INT)
-       CHECK_TYPE_SIZE("unsigned short int" SZ_UINT)
-       CHECK_TYPE_SIZE("unsigned int"       SZ_SHORT_UINT)
-       SET(smallintsok SZ_INT == 4 AND SZ_UINT == 4 AND SZ_SHORT_INT == 2 AND SZ_SHORT_UINT == 2 AND SZ_TINY_INT == 1 AND SZ_TINY_UINT == 1)
-       IF(NOT smallintsok)
-         MESSAGE(FATAL "sizeof(int) != 4 and/or sizeof(short) != 2 and no stdint.h or BaseTsd.h found. We don't know how to cope with this.")
-       ENDIF(NOT smallintsok)
-       SET(pdfint8 "signed char")
-       SET(pdfint16 "short")
-       SET(pdfint32 "int")
-       SET(pdfuint8 "unsigned char")
-       SET(pdfuint16 "unsigned short")
-       SET(pdfuint32 "unsigned int")
-       # Now we just have to figure out what 64-bit integer type we can use.
-       #
-       # Do we have VC >= 6's __uint64 and __int64?
-       # See: http://icfun.blogspot.com/2008/04/use-of-int64-variable-in-c.html
-       CHECK_TYPE_SIZE("__uint64" SZ___INT64)
-       CHECK_TYPE_SIZE("__int64"  SZ___UINT64)
-       IF(SZ___INT64 == 8 AND SZ___UINT64 == 8)
-         # MS compiler, VC6 or newer without BaseTsd.h in SDK
-         SET(pdfint64 "__int64")
-         SET(pdfuint64 "__uint64")
-       ELSE(SZ___INT64 AND SZ___UINT64)
-         # Still no luck. Old unix compiler, Borland, or some other monster?
-         # Are we lucky and sizeof(long) == 8?
-         CHECK_TYPE_SIZE("long int", SZ_LONG)
-         CHECK_TYPE_SIZE("unsigned long int", SZ_ULONG)
-         IF(SZ_LONG == 8 AND SZ_ULONG == 8)
-           # Must be on a LP64 platform, sizeof(long) = 8
-           SET(pdfint64 "long int")
-           SET(pdfuint64 "unsigned long int")
-         ELSE(SZ_LONG == 8 AND SZ_ULONG == 8)
-           # See if the compiler implements "long long int", _int64, int64, __int64 or int64_t
-           IF(PODOFO_HAVE_SYS_TYPES_H)
-             SET(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h")
-           ENDIF(PODOFO_HAVE_SYS_TYPES_H)
-           CHECK_TYPE_SIZE("long long int"          SZ_LONG_LONG)
-           CHECK_TYPE_SIZE("unsigned long long int" SZ_UNSIGNED_LONG_LONG)
-           IF(SZ_LONG_LONG == 8 AND SZ_UNSIGNED_LONG_LONG == 8)
-             SET(pdfint64 "long int")
-             SET(pdfuint64 "unsigned long int")
-           ELSE(SZ_LONG_LONG == 8 AND SZ_UNSIGNED_LONG_LONG == 8)
-             CHECK_TYPE_SIZE("int64_t"                SZ_INT64_T)
-             CHECK_TYPE_SIZE("uint64_t"               SZ_UINT64_T)
-             IF(SZ_INT64_T AND SZ_UINT64_T)
-               SET(pdfint64 "int64_t")
-               SET(pdfuint64 "uint64_t")
-             ELSE(SZ_INT64_T AND SZ_UINT64_T)
-               CHECK_TYPE_SIZE("int64"                SZ_INT64)
-               CHECK_TYPE_SIZE("uint64"               SZ_UINT64)
-               IF(SZ_INT64 AND SZ_UINT64)
-                 SET(pdfint64 "int64")
-                 SET(pdfuint64 "uint64")
-               ELSE(SZ_INT64 AND SZ_UINT64)
-                 CHECK_TYPE_SIZE("_int64"                SZ__INT64)
-                 CHECK_TYPE_SIZE("_uint64"               SZ__UINT64)
-                 IF(SZ__INT64 AND SZ__UINT64)
-                   SET(pdfint64 "_int64")
-                   SET(pdfuint64 "_uint64")
-                 ELSE(SZ__INT64 AND SZ__UINT64)
-                   MESSAGE("Oh my lord, your compiler doesn't seem to support any of the int64 type flavours we tried.")
-                   MESSAGE(WARNING "You must set the PDF_INTxx_TYPENAME and PDF_UINTxx_TYPENAME variables manually")
-                 ENDIF(SZ__INT64 AND SZ__UINT64)
-               ENDIF(SZ_INT64 AND SZ_UINT64)
-             ENDIF(SZ_INT64_T AND SZ_UINT64_T)
-           ENDIF(SZ_LONG_LONG == 8 AND SZ_UNSIGNED_LONG_LONG == 8)
-         ENDIF(SZ_LONG == 8 AND SZ_ULONG == 8)
-       ENDIF(SZ___INT64 AND SZ___UINT64)
-    ENDIF(PODOFO_HAVE_BASETSD_H)
-  ENDIF(PODOFO_HAVE_STDINT_H)
-  SET(CMAKE_EXTRA_INCLUDE_FILES)
-ENDIF(NOT PDF_INT64_TYPENAME)
-
-IF(NOT PDF_INT64_TYPENAME AND pdfint64)
-  SET(PDF_INT64_TYPENAME  "${pdfint64}" CACHE STRING "Name of detected 64-bit signed integer type to use")
-  SET(PDF_INT32_TYPENAME  "${pdfint32}" CACHE STRING "Name of detected 32-bit signed integer type to use")
-  SET(PDF_INT16_TYPENAME  "${pdfint16}" CACHE STRING "Name of detected 16-bit signed integer type to use")
-  SET(PDF_INT8_TYPENAME   "${pdfint8}" CACHE STRING "Name of detected 8-bit signed integer type to use")
-  SET(PDF_UINT64_TYPENAME "${pdfuint64}" CACHE STRING "Name of detected 64-bit unsigned integer type to use")
-  SET(PDF_UINT32_TYPENAME "${pdfuint32}" CACHE STRING "Name of detected 32-bit unsigned integer type to use")
-  SET(PDF_UINT16_TYPENAME "${pdfuint16}" CACHE STRING "Name of detected 16-bit unsigned integer type to use")
-  SET(PDF_UINT8_TYPENAME  "${pdfuint8}" CACHE STRING "Name of detected 8-bit unsigned integer type to use")
-ENDIF(NOT PDF_INT64_TYPENAME AND pdfint64)
-
-
-# Linux packagers want an uninstall target.
-CONFIGURE_FILE(
-    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
-    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
-    IMMEDIATE @ONLY)
-ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}"
-    -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-
-# Check if we are big endian
-TEST_BIG_ENDIAN(TEST_BIG)
-
-IF(WIN32)
-    # On win32 we support EITHER shared OR static builds.
-    # If both are enabled (default), turn off generation of the
-    # static library.
-    IF(PODOFO_BUILD_SHARED AND PODOFO_BUILD_STATIC)
-         MESSAGE("Both PODOFO_BUILD_SHARED and PODOFO_BUILD_STATIC set")
-         MESSAGE("  so disabling shared library generation (win32)")
-         SET(PODOFO_BUILD_SHARED FALSE)
-         SET(PODOFO_BUILD_STATIC TRUE)
-    ENDIF(PODOFO_BUILD_SHARED AND PODOFO_BUILD_STATIC)
-    # We must explicitly link to the core win32 libraries, and we need winsock2
-    # to get some byte-order conversion routines too.
-    SET(PLATFORM_SYSTEM_LIBRARIES kernel32 user32 gdi32 winspool comdlg32 advapi32 shell32 ole32 oleaut32 uuid ws2_32)
-    # Microsoft deprecate certain POSIX functions that we use.
-    # for now, turn off these warnings.
-    ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
-    # We need a fake unistd.h for some libraries to build. They try to include <unistd.h>
-    # which is not available under win32 with MSVC++, but everything in unistd.h is defined,
-    # so an empty file solves the issue.
-    SET(EXTRA_INCLUDES ${PoDoFo_SOURCE_DIR}/vcincludes)
-ELSE(WIN32)
-    SET(PLATFORM_SYSTEM_LIBRARIES)
-    SET(EXTRA_INCLUDES)
-ENDIF(WIN32)
-
-IF(UNIX)
-    SET(WANT_FONTCONFIG TRUE CACHE INTERNAL
-        "True if PoDoFo should be built with fontconfig support")
-ELSE(UNIX)
-    SET(WANT_FONTCONFIG FALSE CACHE INTERNAL
-        "True if PoDoFo should be built with fontconfig support")
-ENDIF(UNIX)
-
-
-IF(CMAKE_COMPILER_IS_GNUCXX)
-    MESSAGE("Using gcc specific compiler options")
-    # We can be more specific about what we want out of g++
-    # than with most other compilers.
-
-    # Attempt to detect the gcc version. You must not rely on
-    # this; use the detected version as a guide only.
-    EXEC_PROGRAM(gcc ARGS --version OUTPUT_VARIABLE GCC_VERSION)
-    IF(GCC_VERSION MATCHES ".*\\(GCC\\) 4\\.[0-9].*")
-        MESSAGE("Have gcc 4.x")
-        SET(PODOFO_HAVE_GCC4 1)
-    ELSE(GCC_VERSION MATCHES ".*\\(GCC\\) 4\\.[0-9].*")
-        SET(PODOFO_HAVE_GCC4 0)
-    ENDIF(GCC_VERSION MATCHES ".*\\(GCC\\) 4\\.[0-9].*")
-
-    # If the user hasn't specifically said whether they want
-    # -fvisibility=hidden or not, turn it on for gcc4 and off
-    # for other gcc versions.
-    IF(NOT DEFINED PODOFO_USE_VISIBILITY)
-        SET(PODOFO_USE_VISIBILITY ${PODOFO_HAVE_GCC4})
-    ENDIF(NOT DEFINED PODOFO_USE_VISIBILITY)
-
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-
-    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Woverloaded-virtual -Wswitch-enum -Wcast-qual -Wwrite-strings -Wredundant-decls -Wreorder -Wno-deprecated-declarations")
-
-    #
-    # Note that we do not need debug definitions here. Set
-    # -DCMAKE_BUILD_TYPE=debug or (if you want an optimised
-    # release build with debug info) -DCMAKE_CXX_FLAGS="-g3"
-    #
-    # We add -W unless we're using gcc on win32, where it produces
-    # spurious warnings about dllimport of inlines because of a dllimport
-    # declaration on the whole class.
-    IF(NOT WIN32)
-        ADD_DEFINITIONS(-W)
-    ENDIF(NOT WIN32)
-    # If they've enabled the use of gcc4 symbol visibility, use it.
-    IF(PODOFO_USE_VISIBILITY)
-        ADD_DEFINITIONS(
-            -DPODOFO_HAVE_GCC_SYMBOL_VISIBILITY
-            -fvisibility=hidden
-            )
-    ENDIF(PODOFO_USE_VISIBILITY)
-ENDIF(CMAKE_COMPILER_IS_GNUCXX)
-
-FIND_PACKAGE(ZLIB REQUIRED)
-MESSAGE("Found zlib headers in ${ZLIB_INCLUDE_DIR}, library at ${ZLIB_LIBRARIES}")
-
-FIND_PACKAGE(LIBCRYPTO)
-
-IF(LIBCRYPTO_FOUND)
-	SET(PODOFO_HAVE_OPENSSL TRUE)
-	MESSAGE("Found OpenSSL's libCrypto headers in ${LIBCRYPTO_INCLUDE_DIR}, library at ${LIBCRYPTO_LIBRARIES}")
-ELSE(LIBCRYPTO_FOUND)
-	MESSAGE("OpenSSL's libCrypto not found. Encryption support will be disabled")
-ENDIF(LIBCRYPTO_FOUND)
-
-FIND_PACKAGE(LIBIDN)
-
-IF(LIBIDN_FOUND)
-  MESSAGE("Found libidn headers in ${LIBIDN_INCLUDE_DIR}, library at ${LIBIDN_LIBRARIES}")
-ENDIF(LIBIDN_FOUND)
-
-IF(LIBIDN_FOUND)
-	SET(PODOFO_HAVE_LIBIDN TRUE)
-	INCLUDE_DIRECTORIES(${LIBIDN_INCLUDE_DIR})
-	MESSAGE("Libidn found. AES-256 Encryption support will be enabled")
-ELSE(LIBIDN_FOUND)
-	MESSAGE("Libidn not found. AES-256 Encryption support will be disabled")
-ENDIF(LIBIDN_FOUND)
-
-FIND_PACKAGE(LIBJPEG)
-
-IF(LIBJPEG_FOUND)
-  MESSAGE("Found libjpeg headers in ${LIBJPEG_INCLUDE_DIR}, library at ${LIBJPEG_LIBRARIES}")
-  SET(PODOFO_HAVE_JPEG_LIB TRUE)
-  INCLUDE_DIRECTORIES(${LIBJPEG_INCLUDE_DIR})
-ELSE(LIBJPEG_FOUND)
-  MESSAGE("Libjpeg not found. JPEG support will be disabled")
-ENDIF(LIBJPEG_FOUND)
-
-FIND_PACKAGE(TIFF)
-
-IF(TIFF_FOUND)
-  MESSAGE("Found libtiff headers in ${TIFF_INCLUDE_DIR}, library at ${TIFF_LIBRARIES}")
-  SET(PODOFO_HAVE_TIFF_LIB TRUE)
-  INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
-ELSE(TIFF_FOUND)
-  MESSAGE("Libtiff not found. TIFF support will be disabled")
-ENDIF(TIFF_FOUND)
-
-FIND_PACKAGE(PNG)
-
-IF(PNG_FOUND)
-  MESSAGE("Found LibPng headers in ${PNG_INCLUDE_DIR}, library at ${PNG_LIBRARIES}")
-  SET(PODOFO_HAVE_PNG_LIB TRUE)
-  INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
-ELSE(PNG_FOUND)
-  MESSAGE("LibPng not found. PNG support will be disabled")
-ENDIF(PNG_FOUND)
-
-
-FIND_PACKAGE(CppUnit)
-
-IF(CppUnit_FOUND)
-  MESSAGE("Found cppunit. Unit tests will be built.")
-  SET(PODOFO_HAVE_CPPUNIT CppUnit_FOUND)
-  INCLUDE_DIRECTORIES(${CPPUNIT_INCLUDE_DIR})
-ELSE(CppUnit_FOUND)
-  MESSAGE("Cppunit not found. No unit tests will be built.")
-ENDIF(CppUnit_FOUND)
-
-FIND_PACKAGE(OpenSSL)
-
-FIND_PACKAGE(Freetype REQUIRED)
-MESSAGE("Found freetype library at ${FREETYPE_LIBRARY}, headers ${FREETYPE_INCLUDE_DIRS}")
-
-FIND_PACKAGE(LIBSTLPORT)
-SET(stlport_libraries_if_use_stlport)
-IF(USE_STLPORT)
-	IF(LIBSTLPORT_FOUND)
-		MESSAGE("Using STLPort")
-		INCLUDE_DIRECTORIES(${LIBSTLPORT_HEADERS})
-		LINK_DIRECTORIES(${LIBSTLPORT_LIB})
-		SET(stlport_libraries_if_use_stlport stlport)
-		# Use the threaded STLPort
-		ADD_DEFINITIONS(-D_PTHREADS)
-	ELSE(LIBSTLPORT_FOUND)
-		MESSAGE(FATAL_ERROR "STLPort use requested, but STLPort not found.")
-	ENDIF(LIBSTLPORT_FOUND)
-ENDIF(USE_STLPORT)
-
-IF(WANT_FONTCONFIG)
-	FIND_PACKAGE(FONTCONFIG REQUIRED)
-	SET(PODOFO_HAVE_FONTCONFIG TRUE)
-	SET(PODOFO_LIB_FONTCONFIG:STRING fontconfig)
-	IF(FONTCONFIG_FOUND)
-	  MESSAGE("Found fontconfig headers in ${FONTCONFIG_INCLUDE_DIR}, library at ${FONTCONFIG_LIBRARIES}")
-	ELSE(FONTCONFIG_FOUND)
-	  MESSAGE("Could not find fontconfig.")
-        ENDIF(FONTCONFIG_FOUND)
-ELSE(WANT_FONTCONFIG)
-	# Might as well look for it anyway. This also sets the appropriate
-	# variables to empty values.
-	FIND_PACKAGE(FONTCONFIG)
-	SET(PODOFO_LIB_FONTCONFIG:STRING)
-ENDIF(WANT_FONTCONFIG)
-
-# libjpeg has routines that take a FILE*. This is safe if and only
-# if the C runtime podofo is built against is the same as the C runtime
-# libjpeg is built against. That is not always the case.
-#
-# If the user has explicitly told us that libjpeg's libc is binary compatible,
-# don't worry about using workarounds. Otherwise, on Windows we assume it's not
-# compatible and on other platforms we'll assume it is. This change currently
-# only affects PdfImage.cpp.
-#
-IF(DEFINED JPEG_RUNTIME_COMPATIBLE)
-	IF(JPEG_RUNTIME_COMPATIBLE)
-		# Trust the user to know what they're doing and pass a FILE*
-		SET(PODOFO_JPEG_RUNTIME_COMPATIBLE TRUE)
-	ENDIF(JPEG_RUNTIME_COMPATIBLE)
-ELSE(DEFINED JPEG_RUNTIME_COMPATIBLE)
-	IF(NOT WIN32)
-		# It's a sensible platform and the user hasn't told us
-		# otherwise - pass a FILE* .
-		SET(PODOFO_JPEG_RUNTIME_COMPATIBLE TRUE)
-	ENDIF(NOT WIN32)
-ENDIF(DEFINED JPEG_RUNTIME_COMPATIBLE)
-
-FIND_PACKAGE(LUA)
-IF(LUA_FOUND)
-	# If we have lua, we can build podofoimpose.
-	MESSAGE("Lua found - PoDoFoImpose and PoDoFoColor will be built with Lua support")
-	MESSAGE(" * Lua include directory: ${LUA_INCLUDE_DIR}")
-	MESSAGE(" * Lua libraries: ${LUA_LIBRARIES}")
-	INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
-	SET(PODOFO_HAVE_LUA TRUE)
-ELSE(LUA_FOUND)
-	MESSAGE("Lua not found - PoDoFoImpose and PoDoFoColor will be built without Lua support")
-ENDIF(LUA_FOUND)
-
-
-# Check if we should build a multithreaded version of PoDoFo
-IF(DEFINED PODOFO_NO_MULTITHREAD)
-  MESSAGE("Building non multithreaded version of PoDoFo.")
-  SET(PODOFO_MULTI_THREAD FALSE)
-ELSE(DEFINED PODOFO_NO_MULTITHREAD)
-  MESSAGE("Building multithreaded version of PoDoFo.")
-  SET(PODOFO_MULTI_THREAD TRUE)
-  FIND_PACKAGE(Threads)
-  SET(PLATFORM_SYSTEM_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${PLATFORM_SYSTEM_LIBRARIES})
-ENDIF(DEFINED PODOFO_NO_MULTITHREAD)
-
-IF(WANT_BOOST)
-    MESSAGE("Looking optional for Boost.")
-    MESSAGE("Boost is optional, so don't worry if it is not found.")
-    MESSAGE("Set the BOOST_ROOT env var if you have problems.")
-    FIND_PACKAGE(Boost)
-    IF(BOOST_FOUND)
-       SET(PODOFO_HAVE_BOOST TRUE)
-       INCLUDE_DIRECTORIES(${BOOST_INCLUDE_DIR})
-    ELSE(BOOST_FOUND)
-       MESSAGE("If you don't need graph support you can ignore the above error.")
-    ENDIF(BOOST_FOUND)
-ENDIF(WANT_BOOST)
-
-INCLUDE_DIRECTORIES(
-    ${PoDoFo_BINARY_DIR}
-    ${PoDoFo_SOURCE_DIR}
-    ${PoDoFo_SOURCE_DIR}/src
-    ${FREETYPE_INCLUDE_DIRS}
-    ${ZLIB_INCLUDE_DIR}
-    ${EXTRA_INCLUDES}
-     )
-LINK_DIRECTORIES(
-    ${PoDoFo_BINARY_DIR}/src/
-    )
-
-#
-# The PoDoFo library needs to be linked to these libraries,
-# as do any apps or libraries linking to PoDoFo. PODOFO_LIB
-# will include these and the correct podofo target, so clients
-# should specify only PODOFO_LIB .
-#
-SET(PODOFO_LIB_DEPENDS
-  ${ZLIB_LIBRARIES}
-  ${LIBIDN_LIBRARIES}
-  ${LIBCRYPTO_LIBRARIES}
-  ${LIBJPEG_LIBRARIES}
-  ${PLATFORM_SYSTEM_LIBRARIES}
-  ${stlport_libraries_if_use_stlport}
-  ${FREETYPE_LIBRARY}
-  ${PNG_LIBRARIES}
-  ${TIFF_LIBRARIES}
-  )
-
-IF(FONTCONFIG_FOUND AND WANT_FONTCONFIG)
-  SET(PODOFO_LIB_DEPENDS ${FONTCONFIG_LIBRARIES} ${PODOFO_LIB_DEPENDS})
-  INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIR})
-ENDIF(FONTCONFIG_FOUND AND WANT_FONTCONFIG)
-
-SET(PODOFO_LIB
-    podofo
-    ${PODOFO_LIB_DEPENDS}
-    )
-
-#
-# Setup directories we will need
-#
-SET(MANDIR "share/man/")
-
-# Create the config file. It'll be appended to as the subdirs run though
-# then dependency information will be written to it at the end of the
-# build.
-FILE(WRITE
-     "${PoDoFo_BINARY_DIR}/PoDoFoConfig.cmake"
-     "# CMake module for PoDoFo\n"
-     )
-FILE(APPEND 
-     "${PoDoFo_BINARY_DIR}/PoDoFoConfig.cmake"
-     "SET(PODOFO_INCLUDES ${PoDoFo_SOURCE_DIR}/src)\n"
-     )
-
-ADD_SUBDIRECTORY(src)
-IF(NOT PODOFO_BUILD_LIB_ONLY)
-ADD_SUBDIRECTORY(test)
-ADD_SUBDIRECTORY(tools)
-ADD_SUBDIRECTORY(examples)
-ADD_SUBDIRECTORY(debian)
-ENDIF(NOT PODOFO_BUILD_LIB_ONLY)
-
-# Generate our configure file
-CONFIGURE_FILE(${PoDoFo_SOURCE_DIR}/podofo_config.h.in ${PoDoFo_BINARY_DIR}/podofo_config.h)
-
-# Export some variables into the config file so it's easier for others
-# to build and link against PoDoFo
-
-# To use these dependencies set PODOFO_DIR to the podofo BUILD directory in
-# your build (eg -DPODOFO_DIR=/path/to/podofo when running cmake to configure
-# the app that'll use podofo). See: FIND_PACKAGE(...) in the cmake docs.
-IF(PODOFO_BUILD_SHARED)
-  EXPORT(TARGETS podofo_shared FILE "${CMAKE_CURRENT_BINARY_DIR}/PoDoFoConfig.cmake")
-ENDIF(PODOFO_BUILD_SHARED)
-IF(PODOFO_BUILD_STATIC)
-  EXPORT(TARGETS podofo_static FILE "${CMAKE_CURRENT_BINARY_DIR}/PoDoFoConfig.cmake")
-ENDIF(PODOFO_BUILD_STATIC)
-
--- examples/helloworld/helloworld.cpp.orig	2010-10-11 15:45:32.000000000 +0000
+++ examples/helloworld/helloworld.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,254 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-
-/*
- * Include the standard headers for cout to write
- * some output to the console.
- */
-#include <iostream>
-
-/*
- * Now include all podofo header files, to have access
- * to all functions of podofo and so that you do not have
- * to care about the order of includes.
- *
- * You should always use podofo.h and not try to include
- * the required headers on your own.
- */
-#include <podofo/podofo.h>
-
-/*
- * All podofo classes are member of the PoDoFo namespace.
- */
-using namespace PoDoFo;
-
-void PrintHelp()
-{
-    std::cout << "This is a example application for the PoDoFo PDF library." << std::endl
-              << "It creates a small PDF file containing the text >Hello World!<" << std::endl
-              << "Please see http://podofo.sf.net for more information" << std::endl << std::endl;
-    std::cout << "Usage:" << std::endl;
-    std::cout << "  examplehelloworld [outputfile.pdf]" << std::endl << std::endl;
-}
-
-void HelloWorld( const char* pszFilename ) 
-{
-    /*
-     * PdfStreamedDocument is the class that can actually write a PDF file.
-     * PdfStreamedDocument is much faster than PdfDocument, but it is only
-     * suitable for creating/drawing PDF files and cannot modify existing
-     * PDF documents.
-     *
-     * The document is written directly to pszFilename while being created.
-     */
-    PdfStreamedDocument document( pszFilename );
-
-	/*
-     * PdfPainter is the class which is able to draw text and graphics
-     * directly on a PdfPage object.
-     */
-    PdfPainter painter;
-
-	/*
-     * This pointer will hold the page object later. 
-     * PdfSimpleWriter can write several PdfPage's to a PDF file.
-     */
-    PdfPage* pPage;
-
-	/*
-     * A PdfFont object is required to draw text on a PdfPage using a PdfPainter.
-     * PoDoFo will find the font using fontconfig on your system and embedd truetype
-     * fonts automatically in the PDF file.
-     */     
-    PdfFont* pFont;
-
-	try {
-		/*
-		 * The PdfDocument object can be used to create new PdfPage objects.
-		 * The PdfPage object is owned by the PdfDocument will also be deleted automatically
-		 * by the PdfDocument object.
-		 *
-		 * You have to pass only one argument, i.e. the page size of the page to create.
-		 * There are predefined enums for some common page sizes.
-		 */
-		pPage = document.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-
-		/*
-		 * If the page cannot be created because of an error (e.g. ePdfError_OutOfMemory )
-		 * a NULL pointer is returned.
-		 * We check for a NULL pointer here and throw an exception using the RAISE_ERROR macro.
-		 * The raise error macro initializes a PdfError object with a given error code and
-		 * the location in the file in which the error ocurred and throws it as an exception.
-		 */
-		if( !pPage ) 
-		{
-			PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-		}
-
-		/*
-		 * Set the page as drawing target for the PdfPainter.
-		 * Before the painter can draw, a page has to be set first.
-		 */
-		painter.SetPage( pPage );
-
-		/*
-		 * Create a PdfFont object using the font "Arial".
-		 * The font is found on the system using fontconfig and embedded into the
-		 * PDF file. If Arial is not available, a default font will be used.
-		 *
-		 * The created PdfFont will be deleted by the PdfDocument.
-		 */
-		pFont = document.CreateFont( "Arial" );
-	    
-		/*
-		 * If the PdfFont object cannot be allocated return an error.
-		 */
-		if( !pFont )
-		{
-			PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-		}
-
-		/*
-		 * Set the font size
-		 */
-		pFont->SetFontSize( 18.0 );
-
-		/*
-		 * Set the font as default font for drawing.
-		 * A font has to be set before you can draw text on
-		 * a PdfPainter.
-		 */
-		painter.SetFont( pFont );
-
-		/*
-		 * You could set a different color than black to draw
-		 * the text.
-		 *
-		 * SAFE_OP( painter.SetColor( 1.0, 0.0, 0.0 ) );
-		 */
-
-		/*
-		 * Actually draw the line "Hello World!" on to the PdfPage at
-		 * the position 2cm,2cm from the top left corner. 
-		 * Please remember that PDF files have their origin at the 
-		 * bottom left corner. Therefore we substract the y coordinate 
-		 * from the page height.
-		 * 
-		 * The position specifies the start of the baseline of the text.
-		 *
-		 * All coordinates in PoDoFo are in PDF units.
-		 * You can also use PdfPainterMM which takes coordinates in 1/1000th mm.
-		 *
-		 */
-		painter.DrawText( 56.69, pPage->GetPageSize().GetHeight() - 56.69, "Hello World!" );
-
-		/*
-		 * Tell PoDoFo that the page has been drawn completely.
-		 * This required to optimize drawing operations inside in PoDoFo
-		 * and has to be done whenever you are done with drawing a page.
-		 */
-		painter.FinishPage();
-
-		/*
-		 * Set some additional information on the PDF file.
-		 */
-		document.GetInfo()->SetCreator ( PdfString("examplahelloworld - A PoDoFo test application") );
-		document.GetInfo()->SetAuthor  ( PdfString("Dominik Seichter") );
-		document.GetInfo()->SetTitle   ( PdfString("Hello World") );
-		document.GetInfo()->SetSubject ( PdfString("Testing the PoDoFo PDF Library") );
-		document.GetInfo()->SetKeywords( PdfString("Test;PDF;Hello World;") );
-
-		/*
-		 * The last step is to close the document.
-		 */
-		document.Close();
-	} catch ( const PdfError & e ) {
-		/*
-		 * All PoDoFo methods may throw exceptions
-		 * make sure that painter.FinishPage() is called
-		 * or who will get an assert in its destructor
-		 */
-		try {
-			painter.FinishPage();
-		} catch( ... ) {
-			/*
-			 * Ignore errors this time
-			 */
-		}
-
-		throw e;
-	}
-}
-
-int main( int argc, char* argv[] )
-{
-    /*
-     * Check if a filename was passed as commandline argument.
-     * If more than 1 argument or no argument is passed,
-     * a help message is displayed and the example application
-     * will quit.
-     */
-    if( argc != 2 )
-    {
-        PrintHelp();
-        return -1;
-    }
-
-    /*
-     * All podofo functions will throw an exception in case of an error.
-     *
-     * You should catch the exception to either fix it or report
-     * back to the user.
-     *
-     * All exceptions podofo throws are objects of the class PdfError.
-     * Thats why we simply catch PdfError objects.
-     */
-    try {
-        /*
-         * Call the drawing routing which will create a PDF file
-         * with the filename of the output file as argument.
-         */
-         HelloWorld( argv[1] );
-    } catch( const PdfError & eCode ) {
-        /*
-         * We have to check if an error has occurred.
-         * If yes, we return and print an error message
-         * to the commandline.
-         */
-        eCode.PrintErrorMsg();
-        return eCode.GetError();
-    }
-
-
-    /**
-     * Free global memory allocated by PoDoFo.
-     * This is normally not necessary.
-     */
-    PdfEncodingFactory::FreeGlobalEncodingInstances();
-
-    /*
-     * The PDF was created sucessfully.
-     */
-    std::cout << std::endl
-              << "Created a PDF file containing the line \"Hello World!\": " << argv[1] << std::endl << std::endl;
-    
-    return 0;
-}
--- examples/helloworld-base14/helloworld-base14.cpp.orig	2010-04-29 21:50:40.000000000 +0000
+++ examples/helloworld-base14/helloworld-base14.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,380 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-
-/*
- * Include the standard headers for cout to write
- * some output to the console.
- */
-#include <iostream>
-
-/* Include appropriate system header for standard integer types
-*/
-#ifdef _WIN32
-#include <BaseTsd.h>
-#else
-#include <stdint.h>
-#endif
-/*
- * Now include all podofo header files, to have access
- * to all functions of podofo and so that you do not have
- * to care about the order of includes.
- *
- * You should always use podofo.h and not try to include
- * the required headers on your own.
- */
-#include <podofo.h>
-
-/*
- * All podofo classes are member of the PoDoFo namespace.
- */
-using namespace PoDoFo;
-
-
-
-void PrintHelp()
-{
-    std::cout << "This is a example application for the PoDoFo PDF library." << std::endl
-              << "It creates a small PDF file containing the text >Hello World!<" << std::endl
-              << "Please see http://podofo.sf.net for more information" << std::endl << std::endl;
-    std::cout << "Usage:" << std::endl;
-    std::cout << "  examplehelloworld [outputfile.pdf]" << std::endl << std::endl;
-}
-
-const char * GetBase14FontName(int i);
-void DemoBase14Fonts(PdfPainter& painter, PdfPage* pPage, PdfStreamedDocument& document);
-
-void HelloWorld( const char* pszFilename ) 
-{
-    /*
-     * PdfStreamedDocument is the class that can actually write a PDF file.
-     * PdfStreamedDocument is much faster than PdfDocument, but it is only
-     * suitable for creating/drawing PDF files and cannot modify existing
-     * PDF documents.
-     *
-     * The document is written directly to pszFilename while being created.
-     */
-    PdfStreamedDocument document( pszFilename );
-
-	/*
-     * PdfPainter is the class which is able to draw text and graphics
-     * directly on a PdfPage object.
-     */
-    PdfPainter painter;
-
-	/*
-     * This pointer will hold the page object later. 
-     * PdfSimpleWriter can write several PdfPage's to a PDF file.
-     */
-    PdfPage* pPage;
-
-	/*
-     * A PdfFont object is required to draw text on a PdfPage using a PdfPainter.
-     * PoDoFo will find the font using fontconfig on your system and embedd truetype
-     * fonts automatically in the PDF file.
-     */     
-    PdfFont* pFont;
-
-	try {
-		/*
-		 * The PdfDocument object can be used to create new PdfPage objects.
-		 * The PdfPage object is owned by the PdfDocument will also be deleted automatically
-		 * by the PdfDocument object.
-		 *
-		 * You have to pass only one argument, i.e. the page size of the page to create.
-		 * There are predefined enums for some common page sizes.
-		 */
-		pPage = document.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-
-		/*
-		 * If the page cannot be created because of an error (e.g. ePdfError_OutOfMemory )
-		 * a NULL pointer is returned.
-		 * We check for a NULL pointer here and throw an exception using the RAISE_ERROR macro.
-		 * The raise error macro initializes a PdfError object with a given error code and
-		 * the location in the file in which the error ocurred and throws it as an exception.
-		 */
-		if( !pPage ) 
-		{
-			PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-		}
-
-		/*
-		 * Set the page as drawing target for the PdfPainter.
-		 * Before the painter can draw, a page has to be set first.
-		 */
-		painter.SetPage( pPage );
-
-		/*
-		 * Create a PdfFont object using the font "Arial".
-		 * The font is found on the system using fontconfig and embedded into the
-		 * PDF file. If Arial is not available, a default font will be used.
-		 *
-		 * The created PdfFont will be deleted by the PdfDocument.
-		 */
-		pFont = document.CreateFont( "Helvetica" );
-
-		/*
-		 * If the PdfFont object cannot be allocated return an error.
-		 */
-		if( !pFont )
-		{
-			PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-		}
-
-		/*
-		 * Set the font size
-		 */
-		pFont->SetFontSize( 18.0 );
-
-		/*
-		 * Set the font as default font for drawing.
-		 * A font has to be set before you can draw text on
-		 * a PdfPainter.
-		 */
-		painter.SetFont( pFont );
-
-		/*
-		 * You could set a different color than black to draw
-		 * the text.
-		 *
-		 * SAFE_OP( painter.SetColor( 1.0, 0.0, 0.0 ) );
-		 */
-
-		/*
-		 * Actually draw the line "Hello World!" on to the PdfPage at
-		 * the position 2cm,2cm from the top left corner. 
-		 * Please remember that PDF files have their origin at the 
-		 * bottom left corner. Therefore we substract the y coordinate 
-		 * from the page height.
-		 * 
-		 * The position specifies the start of the baseline of the text.
-		 *
-		 * All coordinates in PoDoFo are in PDF units.
-		 * You can also use PdfPainterMM which takes coordinates in 1/1000th mm.
-		 *
-		 */
-		painter.DrawText( 56.69, pPage->GetPageSize().GetHeight() - 56.69, "Hello World!" );
-
-		DemoBase14Fonts(painter, pPage, document);
-
-		painter.FinishPage();
-
-		/*
-		 * The last step is to close the document.
-		 */
-		document.Close();
-
-	} catch ( const PdfError & e ) {
-		/*
-		 * All PoDoFo methods may throw exceptions
-		 * make sure that painter.FinishPage() is called
-		 * or who will get an assert in its destructor
-		 */
-		try {
-			painter.FinishPage();
-		} catch( ... ) {
-			/*
-			 * Ignore errors this time
-			 */
-		}
-
-		throw e;
-	}
-}
-
-int main( int argc, char* argv[] )
-{
-    /*
-     * Check if a filename was passed as commandline argument.
-     * If more than 1 argument or no argument is passed,
-     * a help message is displayed and the example application
-     * will quit.
-     */
-    if( argc != 2 )
-    {
-        PrintHelp();
-        return -1;
-    }
-
-    /*
-     * All podofo functions will throw an exception in case of an error.
-     *
-     * You should catch the exception to either fix it or report
-     * back to the user.
-     *
-     * All exceptions podofo throws are objects of the class PdfError.
-     * Thats why we simply catch PdfError objects.
-     */
-    try {
-        /*
-         * Call the drawing routing which will create a PDF file
-         * with the filename of the output file as argument.
-         */
-         HelloWorld( argv[1] );
-    } catch( const PdfError & eCode ) {
-        /*
-         * We have to check if an error has occurred.
-         * If yes, we return and print an error message
-         * to the commandline.
-         */
-        eCode.PrintErrorMsg();
-        return eCode.GetError();
-    }
-
-    /*
-     * The PDF was created sucessfully.
-     */
-    std::cout << std::endl
-              << "Created a PDF file containing the line \"Hello World!\": " << argv[1] << std::endl << std::endl;
-    
-    return 0;
-}
-
-// Base14 + other non-Base14 fonts for comparison
-#define NUM_BASE14_FONTS 17
-
-const char * GetBase14FontName(int i)
-{
-	const char *base14fonts[NUM_BASE14_FONTS] = {
-							"Courier",
-							"Courier-Bold",
-							"Courier-Oblique",
-							"Courier-BoldOblique",
-							"Helvetica",
-							"Helvetica-Bold",
-							"Helvetica-Oblique",
-							"Helvetica-BoldOblique",
-							"Times-Roman",
-							"Times-Bold",
-							"Times-Italic",
-							"Times-BoldItalic",
-							"Symbol",
-							"ZapfDingbats",
-
-							"Arial",
-							"Times New Roman",
-							"Verdana"
-							};
-
-	if (i >= 0 && i < NUM_BASE14_FONTS)
-		return base14fonts[i]; 
-	else
-		return NULL;
-
-}
-
-void DrawRedFrame(PdfPainter& painter, double x, double y, double width, double height)
-{
-        // draw red box
-        painter.SetColor(1.0f, 0.0f, 0.0f);
-        painter.SetStrokingColor(1.0f, 0.0f, 0.0f);
-        painter.DrawLine(x, y, x+width, y);
-        if ( height > 0.0f )
-        {
-            painter.DrawLine(x, y, x, y+height);
-            painter.DrawLine(x+width, y, x+width, y+height);
-            painter.DrawLine(x, y+height, x+width, y+height);
-        }
-        // restore to black
-        painter.SetColor(0.0f, 0.0f, 0.0f);
-        painter.SetStrokingColor(0.0f, 0.0f, 0.0f);
-}
-
-
-void DemoBase14Fonts(PdfPainter& painter, PdfPage* pPage, PdfStreamedDocument& document)
-{
-	double x = 56,y = pPage->GetPageSize().GetHeight() - 56.69;
-	char text[255];
-	const char *demo_text = "abcdefgABCDEFG12345!#$%&+-@?        ";
-	double height=0.0f, width=0.0f;
-    int i;
-
-    // draw sample of all types
-	for(i = 0; i < NUM_BASE14_FONTS; ++i)
-	{
-		x = 56; y = y - 25;
-		strcpy(text, demo_text);
-		strcat(text, GetBase14FontName(i));
-
-		PdfFont *pFont = document.CreateFont( GetBase14FontName(i) );
-		pFont->SetFontSize( 12.0 );
-		painter.SetFont( pFont );
-		
-        width  = pFont->GetFontMetrics()->StringWidth(text);
-        height = pFont->GetFontMetrics()->GetLineSpacing();
-
-
-		std::cout <<  GetBase14FontName(i) << " Width = " << width << " Height = " << height << std::endl;
-
-        // draw red box
-        DrawRedFrame( painter, x, y, width, height);
-
-        // draw text
-		painter.DrawText( x, y , text);
-	}
-
-    // draw some individual characters:
-    const char *demo_text2 = " @_1jiPlg .;";
-    int nChars = strlen(demo_text2);
-
-    // draw  individuals
-
-	for(i = 0; i < nChars; i++)
-	{
-		x = 56; y = y - 25;
-        if ( i==0 )
-        {
-		    strcpy(text, "Helvetica / Arial Comparison:");
-
-        } else {
-		    text[0] = demo_text2[i];
-		    text[1] = '\0';
-        }
-
-        PdfFont *pFont = document.CreateFont("Helvetica");
-        painter.SetFont( pFont );
-        height = pFont->GetFontMetrics()->GetLineSpacing();
-        width  = pFont->GetFontMetrics()->StringWidth(text);
-
-        // draw red box
-        DrawRedFrame( painter, x, y, width, height);
-
-        // draw text
-		painter.DrawText( x, y , text);
-
-        if ( i>0 )
-        {
-            // draw again, with non-Base14 font
-            PdfFont *pFont2 = document.CreateFont("Arial");
-            painter.SetFont( pFont2 );
-            height = pFont2->GetFontMetrics()->GetLineSpacing();
-            width  = pFont2->GetFontMetrics()->StringWidth(text);
-
-            // draw red box
-            DrawRedFrame( painter, x+100, y, width, height);
-
-            // draw text
-		    painter.DrawText( x+100, y , text);
-	    }
-	}
-
-
-}
-
--- src/base/PdfColor.cpp.orig	2011-10-06 18:30:36.000000000 +0000
+++ src/base/PdfColor.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1231 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfColor.h"
-
-#include "PdfArray.h"
-#include "PdfDictionary.h"
-#include "PdfLocale.h"
-#include "PdfStream.h"
-#include "PdfTokenizer.h"
-#include "PdfVariant.h"
-#include "PdfDefinesPrivate.h"
-
-#include <algorithm>
-#include <ctype.h>
-
-namespace PoDoFo {
-
-/** A PdfNamedColor holds
- *  a PdfColor object and a name.
- */
-class PdfNamedColor {
-public:
-    /** Create a PdfNamedColor object.
-     *
-     *  \param pszName the name. The string must be allocated as static memory somewhere
-     *         The string data will not be copied!
-     *  \param rColor a PdfColor object
-     */
-    PdfNamedColor( const char* pszName, const PdfColor & rColor )
-        : m_pszName( pszName ), m_color( rColor )
-    {
-    }
-
-    /** Create a PdfNamedColor object.
-     *
-     *  \param pszName the name. The string must be allocated as static memory somewhere
-     *         The string data will not be copied!
-     *  \param rColorName RGB hex value (e.g. #FFABCD)
-     */
-    PdfNamedColor( const char* pszName, const char* rColorName )
-        : m_pszName( pszName ), m_color( FromRGBString(rColorName) )
-    {
-    }
-
-    /** Copy constructor
-     */
-    PdfNamedColor(const PdfNamedColor& rhs)
-        : m_pszName( rhs.m_pszName ), m_color( rhs.m_color )
-    {
-    }
-
-    /** Class destructor.
-     */
-    ~PdfNamedColor()
-    {
-    }
-
-    /** Compare this color object to a name 
-     *  The comparison is case insensitive!
-     *  \returns true if the passed string is smaller than the name
-     *           of this color object.
-     */
-    inline bool operator<( const char* pszName ) const
-    {
-        return pszName ? PoDoFo::compat::strcasecmp( m_pszName, pszName ) < 0 : true; 
-	}
-
-    /** Compare this color object to a PdfNamedColor comparing only the name.
-     *  The comparison is case insensitive!
-     *  \returns true if the passed string is smaller than the name
-     *           of this color object.
-     */
-    inline bool operator<( const PdfNamedColor & rhs ) const
-    {
-        return rhs.GetName() ? PoDoFo::compat::strcasecmp( m_pszName, rhs.GetName() ) < 0 : true; 
-    }
-
-
-    /** Compare this color object to a name 
-     *  The comparison is case insensitive!
-     *  \returns true if the passed string is the name
-     *           of this color object.
-     */
-    inline bool operator==( const char* pszName ) const
-    {
-        return pszName ? PoDoFo::compat::strcasecmp( m_pszName, pszName ) == 0 : false; 
-    }
-
-    /** 
-     * \returns a reference to the internal color object
-     */
-    inline const PdfColor & GetColor() const 
-    {
-        return m_color;
-    }
-    
-    /**
-     * \returns a pointer to the name of the color
-     */
-    inline const char* GetName() const
-    {
-        return m_pszName;
-    }
-
-private:
-    /** default constructor, not implemented
-     */
-    PdfNamedColor();
-
-    /** copy assignment operator, not implemented
-     */
-    PdfNamedColor& operator=(const PdfNamedColor&);
-
-    /** Creates a color object from a RGB string.
-     *
-     *  \param pszName a string describing a color.
-     *
-     *  Supported values are:
-     *  - hex values (e.g. #FF002A (RGB))
-     *
-     *  \returns a PdfColor object
-     */
-    static PdfColor FromRGBString( const char* pszName )
-    {
-        //This method cannot use PdfTokenizer::GetHexValue() as static values used there have 
-        //not been initialised yet. This function should used only during program startup
-        //and the only purpose is use at s_NamedColors table.
-
-        size_t lLen = strlen( pszName );
-        if (
-            (lLen == 7) &&
-            (pszName[0] == '#') &&
-            isxdigit(pszName[1])
-            )
-        {
-            const unsigned long NAME_CONVERTED_TO_LONG_HEX = 
-                static_cast<unsigned long>(strtol(&pszName[1], 0, 16));
-
-            const unsigned long R = (NAME_CONVERTED_TO_LONG_HEX & 0x00FF0000) >> 16;
-            const unsigned long G = (NAME_CONVERTED_TO_LONG_HEX & 0x0000FF00) >> 8;
-            const unsigned long B = (NAME_CONVERTED_TO_LONG_HEX & 0x000000FF);
-            
-            return PdfColor( static_cast<double>(R)/255.0, 
-                             static_cast<double>(G)/255.0, 
-                             static_cast<double>(B)/255.0 );
-        }
-        else
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-        }
-    }
-
-    const char* m_pszName;
-    PdfColor    m_color;
-};
-
-/**
- * Predicate to allow binary search in the list
- * of PdfNamedColor's using for example std::equal_range.
- */
-class NamedColorComparatorPredicate { 
-public:
-    NamedColorComparatorPredicate()
-    {
-    }
-
-    inline bool operator()( const PdfNamedColor & rNamedColor1, const PdfNamedColor & rNamedColor2 ) const { 
-        return rNamedColor1 < rNamedColor2;
-    }
-};
-
-// Table based on http://cvsweb.xfree86.org/cvsweb/xc/programs/rgb/rgb.txt?rev=1.2
-// Hex values have been copied from http://en.wikipedia.org/wiki/X11_color_names (21/11/2010)
-static const size_t s_nNumNamedColors = 148;
-static const PdfNamedColor s_NamedColors[s_nNumNamedColors] = 
-{
-    PdfNamedColor( "aliceblue",     "#F0F8FF" ) ,
-    PdfNamedColor( "antiquewhite",  "#FAEBD7" ) ,
-    PdfNamedColor( "aqua",          "#00FFFF" ) ,
-    PdfNamedColor( "aquamarine",    "#7FFFD4" ) ,
-    PdfNamedColor( "azure",         "#F0FFFF" ) ,
-    PdfNamedColor( "beige",         "#F5F5DC" ) ,
-    PdfNamedColor( "bisque",        "#FFE4C4" ) ,
-    PdfNamedColor( "black",         "#000000" ) ,
-    PdfNamedColor( "blanchedalmond","#FFEBCD" ) ,
-    PdfNamedColor( "blue",          "#0000FF" ) ,
-    PdfNamedColor( "blueviolet",    "#8A2BE2" ) ,
-    PdfNamedColor( "brown",         "#A52A2A" ) ,
-    PdfNamedColor( "burlywood",     "#DEB887" ) ,
-    PdfNamedColor( "cadetblue",     "#5F9EA0" ) ,
-    PdfNamedColor( "chartreuse",    "#7FFF00" ) ,
-    PdfNamedColor( "chocolate",     "#D2691E" ) ,
-    PdfNamedColor( "coral",         "#FF7F50" ) ,
-    PdfNamedColor( "cornflowerblue","#6495ED" ) ,
-    PdfNamedColor( "cornsilk",      "#FFF8DC" ) ,
-    PdfNamedColor( "crimson",       "#DC143C" ) ,
-    PdfNamedColor( "cyan",          "#00FFFF" ) ,
-    PdfNamedColor( "darkblue",      "#00008B" ) ,
-    PdfNamedColor( "darkcyan",      "#008B8B" ) ,
-    PdfNamedColor( "darkgoldenrod", "#B8860B" ) ,
-    PdfNamedColor( "darkgray",      "#A9A9A9" ) ,
-    PdfNamedColor( "darkgreen",     "#006400" ) ,
-    PdfNamedColor( "darkgrey",      "#A9A9A9" ) ,
-    PdfNamedColor( "darkkhaki",     "#BDB76B" ) ,
-    PdfNamedColor( "darkmagenta",   "#8B008B" ) ,
-    PdfNamedColor( "darkolivegreen","#556B2F" ) ,
-    PdfNamedColor( "darkorange",    "#FF8C00" ) ,
-    PdfNamedColor( "darkorchid",    "#9932CC" ) ,
-    PdfNamedColor( "darkred",       "#8B0000" ) ,
-    PdfNamedColor( "darksalmon",    "#E9967A" ) ,
-    PdfNamedColor( "darkseagreen",  "#8FBC8F" ) ,
-    PdfNamedColor( "darkslateblue", "#483D8B" ) ,
-    PdfNamedColor( "darkslategray", "#2F4F4F" ) ,
-    PdfNamedColor( "darkslategrey", "#2F4F4F" ) ,
-    PdfNamedColor( "darkturquoise", "#00CED1" ) ,
-    PdfNamedColor( "darkviolet",    "#9400D3" ) ,
-    PdfNamedColor( "deeppink",      "#FF1493" ) ,
-    PdfNamedColor( "deepskyblue",   "#00BFFF" ) ,
-    PdfNamedColor( "dimgray",       "#696969" ) ,
-    PdfNamedColor( "dimgrey",       "#696969" ) ,
-    PdfNamedColor( "dodgerblue",    "#1E90FF" ) ,
-    PdfNamedColor( "firebrick",     "#B22222" ) ,
-    PdfNamedColor( "floralwhite",   "#FFFAF0" ) ,
-    PdfNamedColor( "forestgreen",   "#228B22" ) ,
-    PdfNamedColor( "fuchsia",       "#FF00FF" ) ,
-    PdfNamedColor( "gainsboro",     "#DCDCDC" ) ,
-    PdfNamedColor( "ghostwhite",    "#F8F8FF" ) ,
-    PdfNamedColor( "gold",          "#FFD700" ) ,
-    PdfNamedColor( "goldenrod",     "#DAA520" ) ,
-    PdfNamedColor( "gray",          "#BEBEBE" ) , //RG changed from W3C to X11 value
-    PdfNamedColor( "green",         "#00FF00" ) ,
-    PdfNamedColor( "greenyellow",   "#ADFF2F" ) ,
-    PdfNamedColor( "grey",          "#BEBEBE" ) , //RG changed from W3C to X11 value
-    PdfNamedColor( "honeydew",      "#F0FFF0" ) ,
-    PdfNamedColor( "hotpink",       "#FF69B4" ) ,
-    PdfNamedColor( "indianred",     "#CD5C5C" ) ,
-    PdfNamedColor( "indigo",        "#4B0082" ) ,
-    PdfNamedColor( "ivory",         "#FFFFF0" ) ,
-    PdfNamedColor( "khaki",         "#F0E68C" ) ,
-    PdfNamedColor( "lavender",      "#E6E6FA" ) ,
-    PdfNamedColor( "lavenderblush", "#FFF0F5" ) ,
-    PdfNamedColor( "lawngreen",     "#7CFC00" ) ,
-    PdfNamedColor( "lemonchiffon",  "#FFFACD" ) ,
-    PdfNamedColor( "lightblue",     "#ADD8E6" ) ,
-    PdfNamedColor( "lightcoral",    "#F08080" ) ,
-    PdfNamedColor( "lightcyan",     "#E0FFFF" ) ,
-    PdfNamedColor( "lightgoldenrod", "#EEDD82" ) ,
-    PdfNamedColor( "lightgoldenrodyellow", "#FAFAD2" ) ,
-    PdfNamedColor( "lightgray",     "#D3D3D3" ) ,
-    PdfNamedColor( "lightgreen",    "#90EE90" ) ,
-    PdfNamedColor( "lightgrey",     "#D3D3D3" ) ,
-    PdfNamedColor( "lightpink",     "#FFB6C1" ) ,
-    PdfNamedColor( "lightsalmon",   "#FFA07A" ) ,
-    PdfNamedColor( "lightseagreen", "#20B2AA" ) ,
-    PdfNamedColor( "lightskyblue",  "#87CEFA" ) ,
-    PdfNamedColor( "lightslategray","#778899" ) ,
-    PdfNamedColor( "lightslategrey","#778899" ) ,
-    PdfNamedColor( "lightsteelblue","#B0C4DE" ) ,
-    PdfNamedColor( "lightyellow",   "#FFFFE0" ) ,
-    PdfNamedColor( "lime",          "#00FF00" ) ,
-    PdfNamedColor( "limegreen",     "#32CD32" ) ,
-    PdfNamedColor( "linen",         "#FAF0E6" ) ,
-    PdfNamedColor( "magenta",       "#FF00FF" ) ,
-    PdfNamedColor( "maroon",        "#B03060" ) , //RG changed from W3C to X11 value
-    PdfNamedColor( "mediumaquamarine", "#66CDAA" ) ,
-    PdfNamedColor( "mediumblue",    "#0000CD" ) ,
-    PdfNamedColor( "mediumorchid",  "#BA55D3" ) ,
-    PdfNamedColor( "mediumpurple",  "#9370DB" ) ,
-    PdfNamedColor( "mediumseagreen","#3CB371" ) ,
-    PdfNamedColor( "mediumslateblue", "#7B68EE" ) ,
-    PdfNamedColor( "mediumspringgreen", "#00FA9A" ) ,
-    PdfNamedColor( "mediumturquoise", "#48D1CC" ) ,
-    PdfNamedColor( "mediumvioletred", "#C71585" ) ,
-    PdfNamedColor( "midnightblue",  "#191970" ) ,
-    PdfNamedColor( "mintcream",     "#F5FFFA" ) ,
-    PdfNamedColor( "mistyrose",     "#FFE4E1" ) ,
-    PdfNamedColor( "moccasin",      "#FFE4B5" ) ,
-    PdfNamedColor( "navajowhite",   "#FFDEAD" ) ,
-    PdfNamedColor( "navy",          "#000080" ) ,
-    PdfNamedColor( "oldlace",       "#FDF5E6" ) ,
-    PdfNamedColor( "olive",         "#808000" ) ,
-    PdfNamedColor( "olivedrab",     "#6B8E23" ) ,
-    PdfNamedColor( "orange",        "#FFA500" ) ,
-    PdfNamedColor( "orangered",     "#FF4500" ) ,
-    PdfNamedColor( "orchid",        "#DA70D6" ) ,
-    PdfNamedColor( "palegoldenrod", "#EEE8AA" ) ,
-    PdfNamedColor( "palegreen",     "#98FB98" ) ,
-    PdfNamedColor( "paleturquoise", "#AFEEEE" ) ,
-    PdfNamedColor( "palevioletred", "#DB7093" ) ,
-    PdfNamedColor( "papayawhip",    "#FFEFD5" ) ,
-    PdfNamedColor( "peachpuff",     "#FFDAB9" ) ,
-    PdfNamedColor( "peru",          "#CD853F" ) ,
-    PdfNamedColor( "pink",          "#FFC0CB" ) ,
-    PdfNamedColor( "plum",          "#DDA0DD" ) ,
-    PdfNamedColor( "powderblue",    "#B0E0E6" ) ,
-    PdfNamedColor( "purple",        "#A020F0" ) , //RG changed from W3C to X11 value
-    PdfNamedColor( "red",           "#FF0000" ) ,
-    PdfNamedColor( "rosybrown",     "#BC8F8F" ) ,
-    PdfNamedColor( "royalblue",     "#4169E1" ) ,
-    PdfNamedColor( "saddlebrown",   "#8B4513" ) ,
-    PdfNamedColor( "salmon",        "#FA8072" ) ,
-    PdfNamedColor( "sandybrown",    "#F4A460" ) ,
-    PdfNamedColor( "seagreen",      "#2E8B57" ) ,
-    PdfNamedColor( "seashell",      "#FFF5EE" ) ,
-    PdfNamedColor( "sienna",        "#A0522D" ) ,
-    PdfNamedColor( "silver",        "#C0C0C0" ) ,
-    PdfNamedColor( "skyblue",       "#87CEEB" ) ,
-    PdfNamedColor( "slateblue",     "#6A5ACD" ) ,
-    PdfNamedColor( "slategray",     "#708090" ) ,
-    PdfNamedColor( "slategrey",     "#708090" ) ,
-    PdfNamedColor( "snow",          "#FFFAFA" ) ,
-    PdfNamedColor( "springgreen",   "#00FF7F" ) ,
-    PdfNamedColor( "steelblue",     "#4682B4" ) ,
-    PdfNamedColor( "tan",           "#D2B48C" ) ,
-    PdfNamedColor( "teal",          "#008080" ) ,
-    PdfNamedColor( "thistle",       "#D8BFD8" ) ,
-    PdfNamedColor( "tomato",        "#FF6347" ) ,
-    PdfNamedColor( "turquoise",     "#40E0D0" ) ,
-    PdfNamedColor( "violet",        "#EE82EE" ) ,
-    PdfNamedColor( "wheat",         "#F5DEB3" ) ,
-    PdfNamedColor( "white",         "#FFFFFF" ) ,
-    PdfNamedColor( "whitesmoke",    "#F5F5F5" ) ,
-    PdfNamedColor( "yellow",        "#FFFF00" ) ,
-    PdfNamedColor( "yellowgreen",   "#9ACD32" ) 
-};
-
-inline void CheckDoubleRange( double val, double min, double max )
-{
-    if( (val < min) || (val > max) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-    }
-}
-
-PdfColor::PdfColor() :
-    m_uColor(),
-    m_separationName(),
-    m_separationDensity(0.0),
-    m_eColorSpace(ePdfColorSpace_Unknown),
-    m_eAlternateColorSpace(ePdfColorSpace_Unknown)
-{
-    m_uColor.rgb[0] = 0.0;
-    m_uColor.rgb[1] = 0.0;
-    m_uColor.rgb[2] = 0.0;
-}
-
-PdfColor::PdfColor( double dGray ) :
-    m_uColor(),
-    m_separationName(),
-    m_separationDensity(0.0),
-    m_eColorSpace(ePdfColorSpace_DeviceGray),
-    m_eAlternateColorSpace(ePdfColorSpace_Unknown)
-{
-    CheckDoubleRange( dGray, 0.0, 1.0 );
-
-    m_uColor.gray = dGray;
-}
-
-PdfColor::PdfColor( double dRed, double dGreen, double dBlue ) :
-    m_uColor(),
-    m_separationName(),
-    m_separationDensity(0.0),
-    m_eColorSpace(ePdfColorSpace_DeviceRGB),
-    m_eAlternateColorSpace(ePdfColorSpace_Unknown)
-{
-    CheckDoubleRange( dRed,   0.0, 1.0 );
-    CheckDoubleRange( dGreen, 0.0, 1.0 );
-    CheckDoubleRange( dBlue,  0.0, 1.0 );
-
-    m_uColor.rgb[0] = dRed;
-    m_uColor.rgb[1] = dGreen;
-    m_uColor.rgb[2] = dBlue;
-}
-
-PdfColor::PdfColor( double dCyan, double dMagenta, double dYellow, double dBlack ) :
-    m_uColor(),
-    m_separationName(),
-    m_separationDensity(0.0),
-    m_eColorSpace( ePdfColorSpace_DeviceCMYK ),
-    m_eAlternateColorSpace(ePdfColorSpace_Unknown)
-{
-    CheckDoubleRange( dCyan,    0.0, 1.0 );
-    CheckDoubleRange( dMagenta, 0.0, 1.0 );
-    CheckDoubleRange( dYellow,  0.0, 1.0 );
-    CheckDoubleRange( dBlack,   0.0, 1.0 );
-
-    m_uColor.cmyk[0] = dCyan;
-    m_uColor.cmyk[1] = dMagenta;
-    m_uColor.cmyk[2] = dYellow;
-    m_uColor.cmyk[3] = dBlack;
-}
-
-PdfColor::PdfColor( const PdfColor & rhs ) :
-    m_uColor(),
-    m_separationName(rhs.m_separationName),
-    m_separationDensity(rhs.m_separationDensity),
-    m_eColorSpace(rhs.m_eColorSpace),
-    m_eAlternateColorSpace(rhs.m_eAlternateColorSpace)
-{
-    memcpy( &m_uColor, &rhs.m_uColor, sizeof(m_uColor) );
-}
-
-PdfColor::~PdfColor()
-{
-}
-
-PdfColorGray::PdfColorGray( double dGray ) :
-    PdfColor( dGray )
-{
-}
-
-PdfColorGray::~PdfColorGray()
-{
-}
-
-PdfColorRGB::PdfColorRGB( double dRed, double dGreen, double dBlue )
-    : PdfColor( dRed, dGreen, dBlue )
-{
-}
-
-PdfColorRGB::~PdfColorRGB()
-{
-}
-
-PdfColorCMYK::PdfColorCMYK( double dCyan, double dMagenta, double dYellow, double dBlack )
-    : PdfColor( dCyan, dMagenta, dYellow, dBlack )
-{
-}
-
-PdfColorCMYK::~PdfColorCMYK()
-{
-}
-
-PdfColorCieLab::PdfColorCieLab( double dCieL, double dCieA, double dCieB )
-  : PdfColor()
-{
-    CheckDoubleRange( dCieL,    0.0, 100.0 );
-    CheckDoubleRange( dCieA, -128.0, 127.0 );
-    CheckDoubleRange( dCieB, -128.0, 127.0 );
-
-    m_eColorSpace = ePdfColorSpace_CieLab;
-    m_uColor.lab[0] = dCieL;
-    m_uColor.lab[1] = dCieA;
-    m_uColor.lab[2] = dCieB;
-}
-
-PdfColorCieLab::~PdfColorCieLab()
-{
-}
-
-PdfColorSeparationAll::PdfColorSeparationAll()
-  : PdfColor()
-{
-    m_eColorSpace = ePdfColorSpace_Separation;
-    m_separationName = "All";
-    m_separationDensity = 1.0;
-    m_eAlternateColorSpace = ePdfColorSpace_DeviceCMYK;
-    m_uColor.cmyk[0] = 1.0;
-    m_uColor.cmyk[1] = 1.0;
-    m_uColor.cmyk[2] = 1.0;
-    m_uColor.cmyk[3] = 1.0;
-}
-
-PdfColorSeparationAll::~PdfColorSeparationAll()
-{
-}
-
-PdfColorSeparationNone::PdfColorSeparationNone()
-  : PdfColor()
-{
-    m_eColorSpace = ePdfColorSpace_Separation;
-    m_separationName = "None";
-    m_separationDensity = 0.0;
-    m_eAlternateColorSpace = ePdfColorSpace_DeviceCMYK;
-    m_uColor.cmyk[0] = 0.0;
-    m_uColor.cmyk[1] = 0.0;
-    m_uColor.cmyk[2] = 0.0;
-    m_uColor.cmyk[3] = 0.0;
-}
-
-PdfColorSeparationNone::~PdfColorSeparationNone()
-{
-}
-
-PdfColorSeparation::PdfColorSeparation( const std::string & sName, double dDensity, const PdfColor & alternateColor )
-  : PdfColor()
-{
-    m_eAlternateColorSpace = alternateColor.GetColorSpace();
-    switch( m_eAlternateColorSpace )
-    {
-        case ePdfColorSpace_DeviceGray:
-        {
-            m_uColor.gray = alternateColor.GetGrayScale();
-            break;
-        }
-        case ePdfColorSpace_DeviceRGB:
-        {
-            m_uColor.rgb[0] = alternateColor.GetRed();
-            m_uColor.rgb[1] = alternateColor.GetGreen();
-            m_uColor.rgb[2] = alternateColor.GetBlue();
-            break;
-        }
-        case ePdfColorSpace_DeviceCMYK:
-        {
-            m_uColor.cmyk[0] = alternateColor.GetCyan();
-            m_uColor.cmyk[1] = alternateColor.GetMagenta();
-            m_uColor.cmyk[2] = alternateColor.GetYellow();
-            m_uColor.cmyk[3] = alternateColor.GetBlack();
-            break;
-        }
-        case ePdfColorSpace_CieLab:
-        {
-            m_uColor.lab[0] = alternateColor.GetCieL();
-            m_uColor.lab[1] = alternateColor.GetCieA();
-            m_uColor.lab[2] = alternateColor.GetCieB();
-            break;
-        }
-        case ePdfColorSpace_Separation:
-        {
-            PODOFO_RAISE_LOGIC_IF( true, "PdfColor::PdfColorSeparation alternateColor must be Gray, RGB, CMYK or CieLab!");
-            break;
-        }
-        case ePdfColorSpace_Unknown:
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-            break;
-        }
-    }
-    m_eColorSpace = ePdfColorSpace_Separation;
-    m_separationName = sName;
-    m_separationDensity = dDensity;
-}
-
-PdfColorSeparation::~PdfColorSeparation()
-{
-}
-
-const PdfColor & PdfColor::operator=( const PdfColor & rhs )
-{
-    if (this != &rhs)
-    {
-        memcpy( &m_uColor, &rhs.m_uColor, sizeof(m_uColor) );
-        m_separationName = rhs.m_separationName;
-        m_separationDensity = rhs.m_separationDensity;
-        m_eColorSpace = rhs.m_eColorSpace;
-        m_eAlternateColorSpace = rhs.m_eAlternateColorSpace;
-    }
-    else
-    {
-        //do nothing
-    }
-
-    return *this;
-}
-
-PdfColor PdfColor::ConvertToGrayScale() const
-{
-    switch(m_eColorSpace)
-    {
-        case ePdfColorSpace_DeviceGray:
-        {
-            return *this;
-        }
-        case ePdfColorSpace_DeviceRGB:
-        {
-            return PdfColor( 0.299*m_uColor.rgb[0] + 0.587*m_uColor.rgb[1] + 0.114*m_uColor.rgb[2] );
-        }
-        case ePdfColorSpace_DeviceCMYK:
-        {
-            return ConvertToRGB().ConvertToGrayScale();
-        }
-        case ePdfColorSpace_Separation:
-        {
-            if ( m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK )
-            {
-                double dCyan    = m_uColor.cmyk[0];
-                double dMagenta = m_uColor.cmyk[1];
-                double dYellow  = m_uColor.cmyk[2];
-                double dBlack   = m_uColor.cmyk[3];
-
-                double dRed   = dCyan    * (1.0 - dBlack) + dBlack;
-                double dGreen = dMagenta * (1.0 - dBlack) + dBlack;
-                double dBlue  = dYellow  * (1.0 - dBlack) + dBlack;
-
-                return PdfColor( 1.0 - dRed, 1.0 - dGreen, 1.0 - dBlue );
-            }
-            else
-            {
-                PODOFO_RAISE_ERROR( ePdfError_NotImplemented );
-            }
-            break;
-        }
-        case ePdfColorSpace_CieLab:
-        case ePdfColorSpace_Unknown:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-            break;
-        }
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-            break;
-        }
-    };
-
-    return PdfColor();
-}
-
-PdfColor PdfColor::ConvertToRGB() const
-{
-    switch(m_eColorSpace)
-    {
-        case ePdfColorSpace_DeviceGray:
-        {
-            return PdfColor( m_uColor.gray, m_uColor.gray, m_uColor.gray );
-        }
-        case ePdfColorSpace_DeviceRGB:
-        {
-            return *this;
-        }
-        case ePdfColorSpace_DeviceCMYK:
-        {
-            double dCyan    = m_uColor.cmyk[0];
-            double dMagenta = m_uColor.cmyk[1];
-            double dYellow  = m_uColor.cmyk[2];
-            double dBlack   = m_uColor.cmyk[3];
-
-            double dRed   = dCyan    * (1.0 - dBlack) + dBlack;
-            double dGreen = dMagenta * (1.0 - dBlack) + dBlack;
-            double dBlue  = dYellow  * (1.0 - dBlack) + dBlack;
-
-            return PdfColor( 1.0 - dRed, 1.0 - dGreen, 1.0 - dBlue );
-        }
-        case ePdfColorSpace_Separation:
-        {
-            if ( m_eAlternateColorSpace == ePdfColorSpace_DeviceCMYK )
-            {
-                double dCyan    = m_uColor.cmyk[0];
-                double dMagenta = m_uColor.cmyk[1];
-                double dYellow  = m_uColor.cmyk[2];
-                double dBlack   = m_uColor.cmyk[3];
-
-                double dRed   = dCyan    * (1.0 - dBlack) + dBlack;
-                double dGreen = dMagenta * (1.0 - dBlack) + dBlack;
-                double dBlue  = dYellow  * (1.0 - dBlack) + dBlack;
-
-                return PdfColor( 1.0 - dRed, 1.0 - dGreen, 1.0 - dBlue );
-            }
-            else
-            {
-                PODOFO_RAISE_ERROR( ePdfError_NotImplemented );
-            }
-
-            break;
-        }
-        case ePdfColorSpace_CieLab:
-        case ePdfColorSpace_Unknown:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-            break;
-        }
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-            break;
-        }
-    };
-
-    return PdfColor();
-}
-
-PdfColor PdfColor::ConvertToCMYK() const
-{
-    switch(m_eColorSpace)
-    {
-        case ePdfColorSpace_DeviceGray:
-        {
-            return ConvertToRGB().ConvertToCMYK();
-        }
-        case ePdfColorSpace_DeviceRGB:
-        {
-            double dRed   = m_uColor.rgb[0];
-            double dGreen = m_uColor.rgb[1];
-            double dBlue  = m_uColor.rgb[2];
-
-            double dBlack   = PDF_MIN( 1.0-dRed, PDF_MIN( 1.0-dGreen, 1.0-dBlue ) );
-
-            double dCyan = 0.0;
-            double dMagenta = 0.0;
-            double dYellow = 0.0;
-            if (dBlack < 1.0)
-            {
-                dCyan    = (1.0 - dRed   - dBlack) / (1.0 - dBlack);
-                dMagenta = (1.0 - dGreen - dBlack) / (1.0 - dBlack);
-                dYellow  = (1.0 - dBlue  - dBlack) / (1.0 - dBlack);
-            }
-            //else do nothing
-
-            return PdfColor( dCyan, dMagenta, dYellow, dBlack );
-        }
-        case ePdfColorSpace_DeviceCMYK:
-        {
-            return *this;
-        }
-        case ePdfColorSpace_Separation:
-        case ePdfColorSpace_CieLab:
-        case ePdfColorSpace_Unknown:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-            break;
-        }
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-            break;
-        }
-    };
-}
-
-PdfArray PdfColor::ToArray() const
-{
-    PdfArray array;
-
-    switch(m_eColorSpace)
-    {
-        case ePdfColorSpace_DeviceGray:
-        {
-            array.push_back( m_uColor.gray );
-            break;
-        }
-        case ePdfColorSpace_DeviceRGB:
-        {
-            array.push_back( m_uColor.rgb[0] ); 
-            array.push_back( m_uColor.rgb[1] ); 
-            array.push_back( m_uColor.rgb[2] );
-            break;
-        }
-        case ePdfColorSpace_DeviceCMYK:
-        {
-            array.push_back( m_uColor.cmyk[0] ); 
-            array.push_back( m_uColor.cmyk[1] ); 
-            array.push_back( m_uColor.cmyk[2] ); 
-            array.push_back( m_uColor.cmyk[3] ); 
-            break;
-        }
-        case ePdfColorSpace_CieLab:
-        {
-            array.push_back( m_uColor.lab[0] ); 
-            array.push_back( m_uColor.lab[1] ); 
-            array.push_back( m_uColor.lab[2] );
-            break;
-        }
-        case ePdfColorSpace_Separation:
-        {
-            array.push_back( m_separationDensity );
-            break;
-        }
-        case ePdfColorSpace_Unknown:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-            break;
-        }
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-            break;
-        }
-    };
-
-    return array;
-}
-
-PdfColor PdfColor::FromString( const char* pszName )
-{
-    if( pszName ) 
-    {
-        size_t lLen = strlen( pszName );
-
-        // first see if it's a single number - if so, that's a single gray value
-        if( isdigit( pszName[0] ) || (pszName[0] == '.') ) 
-        {
-            double dGrayVal = 0.0;
-
-            std::istringstream stream( pszName );
-            PdfLocaleImbue(stream);
-
-            if( !(stream >> dGrayVal) ) 
-            {
-                PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-            }            
-            else
-            {
-                return PdfColor( dGrayVal );
-            }
-        }
-        // now check for a hex value (#xxxxxx or #xxxxxxxx)
-        else if( pszName[0] == '#' )
-        {
-            ++pszName;
-            if( lLen == 7 ) // RGB
-            {
-                const unsigned int R_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int R_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int R = (R_HI << 4) | R_LO;
-                
-                const unsigned int G_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int G_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int G = (G_HI << 4) | G_LO;
-
-                const unsigned int B_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int B_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int B = (B_HI << 4) | B_LO;
-
-                if ( 
-                    (R_HI != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (R_LO != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (G_HI != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (G_LO != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (B_HI != PdfTokenizer::HEX_NOT_FOUND) &&
-                    (B_LO != PdfTokenizer::HEX_NOT_FOUND)
-                    )
-                {
-                    return PdfColor( static_cast<double>(R)/255.0, 
-                                     static_cast<double>(G)/255.0, 
-                                     static_cast<double>(B)/255.0 );
-                }
-                else
-                {
-                    PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-                }
-            }
-            else if( lLen == 9 ) // CMYK
-            {
-                const unsigned int C_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int C_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int C = (C_HI << 4) | C_LO;
-                
-                const unsigned int M_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int M_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int M = (M_HI << 4) | M_LO;
-
-                const unsigned int Y_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int Y_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int Y = (Y_HI << 4) | Y_LO;
-
-                const unsigned int K_HI = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int K_LO = static_cast<unsigned int>(PdfTokenizer::GetHexValue( *pszName++ ));
-                const unsigned int K = (K_HI << 4) | K_LO;
-
-                if ( 
-                    (C_HI != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (C_LO != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (M_HI != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (M_LO != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (Y_HI != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (Y_LO != PdfTokenizer::HEX_NOT_FOUND) && 
-                    (K_HI != PdfTokenizer::HEX_NOT_FOUND) &&
-                    (K_LO != PdfTokenizer::HEX_NOT_FOUND)
-                    )
-                {
-                    return PdfColor( static_cast<double>(C)/255.0, 
-                                     static_cast<double>(M)/255.0, 
-                                     static_cast<double>(Y)/255.0,
-                                     static_cast<double>(K)/255.0 );
-                }
-                else
-                {
-                    PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-                }
-            }
-            
-        }
-        // PdfArray 
-        else if( pszName[0] == '[' ) 
-        {
-            PdfTokenizer tokenizer( pszName, lLen );
-            PdfVariant   var;
-
-            tokenizer.GetNextVariant( var, NULL ); // No encryption...
-            if( var.IsArray() )
-                return PdfColor::FromArray( var.GetArray() );
-        }
-        // it must be a named RGB color
-        else
-        {
-            std::pair<const PdfNamedColor*, const PdfNamedColor*> iterators = 
-                std::equal_range( &(s_NamedColors[0]), 
-                                  s_NamedColors + s_nNumNamedColors, 
-                                  PdfNamedColor( pszName, PdfColor() ), NamedColorComparatorPredicate() );
-            
-            if( iterators.first != iterators.second )
-            {
-                return (*(iterators.first)).GetColor();
-            }
-
-        }
-    }
-
-    return PdfColor();
-}
-
-PdfColor PdfColor::FromArray( const PdfArray & rArray )
-{
-    if( rArray.GetSize() == 1 ) // grayscale
-        return PdfColor( rArray[0].GetReal() );
-    else if( rArray.GetSize() == 3 ) // RGB or spot
-        return PdfColor( rArray[0].GetReal(), rArray[1].GetReal(), rArray[2].GetReal() );
-    else if( rArray.GetSize() == 4 ) // CMYK
-        return PdfColor( rArray[0].GetReal(), rArray[1].GetReal(), rArray[2].GetReal(), rArray[3].GetReal() );
-
-    PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "PdfColor::FromArray supports only GrayScale, RGB and CMYK colors." );
-}
-
-PdfObject* PdfColor::BuildColorSpace( PdfVecObjects* pOwner ) const
-{
-    switch( m_eColorSpace )
-    {
-        case ePdfColorSpace_Separation:
-        {
-            // Build color-spaces for separation
-            PdfObject* csTintFunc = pOwner->CreateObject();
-
-            csTintFunc->GetDictionary().AddKey( "BitsPerSample", static_cast<pdf_int64>(8) );
-
-            PdfArray decode;
-            decode.push_back( static_cast<pdf_int64>(0) );
-            decode.push_back( static_cast<pdf_int64>(1) );
-            decode.push_back( static_cast<pdf_int64>(0) );
-            decode.push_back( static_cast<pdf_int64>(1) );
-            decode.push_back( static_cast<pdf_int64>(0) );
-            decode.push_back( static_cast<pdf_int64>(1) );
-            decode.push_back( static_cast<pdf_int64>(0) );
-            decode.push_back( static_cast<pdf_int64>(1) );
-            csTintFunc->GetDictionary().AddKey( "Decode", decode );
-
-            PdfArray domain;
-            domain.push_back( static_cast<pdf_int64>(0) );
-            domain.push_back( static_cast<pdf_int64>(1) );
-            csTintFunc->GetDictionary().AddKey( "Domain", domain );
-
-            PdfArray encode;
-            encode.push_back( static_cast<pdf_int64>(0) );
-            encode.push_back( static_cast<pdf_int64>(1) );
-            csTintFunc->GetDictionary().AddKey( "Encode", encode );
-
-            csTintFunc->GetDictionary().AddKey( "Filter", PdfName( "FlateDecode" ) );
-            csTintFunc->GetDictionary().AddKey( "FunctionType", PdfVariant( static_cast<pdf_int64>(0L) ) );
-            //csTintFunc->GetDictionary().AddKey( "FunctionType", 
-            //                                    PdfVariant( static_cast<pdf_int64>(ePdfFunctionType_Sampled) ) );
-
-            switch ( m_eAlternateColorSpace )
-            {
-                case ePdfColorSpace_DeviceGray:
-                {
-                    char data[1*2];
-                    data[0] = 0;
-                    data[1] = static_cast<char> (m_uColor.gray);
-
-                    PdfArray range;
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    csTintFunc->GetDictionary().AddKey( "Range", range );
-
-                    PdfArray size;
-                    size.push_back( static_cast<pdf_int64>(2) );
-                    csTintFunc->GetDictionary().AddKey( "Size", size );
-
-                    PdfMemoryInputStream stream( data, 1*2 );
-                    csTintFunc->GetStream()->Set( &stream );
-
-                    PdfArray csArr;
-                    csArr.push_back( PdfName("Separation") );
-                    csArr.push_back( PdfName( m_separationName ) );
-                    csArr.push_back( PdfName("DeviceGray") );
-                    csArr.push_back( csTintFunc->Reference() );
-
-                    PdfObject* csp = pOwner->CreateObject( csArr );
-
-                    return csp;
-                }
-                break;
-
-                case ePdfColorSpace_DeviceRGB:
-                {
-                    char data[3*2];
-                    data[0] =
-                    data[1] =
-                    data[2] = 0;
-                    data[3] = static_cast<char> (m_uColor.rgb[0] * 255);
-                    data[4] = static_cast<char> (m_uColor.rgb[1] * 255);
-                    data[5] = static_cast<char> (m_uColor.rgb[2] * 255);
-
-                    PdfArray range;
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    csTintFunc->GetDictionary().AddKey( "Range", range );
-
-                    PdfArray size;
-                    size.push_back( static_cast<pdf_int64>(2) );
-                    csTintFunc->GetDictionary().AddKey( "Size", size );
-
-                    PdfMemoryInputStream stream( data, 3*2 );
-                    csTintFunc->GetStream()->Set( &stream );
-
-                    PdfArray csArr;
-                    csArr.push_back( PdfName("Separation") );
-                    csArr.push_back( PdfName( m_separationName ) );
-                    csArr.push_back( PdfName("DeviceRGB") );
-                    csArr.push_back( csTintFunc->Reference() );
-
-                    PdfObject* csp = pOwner->CreateObject( csArr );
-
-                    return csp;
-                }
-                break;
-
-                case ePdfColorSpace_DeviceCMYK:
-                {
-                    char data[4*2];
-                    data[0] =
-                    data[1] =
-                    data[2] = 
-                    data[3] = 0;
-                    data[4] = static_cast<char> (m_uColor.cmyk[0] * 255);
-                    data[5] = static_cast<char> (m_uColor.cmyk[1] * 255);
-                    data[6] = static_cast<char> (m_uColor.cmyk[2] * 255);
-                    data[7] = static_cast<char> (m_uColor.cmyk[3] * 255);
-
-                    PdfArray range;
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    csTintFunc->GetDictionary().AddKey( "Range", range );
-
-                    PdfArray size;
-                    size.push_back( static_cast<pdf_int64>(2) );
-                    csTintFunc->GetDictionary().AddKey( "Size", size );
-
-                    PdfArray csArr;
-                    csArr.push_back( PdfName("Separation") );
-                    csArr.push_back( PdfName( m_separationName ) );
-                    csArr.push_back( PdfName("DeviceCMYK") );
-                    csArr.push_back( csTintFunc->Reference() );
-
-                    PdfMemoryInputStream stream( data, 4*2 );
-                    csTintFunc->GetStream()->Set( &stream ); // set stream as last, so that it will work with PdfStreamedDocument
-
-                    PdfObject* csp = pOwner->CreateObject( csArr );
-
-                    return csp;
-                }
-                break;
-
-                case ePdfColorSpace_CieLab:
-                {
-                    char data[3*2];
-                    data[0] =
-                    data[1] =
-                    data[2] = 0;
-                    data[3] = static_cast<char> (m_uColor.lab[0] * 255);
-                    data[4] = static_cast<char> (m_uColor.lab[1] * 255);
-                    data[5] = static_cast<char> (m_uColor.lab[2] * 255);
-
-                    PdfArray range;
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    range.push_back( static_cast<pdf_int64>(0) );
-                    range.push_back( static_cast<pdf_int64>(1) );
-                    csTintFunc->GetDictionary().AddKey( "Range", range );
-
-                    PdfArray size;
-                    size.push_back( static_cast<pdf_int64>(2) );
-                    csTintFunc->GetDictionary().AddKey( "Size", size );
-
-                    PdfMemoryInputStream stream( data, 3*2 );
-                    csTintFunc->GetStream()->Set( &stream );
-
-                    PdfArray csArr;
-                    csArr.push_back( PdfName("Separation") );
-                    csArr.push_back( PdfName( m_separationName ) );
-                    csArr.push_back( PdfName("Lab") );
-                    csArr.push_back( csTintFunc->Reference() );
-
-                    PdfObject* csp = pOwner->CreateObject( csArr );
-
-                    return csp;
-                }
-                break;
-
-                case ePdfColorSpace_Separation:
-                {
-                    break;
-                }
-
-                case ePdfColorSpace_Unknown:
-                default:
-                {
-                    PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-                    break;
-                }
-            }
-        }
-        break;
-
-        case ePdfColorSpace_CieLab:
-        {
-            // Build color-spaces for CIE-lab
-            PdfDictionary labDict;
-
-            // D65-whitepoint
-            PdfArray wpArr;
-            wpArr.push_back( 0.9505 );
-            wpArr.push_back( 1.0000 );
-            wpArr.push_back( 1.0890 );
-            labDict.AddKey( PdfName("WhitePoint" ), wpArr );
-
-            // Range for A,B, L is implicit 0..100
-            PdfArray rangeArr;
-            rangeArr.push_back( static_cast<pdf_int64>(-128) );
-            rangeArr.push_back( static_cast<pdf_int64>(127) );
-            rangeArr.push_back( static_cast<pdf_int64>(-128) );
-            rangeArr.push_back( static_cast<pdf_int64>(127) );
-            labDict.AddKey( PdfName("Range" ), rangeArr );
-
-            PdfArray labArr;
-            labArr.push_back( PdfName("Lab") );
-            labArr.push_back( labDict );
-
-            PdfObject* labp = pOwner->CreateObject( labArr );
-
-            return labp;
-        }
-        break;
-
-        case ePdfColorSpace_DeviceGray:
-        case ePdfColorSpace_DeviceRGB:
-        case ePdfColorSpace_DeviceCMYK:
-        {
-            break;
-        }
-
-        case ePdfColorSpace_Unknown:
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidEnumValue );
-            break;
-        }
-    }
-
-    return NULL;
-}
-
-EPdfColorSpace PdfColor::GetColorSpaceForName( const PdfName & rName )
-{
-    EPdfColorSpace ePdfColorSpace = ePdfColorSpace_Unknown;
-
-    if( PdfName("DeviceGray") == rName ) 
-    {
-        ePdfColorSpace = ePdfColorSpace_DeviceGray;
-    }
-    else if( PdfName("DeviceRGB") == rName ) 
-    {
-        ePdfColorSpace = ePdfColorSpace_DeviceRGB;
-    }
-    else if( PdfName("DeviceCMYK") == rName ) 
-    {
-        ePdfColorSpace = ePdfColorSpace_DeviceCMYK;
-    }
-    else
-    {
-        // TODO: other are not supported at the moment
-        PdfError::LogMessage( eLogSeverity_Information, "Unsupported colorspace name: %s", rName.GetName().c_str() );
-    }
-
-    return ePdfColorSpace;
-}
-    
-PdfName PdfColor::GetNameForColorSpace( EPdfColorSpace eColorSpace )
-{
-    switch( eColorSpace )
-    {
-        case ePdfColorSpace_DeviceGray:
-            return PdfName("DeviceGray");
-        case ePdfColorSpace_DeviceRGB:
-            return PdfName("DeviceRGB");
-        case ePdfColorSpace_DeviceCMYK:
-            return PdfName("DeviceCMYK");
-        case ePdfColorSpace_Separation:
-            return PdfName("Separation");
-        case ePdfColorSpace_CieLab:
-            return PdfName("Lab");
-        case ePdfColorSpace_Unknown:
-        default:
-            PdfError::LogMessage( eLogSeverity_Information, "Unsupported colorspace enum: %i", eColorSpace );
-            return PdfName();
-    }
-    
-}
-
-};
-
--- src/base/PdfCompilerCompat.h.orig	2011-09-30 11:20:59.000000000 +0000
+++ src/base/PdfCompilerCompat.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,184 +0,0 @@
-#ifndef _PDF_COMPILERCOMPAT_H
-#define _PDF_COMPILERCOMPAT_H
-
-//
-// *** THIS HEADER IS INCLUDED BY PdfDefines.h ***
-// *** DO NOT INCLUDE DIRECTLY ***
-#ifndef _PDF_DEFINES_H_
-#error Please include PdfDefines.h instead
-#endif
-
-#include "podofo_config.h"
-
-// Silence some annoying warnings from Visual Studio
-#ifdef _MSC_VER
-#if _MSC_VER <= 1200 // Visual Studio 6
-#pragma warning(disable: 4786)
-#pragma warning(disable: 4251)
-#elif _MSC_VER <= 1400 // Visual Studio 2005
-#pragma warning(disable: 4251)
-#pragma warning(disable: 4275)
-#endif // _MSC_VER
-#endif // _MSC_VER
-
-// Make sure that DEBUG is defined 
-// for debug builds on Windows
-// as Visual Studio defines only _DEBUG
-#ifdef _DEBUG
-#ifndef DEBUG
-#define DEBUG 1
-#endif // DEBUG
-#endif // _DEBUG
-
-
-#if defined(__BORLANDC__) || defined( __TURBOC__)
-#  include <stddef.h>
-#else
-#  include <cstddef>
-#endif
-
-#if defined(TEST_BIG)
-#  define PODOFO_IS_BIG_ENDIAN
-#else
-#  define PODOFO_IS_LITTLE_ENDIAN
-#endif
-
-#if PODOFO_HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
-#if PODOFO_HAVE_BASETSD_H
-#include <BaseTsd.h>
-#endif
-
-#if PODOFO_HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#if PODOFO_HAVE_MEM_H
-#include <mem.h>
-#endif
-
-#if PODOFO_HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-
-#if PODOFO_HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-// alloca() is defined only in <cstdlib> on Mac OS X,
-// only in <malloc.h> on win32, and in both on Linux.
-#if defined(_WIN32)
-#include <malloc.h>
-#endif
-
-// Disable usage of min() and max() macros 
-#if defined(_WIN32) && !defined(__MINGW32__)
-#define NOMINMAX
-#endif
-
-// Integer types - fixed size types guaranteed to work anywhere
-// because we detect the right underlying type name to use with
-// CMake. Use typedefs rather than macros for saner error messages
-// etc.
-namespace PoDoFo {
-    typedef PDF_INT8_TYPENAME  pdf_int8;
-    typedef PDF_INT16_TYPENAME  pdf_int16;
-    typedef PDF_INT32_TYPENAME  pdf_int32;
-    typedef PDF_INT64_TYPENAME  pdf_int64;
-    typedef PDF_UINT8_TYPENAME pdf_uint8;
-    typedef PDF_UINT16_TYPENAME pdf_uint16;
-    typedef PDF_UINT32_TYPENAME pdf_uint32;
-    typedef PDF_UINT64_TYPENAME pdf_uint64;
-};
-#undef PDF_INT8_TYPENAME
-#undef PDF_INT16_TYPENAME
-#undef PDF_INT32_TYPENAME
-#undef PDF_INT64_TYPENAME
-#undef PDF_UINT8_TYPENAME
-#undef PDF_UINT16_TYPENAME
-#undef PDF_UINT32_TYPENAME
-#undef PDF_UINT64_TYPENAME
-
-
-/* 
- * Some elderly compilers, notably VC6, don't support LL literals.
- * In those cases we can use the oversized literal without any suffix.
- */
-#if defined(PODOFO_COMPILER_LACKS_LL_LITERALS)
-#  define PODOFO_LL_LITERAL(x) x
-#  define PODOFO_ULL_LITERAL(x) x
-#else
-#  define PODOFO_LL_LITERAL(x) x##LL
-#  define PODOFO_ULL_LITERAL(x) x##ULL
-#endif
-
-// pdf_long is defined as ptrdiff_t . It's a pointer-sized signed quantity
-// used throughout the code for a variety of purposes.
-//
-// pdf_long is DEPRECATED. Please use one of the explicitly sized types
-// instead, or define a typedef that meaningfully describes what it's for.
-// Good choices in many cases include size_t (string and buffer sizes) and
-// ptrdiff_t (offsets and pointer arithmetic).
-//
-// pdf_long should not be used in new code.
-//
-namespace PoDoFo {
-    typedef ptrdiff_t pdf_long;
-};
-
-
-// Different compilers use different format specifiers for 64-bit integers
-// (yay!).  Use these macros with C's automatic string concatenation to handle
-// that ghastly quirk.
-//
-// for example:   printf("Value of signed 64-bit integer: %"PDF_FORMAT_INT64" (more blah)", 128LL)
-//
-#if defined(_MSC_VER)
-#  define PDF_FORMAT_INT64 "I64d"
-#  define PDF_FORMAT_UINT64 "I64u"
-#else
-#  define PDF_FORMAT_INT64 "lld"
-#  define PDF_FORMAT_UINT64 "llu"
-#endif
-
-
-
-// Different compilers express __FUNC__ in different ways and with different
-// capabilities. Try to find the best option.
-//
-// Note that __LINE__ and __FILE__ are *NOT* included.
-// Further note that you can't use compile-time string concatenation on __FUNC__ and friends
-// on many compilers as they're defined to behave as if they were a:
-//    static const char* __func__ = 'nameoffunction';
-// just after the opening brace of each function.
-//
-#if (defined(_MSC_VER)  &&  _MSC_VER <= 1200)
-#  define PODOFO__FUNCTION__ __FUNCTION__
-#elif defined(__BORLANDC__) || defined(__TURBOC__)
-#  define PODOFO__FUNCTION__ __FUNC__
-#elif defined(__GNUC__)
-#  define PODOFO__FUNCTION__ __PRETTY_FUNCTION__
-#else
-#  define PODOFO__FUNCTION__ __FUNCTION__
-#endif
-
-/**
- * \page PoDoFo PdfCompilerCompat Header
- * 
- * <b>PdfCompilerCompat.h</b> gathers up nastyness required for various
- * compiler compatibility into a central place. All compiler-specific defines,
- * wrappers, and the like should be included here and (if necessary) in
- * PdfCompilerCompat.cpp if they must be visible to public users of the library.
- *
- * If the nasty platform and compiler specific hacks can be kept to PoDoFo's
- * build and need not be visible to users of the library, put them in
- * PdfCompilerCompatPrivate.{cpp,h} instead.
- *
- * Please NEVER use symbols from this header or the PoDoFo::compat namespace in
- * a "using" directive. Always explicitly reference names so it's clear that
- * you're pulling them from the compat cruft.
- */
-
-#endif
--- src/base/PdfDataType.h.orig	2011-10-06 18:37:21.000000000 +0000
+++ src/base/PdfDataType.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,142 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_DATATYPE_H_
-#define _PDF_DATATYPE_H_
-
-#include "PdfDefines.h"
-
-namespace PoDoFo {
-
-class PdfEncrypt;
-class PdfOutputDevice;
-
-/** An interface for all PDF datatype classes.
- *
- *  
- *  \see PdfName \see PdfArray \see PdfReference 
- *  \see PdfVariant \see PdfDictionary \see PdfString
- */
-class PODOFO_API PdfDataType {
-
- protected:
-    /** Create a new PdfDataType.
-     *  Can only be called by subclasses
-     */
-    PdfDataType();
-
- public:
-    virtual ~PdfDataType();
-
-    /** Write the complete datatype to a file.
-     *  \param pDevice write the object to this device
-     *  \param eWriteMode additional options for writing this object
-     *  \param pEncrypt an encryption object which is used to encrypt this object
-     *                  or NULL to not encrypt this object
-     */
-    virtual void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt = NULL ) const = 0;
-
-    /** The dirty flag is set if this variant
-     *  has been modified after construction.
-     *  
-     *  Usually the dirty flag is also set
-     *  if you call any non-const member function
-     *  as we cannot determine if you actually changed 
-     *  something or not.
-     *
-     *  \returns true if the value is dirty and has been 
-     *                modified since construction
-     */
-    virtual bool IsDirty() const;
-
-    /** Sets the dirty flag of this PdfVariant
-     *
-     *  \param bDirty true if this PdfVariant has been
-     *                modified from the outside
-     *
-     *  \see IsDirty
-     */
-    virtual void SetDirty( bool bDirty );
-
-    /**
-     * Sets this object to immutable,
-     * so that no keys can be edited or changed.
-     *
-     * @param bImmutable if true set the object to be immutable
-     *
-     * This is used by PdfImmediateWriter and PdfStreamedDocument so 
-     * that no keys can be added to an object after setting stream data on it.
-     *
-     */
-    inline void SetImmutable(bool bImmutable);
-
-    /**
-     * Retrieve if an object is immutable.
-     *
-     * This is used by PdfImmediateWriter and PdfStreamedDocument so 
-     * that no keys can be added to an object after setting stream data on it.
-     *
-     * @returns true if the object is immutable
-     */
-    inline bool GetImmutable() const;
-
-protected:
-    /**
-     *  Will throw an exception if called on an immutable object,
-     *  so this should be called before actually changing a value!
-     * 
-     */
-    inline void AssertMutable() const;
-
-private:
-    bool m_bImmutable;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfDataType::SetImmutable(bool bImmutable)
-{
-    m_bImmutable = bImmutable;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline bool PdfDataType::GetImmutable() const 
-{
-    return m_bImmutable;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfDataType::AssertMutable() const
-{
-    if(m_bImmutable) 
-    {
-        throw PdfError( ePdfError_ChangeOnImmutable );
-    }
-}
-
-}; // namespace PoDoFo
-
-#endif /* _PDF_DATATYPE_H_ */
-
--- src/base/PdfDate.cpp.orig	2012-12-12 22:54:58.000000000 +0000
+++ src/base/PdfDate.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,194 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfDate.h"
-#include "PdfDefinesPrivate.h"
-
-#include <string.h>
-#include <sstream>
-
-namespace PoDoFo {
-
-PdfDate::PdfDate()
-    : m_bValid( false )
-{
-    m_time = time( &m_time );
-    CreateStringRepresentation();
-}
-
-PdfDate::PdfDate( const time_t & t )
-    : m_bValid( false )
-{
-    m_time = t;
-    CreateStringRepresentation();
-}
-
-PdfDate::PdfDate( const PdfString & sDate )
-    : m_bValid( false )
-{
-    if ( !sDate.IsValid() ) 
-    {
-        m_szDate[0] = 0;
-        return;
-    }
-
-    strncpy(m_szDate,sDate.GetString(),PDF_DATE_BUFFER_SIZE);
-
-    struct tm _tm;
-    memset( &_tm, 0, sizeof(_tm) );
-    int nZoneShift = 0;
-    int nZoneHour = 0;
-    int nZoneMin = 0;
-
-    const char * pszDate = sDate.GetString();
-    if ( pszDate == NULL ) return;
-    if ( *pszDate == 'D' ) {
-        pszDate++;
-        if ( *pszDate++ != ':' ) return;
-    }
-
-    if ( ParseFixLenNumber(pszDate,4,0,9999,_tm.tm_year) == false ) 
-        return;
-
-    _tm.tm_year -= 1900;
-    if ( *pszDate != '\0' ) {
-        if ( ParseFixLenNumber(pszDate,2,1,12,_tm.tm_mon) == false ) 
-            return;
-
-        _tm.tm_mon--;
-        if ( *pszDate != '\0' ) {
-            if ( ParseFixLenNumber(pszDate,2,1,31,_tm.tm_mday) == false ) return;
-            if ( *pszDate != '\0' ) {
-                if ( ParseFixLenNumber(pszDate,2,0,23,_tm.tm_hour) == false ) return;
-                if ( *pszDate != '\0' ) {
-                    if ( ParseFixLenNumber(pszDate,2,0,59,_tm.tm_min) == false ) return;
-                    if ( *pszDate != '\0' ) {
-                        if ( ParseFixLenNumber(pszDate,2,0,59,_tm.tm_sec) == false ) return;
-                        if ( *pszDate != '\0' ) {
-                            switch(*pszDate++) {
-                            case '+':
-                                nZoneShift = -1;
-                                break;
-                            case '-':
-                                nZoneShift = 1;
-                                break;
-                            case 'Z':
-                                nZoneShift = 0;
-                                break;
-                            default:
-                                return;
-                            }
-                            if ( ParseFixLenNumber(pszDate,2,0,59,nZoneHour) == false ) return;
-                            if ( *pszDate == '\'' ) {
-                                pszDate++;
-                                if ( ParseFixLenNumber(pszDate,2,0,59,nZoneMin) == false ) return;
-                                if ( *pszDate != '\'' ) return;
-                                pszDate++;
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    if ( *pszDate != '\0' ) 
-    {
-        return;
-    }
-
-    // convert to 
-    m_time = mktime(&_tm);
-    if ( m_time == -1 ) 
-    {
-        return;
-    }
-
-    m_time += nZoneShift*(nZoneHour*3600 + nZoneMin*60);
-    m_bValid = true;
-}
-
-PdfDate::~PdfDate()
-{
-}
-
-void PdfDate::CreateStringRepresentation()
-{
-    const int   ZONE_STRING_SIZE = 6;
-    const char* INVALIDDATE     = "INVALIDDATE";
-
-    char szZone[ZONE_STRING_SIZE];
-    char szDate[PDF_DATE_BUFFER_SIZE];
-
-    struct tm* stm = localtime( &m_time );
-
-#ifdef _WIN32
-    // On win32, strftime with %z returns a verbose time zone name
-    // like "W. Australia Standard time". We use tzset and timezone
-    // instead.
-    _tzset();
-    snprintf( szZone, ZONE_STRING_SIZE, "%+03d", -_timezone/3600 );
-#else
-    if( strftime( szZone, ZONE_STRING_SIZE, "%z", stm ) == 0 )
-    {
-        std::ostringstream ss;
-        ss << "Generated invalid date from time_t value " << m_time
-           << " (couldn't determine time zone)\n";
-        PdfError::DebugMessage( ss.str().c_str() );
-        strcpy( m_szDate, INVALIDDATE );
-        return;
-    }
-#endif
-
-    // only the first 3 characters are important for the pdf date representation
-    // e.g. +01 instead off +0100
-    szZone[3] = '\0';
-
-    if( strftime( szDate, PDF_DATE_BUFFER_SIZE, "D:%Y%m%d%H%M%S", stm ) == 0 )
-    {
-        std::ostringstream ss;
-        ss << "Generated invalid date from time_t value " << m_time
-           << "\n";
-        PdfError::DebugMessage( ss.str().c_str() );
-        strcpy( m_szDate, INVALIDDATE );
-        return;
-    }
-
-    snprintf( m_szDate, PDF_DATE_BUFFER_SIZE, "%s%s'00'", szDate, szZone );
-    m_bValid = true;
-}
-
-
-bool PdfDate::ParseFixLenNumber(const char *&in, unsigned int length, int min, int max, int &ret)
-{
-    ret = 0;
-    for(unsigned int i=0;i<length;i++)
-    {
-        if ( in == NULL || !isdigit(*in)) return false;
-        ret = ret*10+ (*in-'0');
-        in++;
-    }
-    if ( ret < min || ret > max ) return false;
-    return true;
-}
-
-};
-
-
--- src/base/PdfDate.h.orig	2012-06-04 15:44:36.000000000 +0000
+++ src/base/PdfDate.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,142 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_DATE_H_
-#define _PDF_DATE_H_
-
-#include "PdfDefines.h"
-#include "PdfString.h"
-
-#include <ctime>
-
-// a PDF date has a maximum of 26 bytes incuding the terminating \0
-#define PDF_DATE_BUFFER_SIZE 26
-
-namespace PoDoFo {
-
-/** This class is a date datatype as specified in the PDF 
- *  reference. You can easily convert from Unix time_t to
- *  the PDF time representation and back. Dates like these
- *  are used for example in the PDF info dictionary for the
- *  creation time and date of the PDF file.
- *
- *  PdfDate objects are immutable.
- *
- *  From the PDF reference:
- *
- *  PDF defines a standard date format, which closely follows 
- *  that of the international standard ASN.1 (Abstract Syntax
- *  Notation One), defined in ISO/IEC 8824 (see the Bibliography). 
- *  A date is a string of the form
- *  (D:YYYYMMDDHHmmSSOHH'mm')
- */
-class PODOFO_API PdfDate {
- public:
-    /** Create a PdfDate object with the current date and time.
-     */
-    PdfDate();
-
-    /** Create a PdfDate with a specified date and time
-     *  \param t the date and time of this object
-     *  
-     *  Use IsValid to check wether the time_t could be 
-     *  converted to a valid PdfDate object.
-     *
-     *  \see IsValid()
-     */
-    PdfDate( const time_t & t );
-
-    /** Create a PdfDate with a specified date and time
-     *  \param szDate the date and time of this object 
-     *         in PDF format. It has to be a string of 
-     *         the format  (D:YYYYMMDDHHmmSSOHH'mm').
-     *         Otherwise IsValid will return false.
-     *  
-     *  Use IsValid to check wether the string could be 
-     *  converted to a valid PdfDate object.
-     *
-     *  \see IsValid()
-     */
-    PdfDate( const PdfString & sDate );
-
-    /** Delete the PdfDate object
-     */
-    virtual ~PdfDate();
-
-    /** You can use this function to check wether the date
-     *  you passed to the constructor could be converted to
-     *  a valid pdf date string or a valid time_t.
-     *
-     *  \returns true if the PdfDate object is valid
-     */
-    inline bool IsValid() const;
-
-    /** \returns the date and time of this PdfDate in 
-     *  seconds since epoch.
-     */
-    inline const time_t & GetTime() const;
-
-    /** The value returned by this function can be used in any PdfObject
-     *  where a date is needed.
-     * 
-     *  \param rsString write the date to a PdfString
-     */         
-    inline void ToString( PdfString & rsString ) const;
-
- private:
-    /** Creates the internal string representation from
-     *  a time_t value and writes it to m_szDate.
-     */
-    void CreateStringRepresentation();
-
-    /** Parse fixed length number from string
-     *  \param in string to read number from
-     *  \param length of number to read 
-     *  \param min minimal value of number
-     *  \param max maximal value of number
-     *  \param ret parsed number
-     */
-    bool ParseFixLenNumber(const char *&in, unsigned int length, int min, int max, int &ret);
-
- private:
-    time_t m_time;
-    char   m_szDate[PDF_DATE_BUFFER_SIZE];
-
-    bool   m_bValid;
-};
-
-const time_t & PdfDate::GetTime() const
-{
-    return m_time;
-}
-
-void PdfDate::ToString( PdfString & rsString ) const
-{
-    rsString = PdfString(  m_szDate );
-}
-
-bool PdfDate::IsValid() const
-{
-    return m_bValid;
-}
-
-};
-
-#endif // _PDF_DATE_H_
--- src/base/PdfDictionary.h.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/base/PdfDictionary.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,297 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_DICTIONARY_H_
-#define _PDF_DICTIONARY_H_
-
-#include "PdfDefines.h"
-#include "PdfDataType.h"
-
-#include "PdfName.h"
-#include "PdfObject.h"
-
-/**
- * PODOFO_USE_UNORDERED_MAP
- * 
- * If you set this define, PoDoFo
- * will use std::tr1::unordered_map instead
- * of std::map for PdfDictionary.
- *
- * Some benchmarking tests using callgrind have shown
- * that unordered_map is a little faster for writing and AddKey
- * but of course slower for GetKey and HasKey. As PdfDictionaries
- * are usually very small the difference for GetKey and HasKey is
- * not very large and should therefore be rarely noticeable.
- *
- * By default this define is not set and std::map will be used.
- */
-#ifdef PODOFO_USE_UNORDERED_MAP
-#include <tr1/unordered_map>
-#endif // PODOFO_USE_ORDERED_MAP
-
-namespace PoDoFo {
-
-#ifdef PODOFO_USE_UNORDERED_MAP
-class PdfNameHash : public std::unary_function<PdfName, size_t>
-{
-public:
-    size_t operator()( const PdfName& v ) const
-    {
-        std::tr1::hash<std::string> hasher;
-        
-        return hasher( v.GetName() );
-    }
-};
-
-typedef std::tr1::unordered_map<PdfName,PdfObject*, PdfNameHash>      TKeyMap;
-#else
-typedef std::map<PdfName,PdfObject*>      TKeyMap;
-#endif // PODOFO_USE_UNORDERED_MAP
-
-typedef TKeyMap::iterator                 TIKeyMap;
-typedef TKeyMap::const_iterator           TCIKeyMap;
-
-class PdfOutputDevice;
-
-class PODOFO_API PdfDictionary : public PdfDataType {
- public:
-    /** Create a new, empty dictionary
-     */
-    PdfDictionary();
-
-    /** Deep copy a dictionary
-     *  \param rhs the PdfDictionary to copy
-     */
-    PdfDictionary( const PdfDictionary & rhs );
-
-    /** Destructor
-     */
-    virtual ~PdfDictionary();
-
-    /** Asignment operator.
-     *  Asign another PdfDictionary to this dictionary. This is a deep copy;
-     *  all elements of the source dictionary are duplicated.
-     *
-     *  \param rhs the PdfDictionary to copy.
-     *
-     *  \return this PdfDictionary
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    const PdfDictionary & operator=( const PdfDictionary & rhs );
-
-    /**
-     * Comparison operator. If this dictionary contains all the same keys
-     * as the other dictionary, and for each key the values compare equal,
-     * the dictionaries are considered equal.
-     */
-    bool operator==( const PdfDictionary& rhs ) const;
-
-    /**
-     * \see operator==
-     */
-    inline bool operator!=( const PdfDictionary& rhs ) const;
-
-    /** Removes all keys from the dictionary
-     */
-    void Clear();
-
-    /** Add a key to the dictionary. If an existing key of this name exists, its
-     *  value is replaced and the old value object will be deleted. The passed
-     *  object is copied.
-     *
-     *  \param identifier the key is identified by this name in the dictionary
-     *  \param rObject a variant object containing the data. The object is copied.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    void AddKey( const PdfName & identifier, const PdfObject & rObject );
-
-    /** Add a key to the dictionary. If an existing key of this name exists,
-     *  its value is replaced and the old value object will be deleted. The
-     *  passed object is copied.
-     *
-     *  This is an overloaded member function.
-     *
-     *  \param identifier the key is identified by this name in the dictionary
-     *  \param rObject a variant object containing the data. The object is copied.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    void AddKey( const PdfName & identifier, const PdfObject* pObject );
-
-    /** Get the keys value out of the dictionary.
-     *
-     * The returned value is a pointer to the internal object in the dictionary
-     * so it MUST not be deleted.
-     *
-     *  \param key look for the key names pszKey in the dictionary
-     * 
-     *  \returns pointer to the found value or 0 if the key was not found.
-     */
-    const PdfObject* GetKey( const PdfName & key ) const;
-
-    /** Get the keys value out of the dictionary.  This is an overloaded member
-     * function.
-     *
-     * The returned value is a pointer to the internal object in the dictionary.
-     * It may be modified but is still owned by the dictionary so it MUST not
-     * be deleted.
-     *
-     *  \param key look for the key named key in the dictionary
-     * 
-     *  \returns the found value or 0 if the key was not found.
-     */
-    PdfObject* GetKey( const PdfName & key );
-
-    long long GetKeyAsLong( const PdfName & key, long long lDefault = 0 ) const;
-
-    double GetKeyAsReal( const PdfName & key, double dDefault = 0.0 ) const;
-
-    bool GetKeyAsBool( const PdfName & key, bool bDefault = false ) const;
-
-    PdfName GetKeyAsName( const PdfName & key ) const;
-
-    /** Allows to check if a dictionary contains a certain key.  \param key
-     * look for the key named key.Name() in the dictionary
-     *
-     *  \returns true if the key is part of the dictionary, otherwise false.
-     */
-    bool  HasKey( const PdfName & key  ) const;
-
-    /** Remove a key from this dictionary.  If the key does not exists, this
-     * function does nothing.
-     *
-     *  \param identifier the name of the key to delete
-     * 
-     *  \returns true if the key was found in the object and was removed if
-     *  there was is no key with this name, false is returned.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    bool RemoveKey( const PdfName & identifier );
-
-    /** Write the complete dictionary to a file.  \param pDevice write the
-     * object to this device \returns ErrOk on success
-     *
-     *  \param pDevice write the object to this device
-     *  \param eWriteMode additional options for writing this object
-     *  \param pEncrypt an encryption object which is used to encrypt this object
-     *                  or NULL to not encrypt this object
-     */
-    inline void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt = NULL ) const;
-
-    /** Write the complete dictionary to a file.  \param pDevice write the
-     * object to this device \param keyStop if not KeyNull and a key == keyStop
-     * is found writing will stop right before this key!  \returns ErrOk on
-     * success
-     *
-     *  \param pDevice write the object to this device
-     *  \param eWriteMode additional options for writing this object
-     *  \param pEncrypt an encryption object which is used to encrypt this object
-     *                  or NULL to not encrypt this object
-     *  \param keyStop if not KeyNull and a key == keyStop is found
-     *                 writing will stop right before this key!
-     */
-    void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, 
-                const PdfEncrypt* pEncrypt, const PdfName & keyStop = PdfName::KeyNull ) const;
-
-    /** Get access to the internal map of keys.
-     *
-     * \returns all keys of this dictionary
-     */
-    inline const TKeyMap & GetKeys() const;
-
-    /** Get access to the internal map of keys.  \returns all keys of this
-     *  dictionary
-     */
-    inline TKeyMap & GetKeys();
-
-    /** The dirty flag is set if this variant
-     *  has been modified after construction.
-     *  
-     *  Usually the dirty flag is also set
-     *  if you call any non-const member function
-     *  as we cannot determine if you actually changed 
-     *  something or not.
-     *
-     *  \returns true if the value is dirty and has been 
-     *                modified since construction
-     */
-    virtual bool IsDirty() const;
-
-    /** Sets the dirty flag of this PdfVariant
-     *
-     *  \param bDirty true if this PdfVariant has been
-     *                modified from the outside
-     *
-     *  \see IsDirty
-     */
-    virtual void SetDirty( bool bDirty );
-
- private: 
-    TKeyMap      m_mapKeys; 
-
-    bool         m_bDirty; ///< Indicates if this object was modified after construction
-};
-
-typedef std::vector<PdfDictionary*>      TVecDictionaries; 
-typedef	TVecDictionaries::iterator       TIVecDictionaries; 
-typedef	TVecDictionaries::const_iterator TCIVecDictionaries;
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const TKeyMap & PdfDictionary::GetKeys() const 
-{ 
-    return m_mapKeys; 
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-TKeyMap & PdfDictionary::GetKeys() 
-{ 
-    return m_mapKeys; 
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfDictionary::Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt ) const 
-{ 
-    this->Write( pDevice, eWriteMode, pEncrypt, PdfName::KeyNull ); 
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfDictionary::operator!=( const PdfDictionary& rhs ) const
-{
-    return !(*this == rhs);
-}
-
-};
-
-#endif // _PDF_DICTIONARY_H_
--- src/base/PdfEncoding.cpp.orig	2011-02-12 11:55:40.000000000 +0000
+++ src/base/PdfEncoding.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1761 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfEncoding.h"
-
-#include "PdfDictionary.h"
-#include "PdfLocale.h"
-#include "util/PdfMutexWrapper.h"
-#include "PdfDefinesPrivate.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <sstream>
-
-namespace PoDoFo {
-
-PdfEncoding::PdfEncoding( int nFirstChar, int nLastChar )
-    : m_nFirstChar( nFirstChar ), m_nLastChar( nLastChar )
-{
-    if( !(m_nFirstChar < m_nLastChar) )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange, "PdfEncoding: nFirstChar must be smaller than nLastChar" ); 
-    }
-}
-
-PdfEncoding::~PdfEncoding()
-{
-
-}
-
-// -----------------------------------------------------
-// PdfSimpleEncoding
-// -----------------------------------------------------
-PdfSimpleEncoding::PdfSimpleEncoding( const PdfName & rName )
-    : PdfEncoding( 0, 255 ), m_mutex( new PoDoFo::Util::PdfMutex() ), m_name( rName ), m_pEncodingTable( NULL )
-{
-}
-
-PdfSimpleEncoding::~PdfSimpleEncoding() 
-{
-    free( m_pEncodingTable );
-    delete m_mutex;
-}
-
-void PdfSimpleEncoding::InitEncodingTable() 
-{
-    Util::PdfMutexWrapper wrapper( *m_mutex );
-    const long         lTableLength     = 0xffff;
-    const pdf_utf16be* cpUnicodeTable   = this->GetToUnicodeTable();
-
-    if( !m_pEncodingTable ) // double check
-    {
-        m_pEncodingTable = static_cast<char*>(malloc(sizeof(char)*lTableLength));
-    
-        // fill the table with 0
-        memset( m_pEncodingTable, 0, lTableLength * sizeof(char) ); 
-        // fill the table with data
-        for( size_t i=0; i<256; i++ )
-        {
-            m_pEncodingTable[ static_cast<size_t>(cpUnicodeTable[i]) ] = 
-                static_cast<unsigned char>(i);
-        }
-    }
-}
-
-void PdfSimpleEncoding::AddToDictionary( PdfDictionary & rDictionary ) const
-{
-    rDictionary.AddKey( PdfName("Encoding"), m_name );
-}
-
-pdf_utf16be PdfSimpleEncoding::GetCharCode( int nIndex ) const
-{
-    if( nIndex < this->GetFirstChar() ||
-        nIndex > this->GetLastChar() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-    }
-
-    const pdf_utf16be* cpUnicodeTable   = this->GetToUnicodeTable();
-
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    return ((cpUnicodeTable[nIndex] & 0xff00) >> 8) | ((cpUnicodeTable[nIndex] & 0xff) << 8);
-#else
-    return cpUnicodeTable[nIndex];
-#endif // PODOFO_IS_LITTLE_ENDIAN
-
-}
-
-PdfString PdfSimpleEncoding::ConvertToUnicode( const PdfString & rEncodedString, const PdfFont* ) const
-{
-    const pdf_utf16be* cpUnicodeTable = this->GetToUnicodeTable();
-    pdf_long           lLen           = rEncodedString.GetLength();
-
-    if( lLen  <= 0 )
-        return PdfString("");
-
-    pdf_utf16be* pszStringUtf16 = static_cast<pdf_utf16be*>(malloc(sizeof(pdf_utf16be) * (lLen + 1)) );
-    if( !pszStringUtf16 ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-
-    const char* pszString = rEncodedString.GetString();
-    for( int i=0;i<lLen;i++ )
-    {
-#ifdef PODOFO_IS_BIG_ENDIAN
-        pszStringUtf16[i] = cpUnicodeTable[ static_cast<unsigned char>(*pszString) ];
-#else
-        pszStringUtf16[i] =             
-            ((( cpUnicodeTable[ static_cast<unsigned char>(*pszString) ] << 8 ) & 0xff00) | 
-             (( cpUnicodeTable[ static_cast<unsigned char>(*pszString) ] >> 8 ) & 0x00ff));
-#endif // PODOFO_IS_BIG_ENDIAN
-        ++pszString;
-    }
-
-    pszStringUtf16[lLen] = 0;
-
-    PdfString sStr( pszStringUtf16 );
-    free( pszStringUtf16 );
-    
-    return sStr;
-}
-
-PdfRefCountedBuffer PdfSimpleEncoding::ConvertToEncoding( const PdfString & rString, const PdfFont* ) const
-{
-    if( !m_pEncodingTable )
-        const_cast<PdfSimpleEncoding*>(this)->InitEncodingTable();
-
-    PdfString sSrc = rString.ToUnicode(); // make sure the string is unicode and not PdfDocEncoding!
-    pdf_long  lLen = sSrc.GetCharacterLength();
-
-    if( !lLen )
-        return PdfRefCountedBuffer();
-
-    char* pDest = static_cast<char*>(malloc( sizeof(char) * (lLen + 1) ));
-    if( !pDest ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-        
-    const pdf_utf16be* pszUtf16 = sSrc.GetUnicode();
-    char*              pCur     = pDest;
-    long               lNewLen  = 0L;
-
-    for( int i=0;i<lLen;i++ ) 
-    {
-        pdf_utf16be val = pszUtf16[i];
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-        val = ((val & 0xff00) >> 8) | ((val & 0xff) << 8);
-#endif // PODOFO_IS_LITTLE_ENDIAN
-
-        *pCur = m_pEncodingTable[val]; 
-        if( *pCur ) // ignore 0 characters, as they cannot be converted to the current encoding
-        {
-            ++pCur; 
-            ++lNewLen;
-        }
-    }
-    
-    *pCur = '\0';
-    
-
-    PdfRefCountedBuffer cDest( lNewLen );
-    memcpy( cDest.GetBuffer(), pDest, lNewLen );
-    free( pDest );
-
-    return cDest;
-}
-
-// -----------------------------------------------------
-// PdfDocEncoding
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfDocEncoding::GetToUnicodeTable() const
-{
-    return PdfDocEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfDocEncoding::s_cEncoding[256] = {
-    0x0000,
-    0x0001,
-    0x0002,
-    0x0003,
-    0x0004,
-    0x0005,
-    0x0006,
-    0x0007,
-    0x0008,
-    0x0009,
-    0x000A,
-    0x000B,
-    0x000C,
-    0x000D,
-    0x000E,
-    0x000F,
-    0x0010,
-    0x0011,
-    0x0012,
-    0x0013,
-    0x0014,
-    0x0015,
-    0x0017,
-    0x0017,
-    0x02D8,
-    0x02C7, // dec 25
-    0x02C6,
-    0x02D9,
-    0x02DD,
-    0x02DB,
-    0x02DA,
-    0x02DC,
-    0x0020,
-    0x0021,
-    0x0022,
-    0x0023,
-    0x0024,
-    0x0025,
-    0x0026,
-    0x0027,
-    0x0028,
-    0x0029,
-    0x002A,
-    0x002B,
-    0x002C,
-    0x002D,
-    0x002E,
-    0x002F,
-    0x0030,
-    0x0031,
-    0x0032,
-    0x0033,
-    0x0034,
-    0x0035,
-    0x0036,
-    0x0037,
-    0x0038,
-    0x0039, // dec 57 
-    0x003A,
-    0x003B,
-    0x003C,
-    0x003D,
-    0x003E,
-    0x003F,
-    0x0040,
-    0x0041,
-    0x0042,
-    0x0043,
-    0x0044,
-    0x0045,
-    0x0046,
-    0x0047,
-    0x0048,
-    0x0049,
-    0x004A,
-    0x004B,
-    0x004C,
-    0x004D,
-    0x004E,
-    0x004F,
-    0x0050,
-    0x0051,
-    0x0052,
-    0x0053,
-    0x0054,
-    0x0055,
-    0x0056,
-    0x0057,
-    0x0058,
-    0x0059, // 89
-    0x005A,
-    0x005B,
-    0x005C,
-    0x005D,
-    0x005E,
-    0x005F,
-    0x0060,
-    0x0061,
-    0x0062,
-    0x0063,
-    0x0064,
-    0x0065,
-    0x0066,
-    0x0067,
-    0x0068,
-    0x0069,
-    0x006A,
-    0x006B,
-    0x006C,
-    0x006D,
-    0x006E,
-    0x006F,
-    0x0070,
-    0x0071,
-    0x0072,
-    0x0073,
-    0x0074,
-    0x0075,
-    0x0076,
-    0x0077,
-    0x0078,
-    0x0079, //121 
-    0x007A,
-    0x007B,
-    0x007C,
-    0x007D,
-    0x007E,
-    0x0000, // Undefined
-    0x2022,
-    0x2020,
-    0x2021,
-    0x2026,
-    0x2014,
-    0x2013,
-    0x0192,
-    0x2044,
-    0x2039,
-    0x203A,
-    0x2212,
-    0x2030,
-    0x201E,
-    0x201C,
-    0x201D,
-    0x2018,
-    0x2019,
-    0x201A,
-    0x2122,
-    0xFB01, // dec147 
-    0xFB02,
-    0x0141,
-    0x0152,
-    0x0160,
-    0x0178,
-    0x017D,
-    0x0131,
-    0x0142,
-    0x0153,
-    0x0161,
-    0x017E,
-    0x0000, // Undefined
-    0x20AC, // Euro
-    0x00A1,
-    0x00A2,
-    0x00A3,
-    0x00A4,
-    0x00A5,
-    0x00A6,
-    0x00A7,
-    0x00A8,
-    0x00A9,
-    0x00AA,
-    0x00AB,
-    0x00AC,
-    0x0000, // Undefined
-    0x00AE,
-    0x00AF,
-    0x00B0,
-    0x00B1,
-    0x00B2,
-    0x00B3,
-    0x00B4,
-    0x00B5,
-    0x00B6,
-    0x00B7,
-    0x00B8,
-    0x00B9,
-    0x00BA,
-    0x00BB,
-    0x00BC,
-    0x00BD,
-    0x00BE,
-    0x00BF,
-    0x00C0,
-    0x00C1,
-    0x00C2,
-    0x00C3,
-    0x00C4,
-    0x00C5,
-    0x00C6,
-    0x00C7,
-    0x00C8,
-    0x00C9,
-    0x00CA,
-    0x00CB,
-    0x00CC,
-    0x00CD,
-    0x00CE,
-    0x00CF,
-    0x00D0,
-    0x00D1,
-    0x00D2,
-    0x00D3,
-    0x00D4,
-    0x00D5,
-    0x00D6,
-    0x00D7,
-    0x00D8,
-    0x00D9,
-    0x00DA,
-    0x00DB,
-    0x00DC,
-    0x00DD,
-    0x00DE,
-    0x00DF,
-    0x00E0,
-    0x00E1,
-    0x00E2,
-    0x00E3,
-    0x00E4,
-    0x00E5,
-    0x00E6,
-    0x00E7,
-    0x00E8,
-    0x00E9,
-    0x00EA,
-    0x00EB,
-    0x00EC,
-    0x00ED,
-    0x00EE,
-    0x00EF,
-    0x00F0,
-    0x00F1,
-    0x00F2,
-    0x00F3,
-    0x00F4,
-    0x00F5,
-    0x00F6,
-    0x00F7,
-    0x00F8,
-    0x00F9,
-    0x00FA,
-    0x00FB,
-    0x00FC,
-    0x00FD,
-    0x00FE,
-    0x00FF
-};
-
-// -----------------------------------------------------
-// PdfWinAnsiEncoding
-// See: http://www.microsoft.com/globaldev/reference/sbcs/1252.mspx
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfWinAnsiEncoding::GetToUnicodeTable() const
-{
-    return PdfWinAnsiEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfWinAnsiEncoding::s_cEncoding[256] = {
-    0x0000, // NULL
-    0x0001, // START OF HEADING
-    0x0002, // START OF TEXT
-    0x0003, // END OF TEXT
-    0x0004, // END OF TRANSMISSION
-    0x0005, // ENQUIRY
-    0x0006, // ACKNOWLEDGE
-    0x0007, // BELL
-    0x0008, // BACKSPACE
-    0x0009, // HORIZONTAL TABULATION
-    0x000A, // LINE FEED
-    0x000B, // VERTICAL TABULATION
-    0x000C, // FORM FEED
-    0x000D, // CARRIAGE RETURN
-    0x000E, // SHIFT OUT
-    0x000F, // SHIFT IN
-    0x0010, // DATA LINK ESCAPE
-    0x0011, // DEVICE CONTROL ONE
-    0x0012, // DEVICE CONTROL TWO
-    0x0013, // DEVICE CONTROL THREE
-    0x0014, // DEVICE CONTROL FOUR
-    0x0015, // NEGATIVE ACKNOWLEDGE
-    0x0016, // SYNCHRONOUS IDLE
-    0x0017, // END OF TRANSMISSION BLOCK
-    0x0018, // CANCEL
-    0x0019, // END OF MEDIUM
-    0x001A, // SUBSTITUTE
-    0x001B, // ESCAPE
-    0x001C, // FILE SEPARATOR
-    0x001D, // GROUP SEPARATOR
-    0x001E, // RECORD SEPARATOR
-    0x001F, // UNIT SEPARATOR
-    0x0020, // SPACE
-    0x0021, // EXCLAMATION MARK
-    0x0022, // QUOTATION MARK
-    0x0023, // NUMBER SIGN
-    0x0024, // DOLLAR SIGN
-    0x0025, // PERCENT SIGN
-    0x0026, // AMPERSAND
-    0x0027, // APOSTROPHE
-    0x0028, // LEFT PARENTHESIS
-    0x0029, // RIGHT PARENTHESIS
-    0x002A, // ASTERISK
-    0x002B, // PLUS SIGN
-    0x002C, // COMMA
-    0x002D, // HYPHEN-MINUS
-    0x002E, // FULL STOP
-    0x002F, // SOLIDUS
-    0x0030, // DIGIT ZERO
-    0x0031, // DIGIT ONE
-    0x0032, // DIGIT TWO
-    0x0033, // DIGIT THREE
-    0x0034, // DIGIT FOUR
-    0x0035, // DIGIT FIVE
-    0x0036, // DIGIT SIX
-    0x0037, // DIGIT SEVEN
-    0x0038, // DIGIT EIGHT
-    0x0039, // DIGIT NINE
-    0x003A, // COLON
-    0x003B, // SEMICOLON
-    0x003C, // LESS-THAN SIGN
-    0x003D, // EQUALS SIGN
-    0x003E, // GREATER-THAN SIGN
-    0x003F, // QUESTION MARK
-    0x0040, // COMMERCIAL AT
-    0x0041, // LATIN CAPITAL LETTER A
-    0x0042, // LATIN CAPITAL LETTER B
-    0x0043, // LATIN CAPITAL LETTER C
-    0x0044, // LATIN CAPITAL LETTER D
-    0x0045, // LATIN CAPITAL LETTER E
-    0x0046, // LATIN CAPITAL LETTER F
-    0x0047, // LATIN CAPITAL LETTER G
-    0x0048, // LATIN CAPITAL LETTER H
-    0x0049, // LATIN CAPITAL LETTER I
-    0x004A, // LATIN CAPITAL LETTER J
-    0x004B, // LATIN CAPITAL LETTER K
-    0x004C, // LATIN CAPITAL LETTER L
-    0x004D, // LATIN CAPITAL LETTER M
-    0x004E, // LATIN CAPITAL LETTER N
-    0x004F, // LATIN CAPITAL LETTER O
-    0x0050, // LATIN CAPITAL LETTER P
-    0x0051, // LATIN CAPITAL LETTER Q
-    0x0052, // LATIN CAPITAL LETTER R
-    0x0053, // LATIN CAPITAL LETTER S
-    0x0054, // LATIN CAPITAL LETTER T
-    0x0055, // LATIN CAPITAL LETTER U
-    0x0056, // LATIN CAPITAL LETTER V
-    0x0057, // LATIN CAPITAL LETTER W
-    0x0058, // LATIN CAPITAL LETTER X
-    0x0059, // LATIN CAPITAL LETTER Y
-    0x005A, // LATIN CAPITAL LETTER Z
-    0x005B, // LEFT SQUARE BRACKET
-    0x005C, // REVERSE SOLIDUS
-    0x005D, // RIGHT SQUARE BRACKET
-    0x005E, // CIRCUMFLEX ACCENT
-    0x005F, // LOW LINE
-    0x0060, // GRAVE ACCENT
-    0x0061, // LATIN SMALL LETTER A
-    0x0062, // LATIN SMALL LETTER B
-    0x0063, // LATIN SMALL LETTER C
-    0x0064, // LATIN SMALL LETTER D
-    0x0065, // LATIN SMALL LETTER E
-    0x0066, // LATIN SMALL LETTER F
-    0x0067, // LATIN SMALL LETTER G
-    0x0068, // LATIN SMALL LETTER H
-    0x0069, // LATIN SMALL LETTER I
-    0x006A, // LATIN SMALL LETTER J
-    0x006B, // LATIN SMALL LETTER K
-    0x006C, // LATIN SMALL LETTER L
-    0x006D, // LATIN SMALL LETTER M
-    0x006E, // LATIN SMALL LETTER N
-    0x006F, // LATIN SMALL LETTER O
-    0x0070, // LATIN SMALL LETTER P
-    0x0071, // LATIN SMALL LETTER Q
-    0x0072, // LATIN SMALL LETTER R
-    0x0073, // LATIN SMALL LETTER S
-    0x0074, // LATIN SMALL LETTER T
-    0x0075, // LATIN SMALL LETTER U
-    0x0076, // LATIN SMALL LETTER V
-    0x0077, // LATIN SMALL LETTER W
-    0x0078, // LATIN SMALL LETTER X
-    0x0079, // LATIN SMALL LETTER Y
-    0x007A, // LATIN SMALL LETTER Z
-    0x007B, // LEFT CURLY BRACKET
-    0x007C, // VERTICAL LINE
-    0x007D, // RIGHT CURLY BRACKET
-    0x007E, // TILDE
-    0x007F, // DELETE
-    0x20AC, // EURO SIGN
-    0x0000,
-    0x201A, // SINGLE LOW-9 QUOTATION MARK
-    0x0192, // LATIN SMALL LETTER F WITH HOOK
-    0x201E, // DOUBLE LOW-9 QUOTATION MARK
-    0x2026, // HORIZONTAL ELLIPSIS
-    0x2020, // DAGGER
-    0x2021, // DOUBLE DAGGER
-    0x02C6, // MODIFIER LETTER CIRCUMFLEX ACCENT
-    0x2030, // PER MILLE SIGN
-    0x0160, // LATIN CAPITAL LETTER S WITH CARON
-    0x2039, // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-    0x0152, // LATIN CAPITAL LIGATURE OE
-    0x0000,
-    0x017D, // LATIN CAPITAL LETTER Z WITH CARON
-    0x0000, 
-    0x0000,
-    0x2018, // LEFT SINGLE QUOTATION MARK
-    0x2019, // RIGHT SINGLE QUOTATION MARK
-    0x201C, // LEFT DOUBLE QUOTATION MARK
-    0x201D, // RIGHT DOUBLE QUOTATION MARK
-    0x2022, // BULLET
-    0x2013, // EN DASH
-    0x2014, // EM DASH
-    0x02DC, // SMALL TILDE
-    0x2122, // TRADE MARK SIGN
-    0x0161, // LATIN SMALL LETTER S WITH CARON
-    0x203A, // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-    0x0153, // LATIN SMALL LIGATURE OE
-    0x0000,
-    0x017E, // LATIN SMALL LETTER Z WITH CARON
-    0x0178, // LATIN CAPITAL LETTER Y WITH DIAERESIS
-    0x00A0, // NO-BREAK SPACE
-    0x00A1, // INVERTED EXCLAMATION MARK
-    0x00A2, // CENT SIGN
-    0x00A3, // POUND SIGN
-    0x00A4, // CURRENCY SIGN
-    0x00A5, // YEN SIGN
-    0x00A6, // BROKEN BAR
-    0x00A7, // SECTION SIGN
-    0x00A8, // DIAERESIS
-    0x00A9, // COPYRIGHT SIGN
-    0x00AA, // FEMININE ORDINAL INDICATOR
-    0x00AB, // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-    0x00AC, // NOT SIGN
-    0x00AD, // SOFT HYPHEN
-    0x00AE, // REGISTERED SIGN
-    0x00AF, // MACRON
-    0x00B0, // DEGREE SIGN
-    0x00B1, // PLUS-MINUS SIGN
-    0x00B2, // SUPERSCRIPT TWO
-    0x00B3, // SUPERSCRIPT THREE
-    0x00B4, // ACUTE ACCENT
-    0x00B5, // MICRO SIGN
-    0x00B6, // PILCROW SIGN
-    0x00B7, // MIDDLE DOT
-    0x00B8, // CEDILLA
-    0x00B9, // SUPERSCRIPT ONE
-    0x00BA, // MASCULINE ORDINAL INDICATOR
-    0x00BB, // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-    0x00BC, // VULGAR FRACTION ONE QUARTER
-    0x00BD, // VULGAR FRACTION ONE HALF
-    0x00BE, // VULGAR FRACTION THREE QUARTERS
-    0x00BF, // INVERTED QUESTION MARK
-    0x00C0, // LATIN CAPITAL LETTER A WITH GRAVE
-    0x00C1, // LATIN CAPITAL LETTER A WITH ACUTE
-    0x00C2, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-    0x00C3, // LATIN CAPITAL LETTER A WITH TILDE
-    0x00C4, // LATIN CAPITAL LETTER A WITH DIAERESIS
-    0x00C5, // LATIN CAPITAL LETTER A WITH RING ABOVE
-    0x00C6, // LATIN CAPITAL LETTER AE
-    0x00C7, // LATIN CAPITAL LETTER C WITH CEDILLA
-    0x00C8, // LATIN CAPITAL LETTER E WITH GRAVE
-    0x00C9, // LATIN CAPITAL LETTER E WITH ACUTE
-    0x00CA, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-    0x00CB, // LATIN CAPITAL LETTER E WITH DIAERESIS
-    0x00CC, // LATIN CAPITAL LETTER I WITH GRAVE
-    0x00CD, // LATIN CAPITAL LETTER I WITH ACUTE
-    0x00CE, // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-    0x00CF, // LATIN CAPITAL LETTER I WITH DIAERESIS
-    0x00D0, // LATIN CAPITAL LETTER ETH
-    0x00D1, // LATIN CAPITAL LETTER N WITH TILDE
-    0x00D2, // LATIN CAPITAL LETTER O WITH GRAVE
-    0x00D3, // LATIN CAPITAL LETTER O WITH ACUTE
-    0x00D4, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-    0x00D5, // LATIN CAPITAL LETTER O WITH TILDE
-    0x00D6, // LATIN CAPITAL LETTER O WITH DIAERESIS
-    0x00D7, // MULTIPLICATION SIGN
-    0x00D8, // LATIN CAPITAL LETTER O WITH STROKE
-    0x00D9, // LATIN CAPITAL LETTER U WITH GRAVE
-    0x00DA, // LATIN CAPITAL LETTER U WITH ACUTE
-    0x00DB, // LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-    0x00DC, // LATIN CAPITAL LETTER U WITH DIAERESIS
-    0x00DD, // LATIN CAPITAL LETTER Y WITH ACUTE
-    0x00DE, // LATIN CAPITAL LETTER THORN
-    0x00DF, // LATIN SMALL LETTER SHARP S
-    0x00E0, // LATIN SMALL LETTER A WITH GRAVE
-    0x00E1, // LATIN SMALL LETTER A WITH ACUTE
-    0x00E2, // LATIN SMALL LETTER A WITH CIRCUMFLEX
-    0x00E3, // LATIN SMALL LETTER A WITH TILDE
-    0x00E4, // LATIN SMALL LETTER A WITH DIAERESIS
-    0x00E5, // LATIN SMALL LETTER A WITH RING ABOVE
-    0x00E6, // LATIN SMALL LETTER AE
-    0x00E7, // LATIN SMALL LETTER C WITH CEDILLA
-    0x00E8, // LATIN SMALL LETTER E WITH GRAVE
-    0x00E9, // LATIN SMALL LETTER E WITH ACUTE
-    0x00EA, // LATIN SMALL LETTER E WITH CIRCUMFLEX
-    0x00EB, // LATIN SMALL LETTER E WITH DIAERESIS
-    0x00EC, // LATIN SMALL LETTER I WITH GRAVE
-    0x00ED, // LATIN SMALL LETTER I WITH ACUTE
-    0x00EE, // LATIN SMALL LETTER I WITH CIRCUMFLEX
-    0x00EF, // LATIN SMALL LETTER I WITH DIAERESIS
-    0x00F0, // LATIN SMALL LETTER ETH
-    0x00F1, // LATIN SMALL LETTER N WITH TILDE
-    0x00F2, // LATIN SMALL LETTER O WITH GRAVE
-    0x00F3, // LATIN SMALL LETTER O WITH ACUTE
-    0x00F4, // LATIN SMALL LETTER O WITH CIRCUMFLEX
-    0x00F5, // LATIN SMALL LETTER O WITH TILDE
-    0x00F6, // LATIN SMALL LETTER O WITH DIAERESIS
-    0x00F7, // DIVISION SIGN
-    0x00F8, // LATIN SMALL LETTER O WITH STROKE
-    0x00F9, // LATIN SMALL LETTER U WITH GRAVE
-    0x00FA, // LATIN SMALL LETTER U WITH ACUTE
-    0x00FB, // LATIN SMALL LETTER U WITH CIRCUMFLEX
-    0x00FC, // LATIN SMALL LETTER U WITH DIAERESIS
-    0x00FD, // LATIN SMALL LETTER Y WITH ACUTE
-    0x00FE, // LATIN SMALL LETTER THORN
-    0x00FF, // LATIN SMALL LETTER Y WITH DIAERESIS
-};
-
-// -----------------------------------------------------
-// PdfMacRomanEncoding
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfMacRomanEncoding::GetToUnicodeTable() const
-{
-    return PdfMacRomanEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfMacRomanEncoding::s_cEncoding[256] = {
-    0x0000, // NULL
-    0x0001, // START OF HEADING
-    0x0002, // START OF TEXT
-    0x0003, // END OF TEXT
-    0x0004, // END OF TRANSMISSION
-    0x0005, // ENQUIRY
-    0x0006, // ACKNOWLEDGE
-    0x0007, // BELL
-    0x0008, // BACKSPACE
-    0x0009, // HORIZONTAL TABULATION
-    0x000A, // LINE FEED
-    0x000B, // VERTICAL TABULATION
-    0x000C, // FORM FEED
-    0x000D, // CARRIAGE RETURN
-    0x000E, // SHIFT OUT
-    0x000F, // SHIFT IN
-    0x0010, // DATA LINK ESCAPE
-    0x0011, // DEVICE CONTROL ONE
-    0x0012, // DEVICE CONTROL TWO
-    0x0013, // DEVICE CONTROL THREE
-    0x0014, // DEVICE CONTROL FOUR
-    0x0015, // NEGATIVE ACKNOWLEDGE
-    0x0016, // SYNCHRONOUS IDLE
-    0x0017, // END OF TRANSMISSION BLOCK
-    0x0018, // CANCEL
-    0x0019, // END OF MEDIUM
-    0x001A, // SUBSTITUTE
-    0x001B, // ESCAPE
-    0x001C, // FILE SEPARATOR
-    0x001D, // GROUP SEPARATOR
-    0x001E, // RECORD SEPARATOR
-    0x001F, // UNIT SEPARATOR
-    0x0020, // SPACE
-    0x0021, // EXCLAMATION MARK
-    0x0022, // QUOTATION MARK
-    0x0023, // NUMBER SIGN
-    0x0024, // DOLLAR SIGN
-    0x0025, // PERCENT SIGN
-    0x0026, // AMPERSAND
-    0x0027, // APOSTROPHE
-    0x0028, // LEFT PARENTHESIS
-    0x0029, // RIGHT PARENTHESIS
-    0x002A, // ASTERISK
-    0x002B, // PLUS SIGN
-    0x002C, // COMMA
-    0x002D, // HYPHEN-MINUS
-    0x002E, // FULL STOP
-    0x002F, // SOLIDUS
-    0x0030, // DIGIT ZERO
-    0x0031, // DIGIT ONE
-    0x0032, // DIGIT TWO
-    0x0033, // DIGIT THREE
-    0x0034, // DIGIT FOUR
-    0x0035, // DIGIT FIVE
-    0x0036, // DIGIT SIX
-    0x0037, // DIGIT SEVEN
-    0x0038, // DIGIT EIGHT
-    0x0039, // DIGIT NINE
-    0x003A, // COLON
-    0x003B, // SEMICOLON
-    0x003C, // LESS-THAN SIGN
-    0x003D, // EQUALS SIGN
-    0x003E, // GREATER-THAN SIGN
-    0x003F, // QUESTION MARK
-    0x0040, // COMMERCIAL AT
-    0x0041, // LATIN CAPITAL LETTER A
-    0x0042, // LATIN CAPITAL LETTER B
-    0x0043, // LATIN CAPITAL LETTER C
-    0x0044, // LATIN CAPITAL LETTER D
-    0x0045, // LATIN CAPITAL LETTER E
-    0x0046, // LATIN CAPITAL LETTER F
-    0x0047, // LATIN CAPITAL LETTER G
-    0x0048, // LATIN CAPITAL LETTER H
-    0x0049, // LATIN CAPITAL LETTER I
-    0x004A, // LATIN CAPITAL LETTER J
-    0x004B, // LATIN CAPITAL LETTER K
-    0x004C, // LATIN CAPITAL LETTER L
-    0x004D, // LATIN CAPITAL LETTER M
-    0x004E, // LATIN CAPITAL LETTER N
-    0x004F, // LATIN CAPITAL LETTER O
-    0x0050, // LATIN CAPITAL LETTER P
-    0x0051, // LATIN CAPITAL LETTER Q
-    0x0052, // LATIN CAPITAL LETTER R
-    0x0053, // LATIN CAPITAL LETTER S
-    0x0054, // LATIN CAPITAL LETTER T
-    0x0055, // LATIN CAPITAL LETTER U
-    0x0056, // LATIN CAPITAL LETTER V
-    0x0057, // LATIN CAPITAL LETTER W
-    0x0058, // LATIN CAPITAL LETTER X
-    0x0059, // LATIN CAPITAL LETTER Y
-    0x005A, // LATIN CAPITAL LETTER Z
-    0x005B, // LEFT SQUARE BRACKET
-    0x005C, // REVERSE SOLIDUS
-    0x005D, // RIGHT SQUARE BRACKET
-    0x005E, // CIRCUMFLEX ACCENT
-    0x005F, // LOW LINE
-    0x0060, // GRAVE ACCENT
-    0x0061, // LATIN SMALL LETTER A
-    0x0062, // LATIN SMALL LETTER B
-    0x0063, // LATIN SMALL LETTER C
-    0x0064, // LATIN SMALL LETTER D
-    0x0065, // LATIN SMALL LETTER E
-    0x0066, // LATIN SMALL LETTER F
-    0x0067, // LATIN SMALL LETTER G
-    0x0068, // LATIN SMALL LETTER H
-    0x0069, // LATIN SMALL LETTER I
-    0x006A, // LATIN SMALL LETTER J
-    0x006B, // LATIN SMALL LETTER K
-    0x006C, // LATIN SMALL LETTER L
-    0x006D, // LATIN SMALL LETTER M
-    0x006E, // LATIN SMALL LETTER N
-    0x006F, // LATIN SMALL LETTER O
-    0x0070, // LATIN SMALL LETTER P
-    0x0071, // LATIN SMALL LETTER Q
-    0x0072, // LATIN SMALL LETTER R
-    0x0073, // LATIN SMALL LETTER S
-    0x0074, // LATIN SMALL LETTER T
-    0x0075, // LATIN SMALL LETTER U
-    0x0076, // LATIN SMALL LETTER V
-    0x0077, // LATIN SMALL LETTER W
-    0x0078, // LATIN SMALL LETTER X
-    0x0079, // LATIN SMALL LETTER Y
-    0x007A, // LATIN SMALL LETTER Z
-    0x007B, // LEFT CURLY BRACKET
-    0x007C, // VERTICAL LINE
-    0x007D, // RIGHT CURLY BRACKET
-    0x007E, // TILDE
-    0x007F, // DEL
-    0x00C4, // LATIN CAPITAL LETTER A WITH DIAERESIS
-    0x00C5, // LATIN CAPITAL LETTER A WITH RING ABOVE
-    0x00C7, // LATIN CAPITAL LETTER C WITH CEDILLA
-    0x00C9, // LATIN CAPITAL LETTER E WITH ACUTE
-    0x00D1, // LATIN CAPITAL LETTER N WITH TILDE
-    0x00D6, // LATIN CAPITAL LETTER O WITH DIAERESIS
-    0x00DC, // LATIN CAPITAL LETTER U WITH DIAERESIS
-    0x00E1, // LATIN SMALL LETTER A WITH ACUTE
-    0x00E0, // LATIN SMALL LETTER A WITH GRAVE
-    0x00E2, // LATIN SMALL LETTER A WITH CIRCUMFLEX
-    0x00E4, // LATIN SMALL LETTER A WITH DIAERESIS
-    0x00E3, // LATIN SMALL LETTER A WITH TILDE
-    0x00E5, // LATIN SMALL LETTER A WITH RING ABOVE
-    0x00E7, // LATIN SMALL LETTER C WITH CEDILLA
-    0x00E9, // LATIN SMALL LETTER E WITH ACUTE
-    0x00E8, // LATIN SMALL LETTER E WITH GRAVE
-    0x00EA, // LATIN SMALL LETTER E WITH CIRCUMFLEX
-    0x00EB, // LATIN SMALL LETTER E WITH DIAERESIS
-    0x00ED, // LATIN SMALL LETTER I WITH ACUTE
-    0x00EC, // LATIN SMALL LETTER I WITH GRAVE
-    0x00EE, // LATIN SMALL LETTER I WITH CIRCUMFLEX
-    0x00EF, // LATIN SMALL LETTER I WITH DIAERESIS
-    0x00F1, // LATIN SMALL LETTER N WITH TILDE
-    0x00F3, // LATIN SMALL LETTER O WITH ACUTE
-    0x00F2, // LATIN SMALL LETTER O WITH GRAVE
-    0x00F4, // LATIN SMALL LETTER O WITH CIRCUMFLEX
-    0x00F6, // LATIN SMALL LETTER O WITH DIAERESIS
-    0x00F5, // LATIN SMALL LETTER O WITH TILDE
-    0x00FA, // LATIN SMALL LETTER U WITH ACUTE
-    0x00F9, // LATIN SMALL LETTER U WITH GRAVE
-    0x00FB, // LATIN SMALL LETTER U WITH CIRCUMFLEX
-    0x00FC, // LATIN SMALL LETTER U WITH DIAERESIS
-    0x2020, // DAGGER
-    0x00B0, // DEGREE SIGN
-    0x00A2, // CENT SIGN
-    0x00A3, // POUND SIGN
-    0x00A7, // SECTION SIGN
-    0x2022, // BULLET
-    0x00B6, // PILCROW SIGN
-    0x00DF, // LATIN SMALL LETTER SHARP S
-    0x00AE, // REGISTERED SIGN
-    0x00A9, // COPYRIGHT SIGN
-    0x2122, // TRADE MARK SIGN
-    0x00B4, // ACUTE ACCENT
-    0x00A8, // DIAERESIS
-    0x2260, // NOT EQUAL TO
-    0x00C6, // LATIN CAPITAL LETTER AE
-    0x00D8, // LATIN CAPITAL LETTER O WITH STROKE
-    0x221E, // INFINITY
-    0x00B1, // PLUS-MINUS SIGN
-    0x2264, // LESS-THAN OR EQUAL TO
-    0x2265, // GREATER-THAN OR EQUAL TO
-    0x00A5, // YEN SIGN
-    0x00B5, // MICRO SIGN
-    0x2202, // PARTIAL DIFFERENTIAL
-    0x2211, // N-ARY SUMMATION
-    0x220F, // N-ARY PRODUCT
-    0x03C0, // GREEK SMALL LETTER PI
-    0x222B, // INTEGRAL
-    0x00AA, // FEMININE ORDINAL INDICATOR
-    0x00BA, // MASCULINE ORDINAL INDICATOR
-    0x03A9, // GREEK CAPITAL LETTER OMEGA
-    0x00E6, // LATIN SMALL LETTER AE
-    0x00F8, // LATIN SMALL LETTER O WITH STROKE
-    0x00BF, // INVERTED QUESTION MARK
-    0x00A1, // INVERTED EXCLAMATION MARK
-    0x00AC, // NOT SIGN
-    0x221A, // SQUARE ROOT
-    0x0192, // LATIN SMALL LETTER F WITH HOOK
-    0x2248, // ALMOST EQUAL TO
-    0x2206, // INCREMENT
-    0x00AB, // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
-    0x00BB, // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
-    0x2026, // HORIZONTAL ELLIPSIS
-    0x00A0, // NO-BREAK SPACE
-    0x00C0, // LATIN CAPITAL LETTER A WITH GRAVE
-    0x00C3, // LATIN CAPITAL LETTER A WITH TILDE
-    0x00D5, // LATIN CAPITAL LETTER O WITH TILDE
-    0x0152, // LATIN CAPITAL LIGATURE OE
-    0x0153, // LATIN SMALL LIGATURE OE
-    0x2013, // EN DASH
-    0x2014, // EM DASH
-    0x201C, // LEFT DOUBLE QUOTATION MARK
-    0x201D, // RIGHT DOUBLE QUOTATION MARK
-    0x2018, // LEFT SINGLE QUOTATION MARK
-    0x2019, // RIGHT SINGLE QUOTATION MARK
-    0x00F7, // DIVISION SIGN
-    0x25CA, // LOZENGE
-    0x00FF, // LATIN SMALL LETTER Y WITH DIAERESIS
-    0x0178, // LATIN CAPITAL LETTER Y WITH DIAERESIS
-    0x2044, // FRACTION SLASH
-    0x20AC, // EURO SIGN
-    0x2039, // SINGLE LEFT-POINTING ANGLE QUOTATION MARK
-    0x203A, // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
-    0xFB01, // LATIN SMALL LIGATURE FI
-    0xFB02, // LATIN SMALL LIGATURE FL
-    0x2021, // DOUBLE DAGGER
-    0x00B7, // MIDDLE DOT
-    0x201A, // SINGLE LOW-9 QUOTATION MARK
-    0x201E, // DOUBLE LOW-9 QUOTATION MARK
-    0x2030, // PER MILLE SIGN
-    0x00C2, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
-    0x00CA, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX
-    0x00C1, // LATIN CAPITAL LETTER A WITH ACUTE
-    0x00CB, // LATIN CAPITAL LETTER E WITH DIAERESIS
-    0x00C8, // LATIN CAPITAL LETTER E WITH GRAVE
-    0x00CD, // LATIN CAPITAL LETTER I WITH ACUTE
-    0x00CE, // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
-    0x00CF, // LATIN CAPITAL LETTER I WITH DIAERESIS
-    0x00CC, // LATIN CAPITAL LETTER I WITH GRAVE
-    0x00D3, // LATIN CAPITAL LETTER O WITH ACUTE
-    0x00D4, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
-    0xF8FF, // Apple logo
-    0x00D2, // LATIN CAPITAL LETTER O WITH GRAVE
-    0x00DA, // LATIN CAPITAL LETTER U WITH ACUTE
-    0x00DB, // LATIN CAPITAL LETTER U WITH CIRCUMFLEX
-    0x00D9, // LATIN CAPITAL LETTER U WITH GRAVE
-    0x0131, // LATIN SMALL LETTER DOTLESS I
-    0x02C6, // MODIFIER LETTER CIRCUMFLEX ACCENT
-    0x02DC, // SMALL TILDE
-    0x00AF, // MACRON
-    0x02D8, // BREVE
-    0x02D9, // DOT ABOVE
-    0x02DA, // RING ABOVE
-    0x00B8, // CEDILLA
-    0x02DD, // DOUBLE ACUTE ACCENT
-    0x02DB, // OGONEK
-    0x02C7, // CARON
-};
-
-// OC 13.08.2010 New: PdfMacExpertEncoding
-// -----------------------------------------------------
-// PdfMacExpertEncoding
-// See: ghostscript-8.71/Resource/Init/gs_mex_e.ps
-//      --> array of 256 glyphs for MacExpertEncoding
-// See: http://www.adobe.com/devnet/opentype/archives/glyphlist.txt
-//      --> glyphs to unicodes
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfMacExpertEncoding::GetToUnicodeTable() const
-{
-    return PdfMacExpertEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfMacExpertEncoding::s_cEncoding[256] = {
-// \00x
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-// \04x
-    0x0020, 0xF721, 0xF6F8, 0xF7A2, 0xF724, 0xF6E4, 0xF726, 0xF7B4,
-    0x207D, 0x207E, 0x2025, 0x2024, 0x002C, 0x002D, 0x002E, 0x2044,
-    0xF730, 0xF731, 0xF732, 0xF733, 0xF734, 0xF735, 0xF736, 0xF737,
-    0xF738, 0xF739, 0x003A, 0x003B, 0x0000, 0xF6DE, 0x0000, 0xF73F,
-// \10x
-    0x0000, 0x0000, 0x0000, 0x0000, 0xF7F0, 0x0000, 0x0000, 0x00BC,
-    0x00BD, 0x00BE, 0x215B, 0x215C, 0x215D, 0x215E, 0x2153, 0x2154,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFB00, 0xFB01,
-    0xFB02, 0xFB03, 0xFB04, 0x208D, 0x0000, 0x208E, 0xF6F6, 0xF6E5,
-// \14x
-    0xF760, 0xF761, 0xF762, 0xF763, 0xF764, 0xF765, 0xF766, 0xF767,
-    0xF768, 0xF769, 0xF76A, 0xF76B, 0xF76C, 0xF76D, 0xF76E, 0xF76F,
-    0xF770, 0xF771, 0xF772, 0xF773, 0xF774, 0xF775, 0xF776, 0xF777,
-    0xF778, 0xF779, 0xF77A, 0x20A1, 0xF6DC, 0xF6DD, 0xF6FE, 0x0000,
-// \20x
-    0x0000, 0xF6E9, 0xF6E0, 0x0000, 0x0000, 0x0000, 0x0000, 0xF7E1,
-    0xF7E0, 0xF7E2, 0xF7E4, 0xF7E3, 0xF7E5, 0xF7E7, 0xF7E9, 0xF7E8,
-    0xF7EA, 0xF7EB, 0xF7ED, 0xF7EC, 0xF7EE, 0xF7EF, 0xF7F1, 0xF7F3,
-    0xF7F2, 0xF7F4, 0xF7F6, 0xF7F5, 0xF7FA, 0xF7F9, 0xF7FB, 0xF7FC,
-// \24x
-    0x0000, 0x2078, 0x2084, 0x2083, 0x2086, 0x2088, 0x2087, 0xF6FD,
-    0x0000, 0xF6DF, 0x2082, 0x0000, 0xF7A8, 0x0000, 0xF6F5, 0xF6F0,
-    0x2085, 0x0000, 0xF6E1, 0xF6E7, 0xF7FD, 0x0000, 0xF6E3, 0x0000,
-    0x0000, 0xF7FE, 0x0000, 0x2089, 0x2080, 0xF6FF, 0xF7E6, 0xF7F8,
-// \30x
-    0xF7BF, 0x2081, 0xF6F9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0xF7B8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF6FA,
-    0x2012, 0xF6E6, 0x0000, 0x0000, 0x0000, 0x0000, 0xF7A1, 0x0000,
-    0xF7FF, 0x0000, 0x00B9, 0x00B2, 0x00B3, 0x2074, 0x2075, 0x2076,
-// \34x
-    0x2077, 0x2079, 0x2070, 0x0000, 0xF6EC, 0xF6F1, 0xF6F3, 0x0000,
-    0x0000, 0xF6ED, 0xF6F2, 0xF6EB, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0xF6EE, 0xF6FB, 0xF6F4, 0xF7AF, 0xF6EA, 0x207F, 0xF6EF,
-    0xF6E2, 0xF6E8, 0xF6F7, 0xF6FC, 0x0000, 0x0000, 0x0000, 0x0000
-};
-
-// OC 13.08.2010 New: PdfStandardEncoding
-// -----------------------------------------------------
-// PdfStandardEncoding
-// See: http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/stdenc.txt
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfStandardEncoding::GetToUnicodeTable() const
-{
-    return PdfStandardEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfStandardEncoding::s_cEncoding[256] = {
-//0, // uncomment to check compiler error cause of 257 members
- // 0x00..0x1f undefined:
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0020,  // 20   # SPACE   # space
-    // Duplicated char, commented out
-    // 0x00A0,  // 20   # NO-BREAK SPACE   # space
-    0x0021,  // 21   # EXCLAMATION MARK   # exclam
-    0x0022,  // 22   # QUOTATION MARK   # quotedbl
-    0x0023,  // 23   # NUMBER SIGN   # numbersign
-    0x0024,  // 24   # DOLLAR SIGN   # dollar
-    0x0025,  // 25   # PERCENT SIGN   # percent
-    0x0026,  // 26   # AMPERSAND   # ampersand
-    0x2019,  // 27   # RIGHT SINGLE QUOTATION MARK   # quoteright
-    0x0028,  // 28   # LEFT PARENTHESIS   # parenleft
-    0x0029,  // 29   # RIGHT PARENTHESIS   # parenright
-    0x002A,  // 2A   # ASTERISK   # asterisk
-    0x002B,  // 2B   # PLUS SIGN   # plus
-    0x002C,  // 2C   # COMMA   # comma
-    0x002D,  // 2D   # HYPHEN-MINUS   # hyphen
-    // Duplicated char, commented out
-    // 0x00AD,  // 2D   # SOFT HYPHEN   # hyphen
-    0x002E,  // 2E   # FULL STOP   # period
-    0x002F,  // 2F   # SOLIDUS   # slash
-    0x0030,  // 30   # DIGIT ZERO   # zero
-    0x0031,  // 31   # DIGIT ONE   # one
-    0x0032,  // 32   # DIGIT TWO   # two
-    0x0033,  // 33   # DIGIT THREE   # three
-    0x0034,  // 34   # DIGIT FOUR   # four
-    0x0035,  // 35   # DIGIT FIVE   # five
-    0x0036,  // 36   # DIGIT SIX   # six
-    0x0037,  // 37   # DIGIT SEVEN   # seven
-    0x0038,  // 38   # DIGIT EIGHT   # eight
-    0x0039,  // 39   # DIGIT NINE   # nine
-    0x003A,  // 3A   # COLON   # colon
-    0x003B,  // 3B   # SEMICOLON   # semicolon
-    0x003C,  // 3C   # LESS-THAN SIGN   # less
-    0x003D,  // 3D   # EQUALS SIGN   # equal
-    0x003E,  // 3E   # GREATER-THAN SIGN   # greater
-    0x003F,  // 3F   # QUESTION MARK   # question
-    0x0040,  // 40   # COMMERCIAL AT   # at
-    0x0041,  // 41   # LATIN CAPITAL LETTER A   # A
-    0x0042,  // 42   # LATIN CAPITAL LETTER B   # B
-    0x0043,  // 43   # LATIN CAPITAL LETTER C   # C
-    0x0044,  // 44   # LATIN CAPITAL LETTER D   # D
-    0x0045,  // 45   # LATIN CAPITAL LETTER E   # E
-    0x0046,  // 46   # LATIN CAPITAL LETTER F   # F
-    0x0047,  // 47   # LATIN CAPITAL LETTER G   # G
-    0x0048,  // 48   # LATIN CAPITAL LETTER H   # H
-    0x0049,  // 49   # LATIN CAPITAL LETTER I   # I
-    0x004A,  // 4A   # LATIN CAPITAL LETTER J   # J
-    0x004B,  // 4B   # LATIN CAPITAL LETTER K   # K
-    0x004C,  // 4C   # LATIN CAPITAL LETTER L   # L
-    0x004D,  // 4D   # LATIN CAPITAL LETTER M   # M
-    0x004E,  // 4E   # LATIN CAPITAL LETTER N   # N
-    0x004F,  // 4F   # LATIN CAPITAL LETTER O   # O
-    0x0050,  // 50   # LATIN CAPITAL LETTER P   # P
-    0x0051,  // 51   # LATIN CAPITAL LETTER Q   # Q
-    0x0052,  // 52   # LATIN CAPITAL LETTER R   # R
-    0x0053,  // 53   # LATIN CAPITAL LETTER S   # S
-    0x0054,  // 54   # LATIN CAPITAL LETTER T   # T
-    0x0055,  // 55   # LATIN CAPITAL LETTER U   # U
-    0x0056,  // 56   # LATIN CAPITAL LETTER V   # V
-    0x0057,  // 57   # LATIN CAPITAL LETTER W   # W
-    0x0058,  // 58   # LATIN CAPITAL LETTER X   # X
-    0x0059,  // 59   # LATIN CAPITAL LETTER Y   # Y
-    0x005A,  // 5A   # LATIN CAPITAL LETTER Z   # Z
-    0x005B,  // 5B   # LEFT SQUARE BRACKET   # bracketleft
-    0x005C,  // 5C   # REVERSE SOLIDUS   # backslash
-    0x005D,  // 5D   # RIGHT SQUARE BRACKET   # bracketright
-    0x005E,  // 5E   # CIRCUMFLEX ACCENT   # asciicircum
-    0x005F,  // 5F   # LOW LINE   # underscore
-#if 1
-    0x0060,  // 60   # GRAVE ACCENT
-#else
-    // OC 13.08.2010: See http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/stdenc.txt
-    // The following unicode char should be encoded here.
-    // But i keep the identity ascii 7bit sign.
-    0x2018,  // 60   # LEFT SINGLE QUOTATION MARK   # quoteleft
-#endif
-    0x0061,  // 61   # LATIN SMALL LETTER A   # a
-    0x0062,  // 62   # LATIN SMALL LETTER B   # b
-    0x0063,  // 63   # LATIN SMALL LETTER C   # c
-    0x0064,  // 64   # LATIN SMALL LETTER D   # d
-    0x0065,  // 65   # LATIN SMALL LETTER E   # e
-    0x0066,  // 66   # LATIN SMALL LETTER F   # f
-    0x0067,  // 67   # LATIN SMALL LETTER G   # g
-    0x0068,  // 68   # LATIN SMALL LETTER H   # h
-    0x0069,  // 69   # LATIN SMALL LETTER I   # i
-    0x006A,  // 6A   # LATIN SMALL LETTER J   # j
-    0x006B,  // 6B   # LATIN SMALL LETTER K   # k
-    0x006C,  // 6C   # LATIN SMALL LETTER L   # l
-    0x006D,  // 6D   # LATIN SMALL LETTER M   # m
-    0x006E,  // 6E   # LATIN SMALL LETTER N   # n
-    0x006F,  // 6F   # LATIN SMALL LETTER O   # o
-    0x0070,  // 70   # LATIN SMALL LETTER P   # p
-    0x0071,  // 71   # LATIN SMALL LETTER Q   # q
-    0x0072,  // 72   # LATIN SMALL LETTER R   # r
-    0x0073,  // 73   # LATIN SMALL LETTER S   # s
-    0x0074,  // 74   # LATIN SMALL LETTER T   # t
-    0x0075,  // 75   # LATIN SMALL LETTER U   # u
-    0x0076,  // 76   # LATIN SMALL LETTER V   # v
-    0x0077,  // 77   # LATIN SMALL LETTER W   # w
-    0x0078,  // 78   # LATIN SMALL LETTER X   # x
-    0x0079,  // 79   # LATIN SMALL LETTER Y   # y
-    0x007A,  // 7A   # LATIN SMALL LETTER Z   # z
-    0x007B,  // 7B   # LEFT CURLY BRACKET   # braceleft
-    0x007C,  // 7C   # VERTICAL LINE   # bar
-    0x007D,  // 7D   # RIGHT CURLY BRACKET   # braceright
-    0x007E,  // 7E   # TILDE   # asciitilde
-
- // 0x7f..0xA0 undefined:
-    0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000,
-
-    0x00A1,  // A1   # INVERTED EXCLAMATION MARK   # exclamdown
-    0x00A2,  // A2   # CENT SIGN   # cent
-    0x00A3,  // A3   # POUND SIGN   # sterling
-    0x2044,  // A4   # FRACTION SLASH	# fraction
-    // Duplicated char, commented out
-    // 0x2215,  // A4   # DIVISION SLASH	# fraction
-    0x00A5,  // A5   # YEN SIGN   # yen
-    0x0192,  // A6   # LATIN SMALL LETTER F WITH HOOK   # florin
-    0x00A7,  // A7   # SECTION SIGN   # section
-    0x00A4,  // A8   # CURRENCY SIGN   # currency
-    0x0027,  // A9   # APOSTROPHE   # quotesingle
-    0x201C,  // AA   # LEFT DOUBLE QUOTATION MARK   # quotedblleft
-    0x00AB,  // AB   # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK   # guillemotleft
-    0x2039,  // AC   # SINGLE LEFT-POINTING ANGLE QUOTATION MARK   # guilsinglleft
-    0x203A,  // AD   # SINGLE RIGHT-POINTING ANGLE QUOTATION MARK   # guilsinglright
-    0xFB01,  // AE   # LATIN SMALL LIGATURE FI   # fi
-    0xFB02,  // AF   # LATIN SMALL LIGATURE FL   # fl
-    0x0000,  // B0 undefined
-    0x2013,  // B1   # EN DASH   # endash
-    0x2020,  // B2   # DAGGER   # dagger
-    0x2021,  // B3   # DOUBLE DAGGER   # daggerdbl
-    0x00B7,  // B4   # MIDDLE DOT   # periodcentered
- // 0x2219,  // B4   # BULLET OPERATOR   # periodcentered
-    0x0000,  // B5 undefined
-    0x00B6,  // B6   # PILCROW SIGN   # paragraph
-    0x2022,  // B7   # BULLET   # bullet
-    0x201A,  // B8   # SINGLE LOW-9 QUOTATION MARK   # quotesinglbase
-    0x201E,  // B9   # DOUBLE LOW-9 QUOTATION MARK   # quotedblbase
-    0x201D,  // BA   # RIGHT DOUBLE QUOTATION MARK   # quotedblright
-    0x00BB,  // BB   # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK   # guillemotright
-    0x2026,  // BC   # HORIZONTAL ELLIPSIS   # ellipsis
-    0x2030,  // BD   # PER MILLE SIGN   # perthousand
-    0x0000,  // BE undefined
-    0x00BF,  // BF   # INVERTED QUESTION MARK   # questiondown
-    0x0000,  // C0 undefined
-    0x0060,  // C1   # GRAVE ACCENT   # grave
-    0x00B4,  // C2   # ACUTE ACCENT   # acute
-    0x02C6,  // C3   # MODIFIER LETTER CIRCUMFLEX ACCENT   # circumflex
-    0x02DC,  // C4   # SMALL TILDE   # tilde
-    0x00AF,  // C5   # MACRON   # macron
-    // Duplicated char, commented out
-    //0x02C9,  // C5   # MODIFIER LETTER MACRON   # macron
-    0x02D8,  // C6   # BREVE   # breve
-    0x02D9,  // C7   # DOT ABOVE   # dotaccent
-    0x00A8,  // C8   # DIAERESIS   # dieresis
-    0x0000,  // C9 undefined
-    0x02DA,  // CA   # RING ABOVE   # ring
-    0x00B8,  // CB   # CEDILLA   # cedilla
-    0x02DD,  // CD   # DOUBLE ACUTE ACCENT   # hungarumlaut
-    0x02DB,  // CE   # OGONEK   # ogonek
-    0x02C7,  // CF   # CARON   # caron
-    0x2014,  // D0   # EM DASH   # emdash
-    0x0000,  // D1 undefined
-    0x0000,  // D2 undefined
-    0x0000,  // D3 undefined
-    0x0000,  // D4 undefined
-    0x0000,  // D5 undefined
-    0x0000,  // D6 undefined
-    0x0000,  // D7 undefined
-    0x0000,  // D8 undefined
-    0x0000,  // D9 undefined
-    0x0000,  // DA undefined
-    0x0000,  // DB undefined
-    0x0000,  // DC undefined
-    0x0000,  // DD undefined
-    0x0000,  // DE undefined
-    0x0000,  // DF undefined
-    0x0000,  // E0 undefined
-    0x00C6,  // E1   # LATIN CAPITAL LETTER AE   # AE
-    0x0000,  // E2 undefined
-    0x00AA,  // E3   # FEMININE ORDINAL INDICATOR   # ordfeminine
-    0x0000,  // E4 undefined
-    0x0000,  // E5 undefined
-    0x0000,  // E6 undefined
-    0x0000,  // E7 undefined
-    0x0141,  // E8   # LATIN CAPITAL LETTER L WITH STROKE   # Lslash
-    0x00D8,  // E9   # LATIN CAPITAL LETTER O WITH STROKE   # Oslash
-    0x0152,  // EA   # LATIN CAPITAL LIGATURE OE   # OE
-    0x00BA,  // EB   # MASCULINE ORDINAL INDICATOR   # ordmasculine
-    0x0000,  // EC undefined
-    0x0000,  // ED undefined
-    0x0000,  // EE undefined
-    0x0000,  // EF undefined
-    0x0000,  // F0 undefined
-    0x00E6,  // F1   # LATIN SMALL LETTER AE   # ae
-    0x0000,  // F2 undefined
-    0x0000,  // F3 undefined
-    0x0000,  // F4 undefined
-    0x0131,  // F5   # LATIN SMALL LETTER DOTLESS I   # dotlessi
-    0x0000,  // F6 undefined
-    0x0000,  // F7 undefined
-    0x0142,  // F8   # LATIN SMALL LETTER L WITH STROKE   # lslash
-    0x00F8,  // F9   # LATIN SMALL LETTER O WITH STROKE   # oslash
-    0x0153,  // FA   # LATIN SMALL LIGATURE OE   # oe
-    0x00DF,  // FB   # LATIN SMALL LETTER SHARP S   # germandbls
-    0x0000,  // FC undefined
-    0x0000,  // FD undefined
-    0x0000,  // FE undefined
-    0x0000   // FF undefined
-};
-
-// OC 13.08.2010 New: PdfSymbolEncoding
-// -----------------------------------------------------
-// PdfSymbolEncoding
-// See: http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/symbol.txt
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfSymbolEncoding::GetToUnicodeTable() const
-{
-    return PdfSymbolEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfSymbolEncoding::s_cEncoding[256] = {
-//0, // uncomment to check compiler error cause of 257 members
- // 0x00..0x1f undefined:
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0020,  // 20   # SPACE   # space
- // 0x00A0,  // 20   # NO-BREAK SPACE   # space
-    0x0021,  // 21   # EXCLAMATION MARK   # exclam
-    0x2200,  // 22   # FOR ALL   # universal
-    0x0023,  // 23   # NUMBER SIGN   # numbersign
-    0x2203,  // 24   # THERE EXISTS   # existential
-    0x0025,  // 25   # PERCENT SIGN   # percent
-    0x0026,  // 26   # AMPERSAND   # ampersand
-    0x220B,  // 27   # CONTAINS AS MEMBER   # suchthat
-    0x0028,  // 28   # LEFT PARENTHESIS   # parenleft
-    0x0029,  // 29   # RIGHT PARENTHESIS   # parenright
-    0x2217,  // 2A   # ASTERISK OPERATOR   # asteriskmath
-    0x002B,  // 2B   # PLUS SIGN   # plus
-    0x002C,  // 2C   # COMMA   # comma
-    0x2212,  // 2D   # MINUS SIGN   # minus
-    0x002E,  // 2E   # FULL STOP   # period
-    0x002F,  // 2F   # SOLIDUS   # slash
-    0x0030,  // 30   # DIGIT ZERO   # zero
-    0x0031,  // 31   # DIGIT ONE   # one
-    0x0032,  // 32   # DIGIT TWO   # two
-    0x0033,  // 33   # DIGIT THREE   # three
-    0x0034,  // 34   # DIGIT FOUR   # four
-    0x0035,  // 35   # DIGIT FIVE   # five
-    0x0036,  // 36   # DIGIT SIX   # six
-    0x0037,  // 37   # DIGIT SEVEN   # seven
-    0x0038,  // 38   # DIGIT EIGHT   # eight
-    0x0039,  // 39   # DIGIT NINE   # nine
-    0x003A,  // 3A   # COLON   # colon
-    0x003B,  // 3B   # SEMICOLON   # semicolon
-    0x003C,  // 3C   # LESS-THAN SIGN   # less
-    0x003D,  // 3D   # EQUALS SIGN   # equal
-    0x003E,  // 3E   # GREATER-THAN SIGN   # greater
-    0x003F,  // 3F   # QUESTION MARK   # question
-    0x2245,  // 40   # APPROXIMATELY EQUAL TO   # congruent
-    0x0391,  // 41   # GREEK CAPITAL LETTER ALPHA   # Alpha
-    0x0392,  // 42   # GREEK CAPITAL LETTER BETA   # Beta
-    0x03A7,  // 43   # GREEK CAPITAL LETTER CHI   # Chi
-    0x0394,  // 44   # GREEK CAPITAL LETTER DELTA   # Delta
- // 0x2206,  // 44   # INCREMENT   # Delta
-    0x0395,  // 45   # GREEK CAPITAL LETTER EPSILON   # Epsilon
-    0x03A6,  // 46   # GREEK CAPITAL LETTER PHI   # Phi
-    0x0393,  // 47   # GREEK CAPITAL LETTER GAMMA   # Gamma
-    0x0397,  // 48   # GREEK CAPITAL LETTER ETA   # Eta
-    0x0399,  // 49   # GREEK CAPITAL LETTER IOTA   # Iota
-    0x03D1,  // 4A   # GREEK THETA SYMBOL   # theta1
-    0x039A,  // 4B   # GREEK CAPITAL LETTER KAPPA   # Kappa
-    0x039B,  // 4C   # GREEK CAPITAL LETTER LAMDA   # Lambda
-    0x039C,  // 4D   # GREEK CAPITAL LETTER MU   # Mu
-    0x039D,  // 4E   # GREEK CAPITAL LETTER NU   # Nu
-    0x039F,  // 4F   # GREEK CAPITAL LETTER OMICRON   # Omicron
-    0x03A0,  // 50   # GREEK CAPITAL LETTER PI   # Pi
-    0x0398,  // 51   # GREEK CAPITAL LETTER THETA   # Theta
-    0x03A1,  // 52   # GREEK CAPITAL LETTER RHO   # Rho
-    0x03A3,  // 53   # GREEK CAPITAL LETTER SIGMA   # Sigma
-    0x03A4,  // 54   # GREEK CAPITAL LETTER TAU   # Tau
-    0x03A5,  // 55   # GREEK CAPITAL LETTER UPSILON   # Upsilon
-    0x03C2,  // 56   # GREEK SMALL LETTER FINAL SIGMA   # sigma1
-    0x03A9,  // 57   # GREEK CAPITAL LETTER OMEGA   # Omega
- // 0x2126,  // 57   # OHM SIGN   # Omega
-    0x039E,  // 58   # GREEK CAPITAL LETTER XI   # Xi
-    0x03A8,  // 59   # GREEK CAPITAL LETTER PSI   # Psi
-    0x0396,  // 5A   # GREEK CAPITAL LETTER ZETA   # Zeta
-    0x005B,  // 5B   # LEFT SQUARE BRACKET   # bracketleft
-    0x2234,  // 5C   # THEREFORE   # therefore
-    0x005D,  // 5D   # RIGHT SQUARE BRACKET   # bracketright
-    0x22A5,  // 5E   # UP TACK   # perpendicular
-    0x005F,  // 5F   # LOW LINE   # underscore
-    0xF8E5,  // 60   # RADICAL EXTENDER   # radicalex (CUS)
-    0x03B1,  // 61   # GREEK SMALL LETTER ALPHA   # alpha
-    0x03B2,  // 62   # GREEK SMALL LETTER BETA   # beta
-    0x03C7,  // 63   # GREEK SMALL LETTER CHI   # chi
-    0x03B4,  // 64   # GREEK SMALL LETTER DELTA   # delta
-    0x03B5,  // 65   # GREEK SMALL LETTER EPSILON   # epsilon
-    0x03C6,  // 66   # GREEK SMALL LETTER PHI   # phi
-    0x03B3,  // 67   # GREEK SMALL LETTER GAMMA   # gamma
-    0x03B7,  // 68   # GREEK SMALL LETTER ETA   # eta
-    0x03B9,  // 69   # GREEK SMALL LETTER IOTA   # iota
-    0x03D5,  // 6A   # GREEK PHI SYMBOL   # phi1
-    0x03BA,  // 6B   # GREEK SMALL LETTER KAPPA   # kappa
-    0x03BB,  // 6C   # GREEK SMALL LETTER LAMDA   # lambda
- // 0x00B5,  // 6D   # MICRO SIGN   # mu
-    0x03BC,  // 6D   # GREEK SMALL LETTER MU   # mu
-    0x03BD,  // 6E   # GREEK SMALL LETTER NU   # nu
-    0x03BF,  // 6F   # GREEK SMALL LETTER OMICRON   # omicron
-    0x03C0,  // 70   # GREEK SMALL LETTER PI   # pi
-    0x03B8,  // 71   # GREEK SMALL LETTER THETA   # theta
-    0x03C1,  // 72   # GREEK SMALL LETTER RHO   # rho
-    0x03C3,  // 73   # GREEK SMALL LETTER SIGMA   # sigma
-    0x03C4,  // 74   # GREEK SMALL LETTER TAU   # tau
-    0x03C5,  // 75   # GREEK SMALL LETTER UPSILON   # upsilon
-    0x03D6,  // 76   # GREEK PI SYMBOL   # omega1
-    0x03C9,  // 77   # GREEK SMALL LETTER OMEGA   # omega
-    0x03BE,  // 78   # GREEK SMALL LETTER XI   # xi
-    0x03C8,  // 79   # GREEK SMALL LETTER PSI   # psi
-    0x03B6,  // 7A   # GREEK SMALL LETTER ZETA   # zeta
-    0x007B,  // 7B   # LEFT CURLY BRACKET   # braceleft
-    0x007C,  // 7C   # VERTICAL LINE   # bar
-    0x007D,  // 7D   # RIGHT CURLY BRACKET   # braceright
-    0x223C,  // 7E   # TILDE OPERATOR   # similar
-
- // 0x7f..0x9F undefined:
-    0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-
-    0x20AC,  // A0   # EURO SIGN   # Euro
-    0x03D2,  // A1   # GREEK UPSILON WITH HOOK SYMBOL   # Upsilon1
-    0x2032,  // A2   # PRIME   # minute
-    0x2264,  // A3   # LESS-THAN OR EQUAL TO   # lessequal
-    0x2044,  // A4   # FRACTION SLASH   # fraction
- // 0x2215,  // A4   # DIVISION SLASH   # fraction
-    0x221E,  // A5   # INFINITY   # infinity
-    0x0192,  // A6   # LATIN SMALL LETTER F WITH HOOK   # florin
-    0x2663,  // A7   # BLACK CLUB SUIT   # club
-    0x2666,  // A8   # BLACK DIAMOND SUIT   # diamond
-    0x2665,  // A9   # BLACK HEART SUIT   # heart
-    0x2660,  // AA   # BLACK SPADE SUIT   # spade
-    0x2194,  // AB   # LEFT RIGHT ARROW   # arrowboth
-    0x2190,  // AC   # LEFTWARDS ARROW   # arrowleft
-    0x2191,  // AD   # UPWARDS ARROW   # arrowup
-    0x2192,  // AE   # RIGHTWARDS ARROW   # arrowright
-    0x2193,  // AF   # DOWNWARDS ARROW   # arrowdown
-    0x00B0,  // B0   # DEGREE SIGN   # degree
-    0x00B1,  // B1   # PLUS-MINUS SIGN   # plusminus
-    0x2033,  // B2   # DOUBLE PRIME   # second
-    0x2265,  // B3   # GREATER-THAN OR EQUAL TO   # greaterequal
-    0x00D7,  // B4   # MULTIPLICATION SIGN   # multiply
-    0x221D,  // B5   # PROPORTIONAL TO   # proportional
-    0x2202,  // B6   # PARTIAL DIFFERENTIAL   # partialdiff
-    0x2022,  // B7   # BULLET   # bullet
-    0x00F7,  // B8   # DIVISION SIGN   # divide
-    0x2260,  // B9   # NOT EQUAL TO   # notequal
-    0x2261,  // BA   # IDENTICAL TO   # equivalence
-    0x2248,  // BB   # ALMOST EQUAL TO   # approxequal
-    0x2026,  // BC   # HORIZONTAL ELLIPSIS   # ellipsis
-    0xF8E6,  // BD   # VERTICAL ARROW EXTENDER   # arrowvertex (CUS)
-    0xF8E7,  // BE   # HORIZONTAL ARROW EXTENDER   # arrowhorizex (CUS)
-    0x21B5,  // BF   # DOWNWARDS ARROW WITH CORNER LEFTWARDS   # carriagereturn
-    0x2135,  // C0   # ALEF SYMBOL   # aleph
-    0x2111,  // C1   # BLACK-LETTER CAPITAL I   # Ifraktur
-    0x211C,  // C2   # BLACK-LETTER CAPITAL R   # Rfraktur
-    0x2118,  // C3   # SCRIPT CAPITAL P   # weierstrass
-    0x2297,  // C4   # CIRCLED TIMES   # circlemultiply
-    0x2295,  // C5   # CIRCLED PLUS   # circleplus
-    0x2205,  // C6   # EMPTY SET   # emptyset
-    0x2229,  // C7   # INTERSECTION   # intersection
-    0x222A,  // C8   # UNION   # union
-    0x2283,  // C9   # SUPERSET OF   # propersuperset
-    0x2287,  // CA   # SUPERSET OF OR EQUAL TO   # reflexsuperset
-    0x2284,  // CB   # NOT A SUBSET OF   # notsubset
-    0x2282,  // CC   # SUBSET OF   # propersubset
-    0x2286,  // CD   # SUBSET OF OR EQUAL TO   # reflexsubset
-    0x2208,  // CE   # ELEMENT OF   # element
-    0x2209,  // CF   # NOT AN ELEMENT OF   # notelement
-    0x2220,  // D0   # ANGLE   # angle
-    0x2207,  // D1   # NABLA   # gradient
-    0xF6DA,  // D2   # REGISTERED SIGN SERIF   # registerserif (CUS)
-    0xF6D9,  // D3   # COPYRIGHT SIGN SERIF   # copyrightserif (CUS)
-    0xF6DB,  // D4   # TRADE MARK SIGN SERIF   # trademarkserif (CUS)
-    0x220F,  // D5   # N-ARY PRODUCT   # product
-    0x221A,  // D6   # SQUARE ROOT   # radical
-    0x22C5,  // D7   # DOT OPERATOR   # dotmath
-    0x00AC,  // D8   # NOT SIGN   # logicalnot
-    0x2227,  // D9   # LOGICAL AND   # logicaland
-    0x2228,  // DA   # LOGICAL OR   # logicalor
-    0x21D4,  // DB   # LEFT RIGHT DOUBLE ARROW   # arrowdblboth
-    0x21D0,  // DC   # LEFTWARDS DOUBLE ARROW   # arrowdblleft
-    0x21D1,  // DD   # UPWARDS DOUBLE ARROW   # arrowdblup
-    0x21D2,  // DE   # RIGHTWARDS DOUBLE ARROW   # arrowdblright
-    0x21D3,  // DF   # DOWNWARDS DOUBLE ARROW   # arrowdbldown
-    0x25CA,  // E0   # LOZENGE   # lozenge
-    0x2329,  // E1   # LEFT-POINTING ANGLE BRACKET   # angleleft
-    0xF8E8,  // E2   # REGISTERED SIGN SANS SERIF   # registersans (CUS)
-    0xF8E9,  // E3   # COPYRIGHT SIGN SANS SERIF   # copyrightsans (CUS)
-    0xF8EA,  // E4   # TRADE MARK SIGN SANS SERIF   # trademarksans (CUS)
-    0x2211,  // E5   # N-ARY SUMMATION   # summation
-    0xF8EB,  // E6   # LEFT PAREN TOP   # parenlefttp (CUS)
-    0xF8EC,  // E7   # LEFT PAREN EXTENDER   # parenleftex (CUS)
-    0xF8ED,  // E8   # LEFT PAREN BOTTOM   # parenleftbt (CUS)
-    0xF8EE,  // E9   # LEFT SQUARE BRACKET TOP   # bracketlefttp (CUS)
-    0xF8EF,  // EA   # LEFT SQUARE BRACKET EXTENDER   # bracketleftex (CUS)
-    0xF8F0,  // EB   # LEFT SQUARE BRACKET BOTTOM   # bracketleftbt (CUS)
-    0xF8F1,  // EC   # LEFT CURLY BRACKET TOP   # bracelefttp (CUS)
-    0xF8F2,  // ED   # LEFT CURLY BRACKET MID   # braceleftmid (CUS)
-    0xF8F3,  // EE   # LEFT CURLY BRACKET BOTTOM   # braceleftbt (CUS)
-    0xF8F4,  // EF   # CURLY BRACKET EXTENDER   # braceex (CUS)
-    0x0000,  // F0 undefined
-    0x232A,  // F1   # RIGHT-POINTING ANGLE BRACKET   # angleright
-    0x222B,  // F2   # INTEGRAL   # integral
-    0x2320,  // F3   # TOP HALF INTEGRAL   # integraltp
-    0xF8F5,  // F4   # INTEGRAL EXTENDER   # integralex (CUS)
-    0x2321,  // F5   # BOTTOM HALF INTEGRAL   # integralbt
-    0xF8F6,  // F6   # RIGHT PAREN TOP   # parenrighttp (CUS)
-    0xF8F7,  // F7   # RIGHT PAREN EXTENDER   # parenrightex (CUS)
-    0xF8F8,  // F8   # RIGHT PAREN BOTTOM   # parenrightbt (CUS)
-    0xF8F9,  // F9   # RIGHT SQUARE BRACKET TOP   # bracketrighttp (CUS)
-    0xF8FA,  // FA   # RIGHT SQUARE BRACKET EXTENDER   # bracketrightex (CUS)
-    0xF8FB,  // FB   # RIGHT SQUARE BRACKET BOTTOM   # bracketrightbt (CUS)
-    0xF8FC,  // FC   # RIGHT CURLY BRACKET TOP   # bracerighttp (CUS)
-    0xF8FD,  // FD   # RIGHT CURLY BRACKET MID   # bracerightmid (CUS)
-    0xF8FE,  // FE   # RIGHT CURLY BRACKET BOTTOM   # bracerightbt (CUS)
-    0x0000   // FF undefined
-};
-
-// OC 13.08.2010 New: PdfZapfDingbatsEncoding
-// -----------------------------------------------------
-// PdfZapfDingbatsEncoding
-// See: http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/zdingbat.txt
-// -----------------------------------------------------
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const pdf_utf16be* PdfZapfDingbatsEncoding::GetToUnicodeTable() const
-{
-    return PdfZapfDingbatsEncoding::s_cEncoding;
-}
-
-const pdf_utf16be PdfZapfDingbatsEncoding::s_cEncoding[256] = {
-//0, // uncomment to check compiler error cause of 257 members
- // 0x00..0x1f undefined:
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0020,  // 20   # SPACE   # space
- // 0x00A0,  // 20   # NO-BREAK SPACE   # space
-    0x2701,  // 21   # UPPER BLADE SCISSORS   # a1
-    0x2702,  // 22   # BLACK SCISSORS   # a2
-    0x2703,  // 23   # LOWER BLADE SCISSORS   # a202
-    0x2704,  // 24   # WHITE SCISSORS   # a3
-    0x260E,  // 25   # BLACK TELEPHONE   # a4
-    0x2706,  // 26   # TELEPHONE LOCATION SIGN   # a5
-    0x2707,  // 27   # TAPE DRIVE   # a119
-    0x2708,  // 28   # AIRPLANE   # a118
-    0x2709,  // 29   # ENVELOPE   # a117
-    0x261B,  // 2A   # BLACK RIGHT POINTING INDEX   # a11
-    0x261E,  // 2B   # WHITE RIGHT POINTING INDEX   # a12
-    0x270C,  // 2C   # VICTORY HAND   # a13
-    0x270D,  // 2D   # WRITING HAND   # a14
-    0x270E,  // 2E   # LOWER RIGHT PENCIL   # a15
-    0x270F,  // 2F   # PENCIL   # a16
-    0x2710,  // 30   # UPPER RIGHT PENCIL   # a105
-    0x2711,  // 31   # WHITE NIB   # a17
-    0x2712,  // 32   # BLACK NIB   # a18
-    0x2713,  // 33   # CHECK MARK   # a19
-    0x2714,  // 34   # HEAVY CHECK MARK   # a20
-    0x2715,  // 35   # MULTIPLICATION X   # a21
-    0x2716,  // 36   # HEAVY MULTIPLICATION X   # a22
-    0x2717,  // 37   # BALLOT X   # a23
-    0x2718,  // 38   # HEAVY BALLOT X   # a24
-    0x2719,  // 39   # OUTLINED GREEK CROSS   # a25
-    0x271A,  // 3A   # HEAVY GREEK CROSS   # a26
-    0x271B,  // 3B   # OPEN CENTRE CROSS   # a27
-    0x271C,  // 3C   # HEAVY OPEN CENTRE CROSS   # a28
-    0x271D,  // 3D   # LATIN CROSS   # a6
-    0x271E,  // 3E   # SHADOWED WHITE LATIN CROSS   # a7
-    0x271F,  // 3F   # OUTLINED LATIN CROSS   # a8
-    0x2720,  // 40   # MALTESE CROSS   # a9
-    0x2721,  // 41   # STAR OF DAVID   # a10
-    0x2722,  // 42   # FOUR TEARDROP-SPOKED ASTERISK   # a29
-    0x2723,  // 43   # FOUR BALLOON-SPOKED ASTERISK   # a30
-    0x2724,  // 44   # HEAVY FOUR BALLOON-SPOKED ASTERISK   # a31
-    0x2725,  // 45   # FOUR CLUB-SPOKED ASTERISK   # a32
-    0x2726,  // 46   # BLACK FOUR POINTED STAR   # a33
-    0x2727,  // 47   # WHITE FOUR POINTED STAR   # a34
-    0x2605,  // 48   # BLACK STAR   # a35
-    0x2729,  // 49   # STRESS OUTLINED WHITE STAR   # a36
-    0x272A,  // 4A   # CIRCLED WHITE STAR   # a37
-    0x272B,  // 4B   # OPEN CENTRE BLACK STAR   # a38
-    0x272C,  // 4C   # BLACK CENTRE WHITE STAR   # a39
-    0x272D,  // 4D   # OUTLINED BLACK STAR   # a40
-    0x272E,  // 4E   # HEAVY OUTLINED BLACK STAR   # a41
-    0x272F,  // 4F   # PINWHEEL STAR   # a42
-    0x2730,  // 50   # SHADOWED WHITE STAR   # a43
-    0x2731,  // 51   # HEAVY ASTERISK   # a44
-    0x2732,  // 52   # OPEN CENTRE ASTERISK   # a45
-    0x2733,  // 53   # EIGHT SPOKED ASTERISK   # a46
-    0x2734,  // 54   # EIGHT POINTED BLACK STAR   # a47
-    0x2735,  // 55   # EIGHT POINTED PINWHEEL STAR   # a48
-    0x2736,  // 56   # SIX POINTED BLACK STAR   # a49
-    0x2737,  // 57   # EIGHT POINTED RECTILINEAR BLACK STAR   # a50
-    0x2738,  // 58   # HEAVY EIGHT POINTED RECTILINEAR BLACK STAR   # a51
-    0x2739,  // 59   # TWELVE POINTED BLACK STAR   # a52
-    0x273A,  // 5A   # SIXTEEN POINTED ASTERISK   # a53
-    0x273B,  // 5B   # TEARDROP-SPOKED ASTERISK   # a54
-    0x273C,  // 5C   # OPEN CENTRE TEARDROP-SPOKED ASTERISK   # a55
-    0x273D,  // 5D   # HEAVY TEARDROP-SPOKED ASTERISK   # a56
-    0x273E,  // 5E   # SIX PETALLED BLACK AND WHITE FLORETTE   # a57
-    0x273F,  // 5F   # BLACK FLORETTE   # a58
-    0x2740,  // 60   # WHITE FLORETTE   # a59
-    0x2741,  // 61   # EIGHT PETALLED OUTLINED BLACK FLORETTE   # a60
-    0x2742,  // 62   # CIRCLED OPEN CENTRE EIGHT POINTED STAR   # a61
-    0x2743,  // 63   # HEAVY TEARDROP-SPOKED PINWHEEL ASTERISK   # a62
-    0x2744,  // 64   # SNOWFLAKE   # a63
-    0x2745,  // 65   # TIGHT TRIFOLIATE SNOWFLAKE   # a64
-    0x2746,  // 66   # HEAVY CHEVRON SNOWFLAKE   # a65
-    0x2747,  // 67   # SPARKLE   # a66
-    0x2748,  // 68   # HEAVY SPARKLE   # a67
-    0x2749,  // 69   # BALLOON-SPOKED ASTERISK   # a68
-    0x274A,  // 6A   # EIGHT TEARDROP-SPOKED PROPELLER ASTERISK   # a69
-    0x274B,  // 6B   # HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISK   # a70
-    0x25CF,  // 6C   # BLACK CIRCLE   # a71
-    0x274D,  // 6D   # SHADOWED WHITE CIRCLE   # a72
-    0x25A0,  // 6E   # BLACK SQUARE   # a73
-    0x274F,  // 6F   # LOWER RIGHT DROP-SHADOWED WHITE SQUARE   # a74
-    0x2750,  // 70   # UPPER RIGHT DROP-SHADOWED WHITE SQUARE   # a203
-    0x2751,  // 71   # LOWER RIGHT SHADOWED WHITE SQUARE   # a75
-    0x2752,  // 72   # UPPER RIGHT SHADOWED WHITE SQUARE   # a204
-    0x25B2,  // 73   # BLACK UP-POINTING TRIANGLE   # a76
-    0x25BC,  // 74   # BLACK DOWN-POINTING TRIANGLE   # a77
-    0x25C6,  // 75   # BLACK DIAMOND   # a78
-    0x2756,  // 76   # BLACK DIAMOND MINUS WHITE X   # a79
-    0x25D7,  // 77   # RIGHT HALF BLACK CIRCLE   # a81
-    0x2758,  // 78   # LIGHT VERTICAL BAR   # a82
-    0x2759,  // 79   # MEDIUM VERTICAL BAR   # a83
-    0x275A,  // 7A   # HEAVY VERTICAL BAR   # a84
-    0x275B,  // 7B   # HEAVY SINGLE TURNED COMMA QUOTATION MARK ORNAMENT   # a97
-    0x275C,  // 7C   # HEAVY SINGLE COMMA QUOTATION MARK ORNAMENT   # a98
-    0x275D,  // 7D   # HEAVY DOUBLE TURNED COMMA QUOTATION MARK ORNAMENT   # a99
-    0x275E,  // 7E   # HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT   # a100
-    0x0000,  // 7F undefined
-    0xF8D7,  // 80   # MEDIUM LEFT PARENTHESIS ORNAMENT   # a89 (CUS)
-    0xF8D8,  // 81   # MEDIUM RIGHT PARENTHESIS ORNAMENT   # a90 (CUS)
-    0xF8D9,  // 82   # MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT   # a93 (CUS)
-    0xF8DA,  // 83   # MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT   # a94 (CUS)
-    0xF8DB,  // 84   # MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT   # a91 (CUS)
-    0xF8DC,  // 85   # MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT   # a92 (CUS)
-    0xF8DD,  // 86   # HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT   # a205 (CUS)
-    0xF8DE,  // 87   # HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT   # a85 (CUS)
-    0xF8DF,  // 88   # HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT   # a206 (CUS)
-    0xF8E0,  // 89   # HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT   # a86 (CUS)
-    0xF8E1,  // 8A   # LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT   # a87 (CUS)
-    0xF8E2,  // 8B   # LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT   # a88 (CUS)
-    0xF8E3,  // 8C   # MEDIUM LEFT CURLY BRACKET ORNAMENT   # a95 (CUS)
-    0xF8E4,  // 8D   # MEDIUM RIGHT CURLY BRACKET ORNAMENT   # a96 (CUS)
-
- // 0x8E..0xA0 undefined:
-    0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
-    0x0000,
-
-    0x2761,  // A1   # CURVED STEM PARAGRAPH SIGN ORNAMENT   # a101
-    0x2762,  // A2   # HEAVY EXCLAMATION MARK ORNAMENT   # a102
-    0x2763,  // A3   # HEAVY HEART EXCLAMATION MARK ORNAMENT   # a103
-    0x2764,  // A4   # HEAVY BLACK HEART   # a104
-    0x2765,  // A5   # ROTATED HEAVY BLACK HEART BULLET   # a106
-    0x2766,  // A6   # FLORAL HEART   # a107
-    0x2767,  // A7   # ROTATED FLORAL HEART BULLET   # a108
-    0x2663,  // A8   # BLACK CLUB SUIT   # a112
-    0x2666,  // A9   # BLACK DIAMOND SUIT   # a111
-    0x2665,  // AA   # BLACK HEART SUIT   # a110
-    0x2660,  // AB   # BLACK SPADE SUIT   # a109
-    0x2460,  // AC   # CIRCLED DIGIT ONE   # a120
-    0x2461,  // AD   # CIRCLED DIGIT TWO   # a121
-    0x2462,  // AE   # CIRCLED DIGIT THREE   # a122
-    0x2463,  // AF   # CIRCLED DIGIT FOUR   # a123
-    0x2464,  // B0   # CIRCLED DIGIT FIVE   # a124
-    0x2465,  // B1   # CIRCLED DIGIT SIX   # a125
-    0x2466,  // B2   # CIRCLED DIGIT SEVEN   # a126
-    0x2467,  // B3   # CIRCLED DIGIT EIGHT   # a127
-    0x2468,  // B4   # CIRCLED DIGIT NINE   # a128
-    0x2469,  // B5   # CIRCLED NUMBER TEN   # a129
-    0x2776,  // B6   # DINGBAT NEGATIVE CIRCLED DIGIT ONE   # a130
-    0x2777,  // B7   # DINGBAT NEGATIVE CIRCLED DIGIT TWO   # a131
-    0x2778,  // B8   # DINGBAT NEGATIVE CIRCLED DIGIT THREE   # a132
-    0x2779,  // B9   # DINGBAT NEGATIVE CIRCLED DIGIT FOUR   # a133
-    0x277A,  // BA   # DINGBAT NEGATIVE CIRCLED DIGIT FIVE   # a134
-    0x277B,  // BB   # DINGBAT NEGATIVE CIRCLED DIGIT SIX   # a135
-    0x277C,  // BC   # DINGBAT NEGATIVE CIRCLED DIGIT SEVEN   # a136
-    0x277D,  // BD   # DINGBAT NEGATIVE CIRCLED DIGIT EIGHT   # a137
-    0x277E,  // BE   # DINGBAT NEGATIVE CIRCLED DIGIT NINE   # a138
-    0x277F,  // BF   # DINGBAT NEGATIVE CIRCLED NUMBER TEN   # a139
-    0x2780,  // C0   # DINGBAT CIRCLED SANS-SERIF DIGIT ONE   # a140
-    0x2781,  // C1   # DINGBAT CIRCLED SANS-SERIF DIGIT TWO   # a141
-    0x2782,  // C2   # DINGBAT CIRCLED SANS-SERIF DIGIT THREE   # a142
-    0x2783,  // C3   # DINGBAT CIRCLED SANS-SERIF DIGIT FOUR   # a143
-    0x2784,  // C4   # DINGBAT CIRCLED SANS-SERIF DIGIT FIVE   # a144
-    0x2785,  // C5   # DINGBAT CIRCLED SANS-SERIF DIGIT SIX   # a145
-    0x2786,  // C6   # DINGBAT CIRCLED SANS-SERIF DIGIT SEVEN   # a146
-    0x2787,  // C7   # DINGBAT CIRCLED SANS-SERIF DIGIT EIGHT   # a147
-    0x2788,  // C8   # DINGBAT CIRCLED SANS-SERIF DIGIT NINE   # a148
-    0x2789,  // C9   # DINGBAT CIRCLED SANS-SERIF NUMBER TEN   # a149
-    0x278A,  // CA   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ONE   # a150
-    0x278B,  // CB   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT TWO   # a151
-    0x278C,  // CC   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT THREE   # a152
-    0x278D,  // CD   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT FOUR   # a153
-    0x278E,  // CE   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT FIVE   # a154
-    0x278F,  // CF   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT SIX   # a155
-    0x2790,  // D0   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT SEVEN   # a156
-    0x2791,  // D1   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT EIGHT   # a157
-    0x2792,  // D2   # DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT NINE   # a158
-    0x2793,  // D3   # DINGBAT NEGATIVE CIRCLED SANS-SERIF NUMBER TEN   # a159
-    0x2794,  // D4   # HEAVY WIDE-HEADED RIGHTWARDS ARROW   # a160
-    0x2192,  // D5   # RIGHTWARDS ARROW   # a161
-    0x2194,  // D6   # LEFT RIGHT ARROW   # a163
-    0x2195,  // D7   # UP DOWN ARROW   # a164
-    0x2798,  // D8   # HEAVY SOUTH EAST ARROW   # a196
-    0x2799,  // D9   # HEAVY RIGHTWARDS ARROW   # a165
-    0x279A,  // DA   # HEAVY NORTH EAST ARROW   # a192
-    0x279B,  // DB   # DRAFTING POINT RIGHTWARDS ARROW   # a166
-    0x279C,  // DC   # HEAVY ROUND-TIPPED RIGHTWARDS ARROW   # a167
-    0x279D,  // DD   # TRIANGLE-HEADED RIGHTWARDS ARROW   # a168
-    0x279E,  // DE   # HEAVY TRIANGLE-HEADED RIGHTWARDS ARROW   # a169
-    0x279F,  // DF   # DASHED TRIANGLE-HEADED RIGHTWARDS ARROW   # a170
-    0x27A0,  // E0   # HEAVY DASHED TRIANGLE-HEADED RIGHTWARDS ARROW   # a171
-    0x27A1,  // E1   # BLACK RIGHTWARDS ARROW   # a172
-    0x27A2,  // E2   # THREE-D TOP-LIGHTED RIGHTWARDS ARROWHEAD   # a173
-    0x27A3,  // E3   # THREE-D BOTTOM-LIGHTED RIGHTWARDS ARROWHEAD   # a162
-    0x27A4,  // E4   # BLACK RIGHTWARDS ARROWHEAD   # a174
-    0x27A5,  // E5   # HEAVY BLACK CURVED DOWNWARDS AND RIGHTWARDS ARROW   # a175
-    0x27A6,  // E6   # HEAVY BLACK CURVED UPWARDS AND RIGHTWARDS ARROW   # a176
-    0x27A7,  // E7   # SQUAT BLACK RIGHTWARDS ARROW   # a177
-    0x27A8,  // E8   # HEAVY CONCAVE-POINTED BLACK RIGHTWARDS ARROW   # a178
-    0x27A9,  // E9   # RIGHT-SHADED WHITE RIGHTWARDS ARROW   # a179
-    0x27AA,  // EA   # LEFT-SHADED WHITE RIGHTWARDS ARROW   # a193
-    0x27AB,  // EB   # BACK-TILTED SHADOWED WHITE RIGHTWARDS ARROW   # a180
-    0x27AC,  // EC   # FRONT-TILTED SHADOWED WHITE RIGHTWARDS ARROW   # a199
-    0x27AD,  // ED   # HEAVY LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW   # a181
-    0x27AE,  // EE   # HEAVY UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW   # a200
-    0x27AF,  // EF   # NOTCHED LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW   # a182
-    0x0000,  // F0 undefined
-    0x27B1,  // F1   # NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW   # a201
-    0x27B2,  // F2   # CIRCLED HEAVY WHITE RIGHTWARDS ARROW   # a183
-    0x27B3,  // F3   # WHITE-FEATHERED RIGHTWARDS ARROW   # a184
-    0x27B4,  // F4   # BLACK-FEATHERED SOUTH EAST ARROW   # a197
-    0x27B5,  // F5   # BLACK-FEATHERED RIGHTWARDS ARROW   # a185
-    0x27B6,  // F6   # BLACK-FEATHERED NORTH EAST ARROW   # a194
-    0x27B7,  // F7   # HEAVY BLACK-FEATHERED SOUTH EAST ARROW   # a198
-    0x27B8,  // F8   # HEAVY BLACK-FEATHERED RIGHTWARDS ARROW   # a186
-    0x27B9,  // F9   # HEAVY BLACK-FEATHERED NORTH EAST ARROW   # a195
-    0x27BA,  // FA   # TEARDROP-BARBED RIGHTWARDS ARROW   # a187
-    0x27BB,  // FB   # HEAVY TEARDROP-SHANKED RIGHTWARDS ARROW   # a188
-    0x27BC,  // FC   # WEDGE-TAILED RIGHTWARDS ARROW   # a189
-    0x27BD,  // FD   # HEAVY WEDGE-TAILED RIGHTWARDS ARROW   # a190
-    0x27BE,  // FE   # OPEN-OUTLINED RIGHTWARDS ARROW   # a191
-    0x0000   // FF undefined
-};
- 
-}; /* namespace PoDoFo */
--- src/base/PdfEncrypt.cpp.orig	2024-06-29 17:32:05.002340184 +0000
+++ src/base/PdfEncrypt.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1768 +0,0 @@
-/*
- **********************************************************************
- ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
- **                                                                  **
- ** License to copy and use this software is granted provided that   **
- ** it is identified as the "RSA Data Security, Inc. MD5 Message     **
- ** Digest Algorithm" in all material mentioning or referencing this **
- ** software or this function.                                       **
- **                                                                  **
- ** License is also granted to make and use derivative works         **
- ** provided that such works are identified as "derived from the RSA **
- ** Data Security, Inc. MD5 Message Digest Algorithm" in all         **
- ** material mentioning or referencing the derived work.             **
- **                                                                  **
- ** RSA Data Security, Inc. makes no representations concerning      **
- ** either the merchantability of this software or the suitability   **
- ** of this software for any particular purpose.  It is provided "as **
- ** is" without express or implied warranty of any kind.             **
- **                                                                  **
- ** These notices must be retained in any copies of any part of this **
- ** documentation and/or software.                                   **
- **********************************************************************
- */
-
-// includes
-#include "PdfEncrypt.h"
-
-#include "PdfDictionary.h"
-#include "PdfFilter.h"
-#include "PdfDefinesPrivate.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <sstream>
-
-#ifdef PODOFO_HAVE_OPENSSL
-// SHA-256
-#ifdef PODOFO_HAVE_LIBIDN
-// AES-256 dependencies :
-// SASL
-#include <stringprep.h>
-#include <openssl/sha.h>
-#endif // PODOFO_HAVE_LIBIDN
-
-#include <openssl/md5.h>
-#include <openssl/evp.h>
-#endif //PODOFO_HAVE_OPENSSL
-
-namespace
-{
-    //RG: TODO Could we name literal 256 and use the literal name e.g.
-    //const size_t KEY_SIZE = 256;
-}
-
-namespace PoDoFo {
-
-#ifdef PODOFO_HAVE_LIBIDN
-int PdfEncrypt::s_nEnabledEncryptionAlgorithms = 
-ePdfEncryptAlgorithm_RC4V1 |
-ePdfEncryptAlgorithm_RC4V2 |
-ePdfEncryptAlgorithm_AESV2 |
-ePdfEncryptAlgorithm_AESV3;
-#else // PODOFO_HAVE_LIBIDN
-int PdfEncrypt::s_nEnabledEncryptionAlgorithms =
-ePdfEncryptAlgorithm_RC4V1 |
-ePdfEncryptAlgorithm_RC4V2 |
-ePdfEncryptAlgorithm_AESV2;
-#endif // PODOFO_HAVE_LIBIDN
-
-#ifdef PODOFO_HAVE_OPENSSL
-// Default value for P (permissions) = no permission
-#define PERMS_DEFAULT 0xFFFFF0C0
-
-#define AES_IV_LENGTH 16
-
-// A class that holds the AES Crypto object
-class AESCryptoEngine {
-    public:
-    
-        AESCryptoEngine()
-        {
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-            aes = EVP_CIPHER_CTX_new();
-    #else
-            EVP_CIPHER_CTX_init(&aes);
-    #endif
-        }
-    
-        EVP_CIPHER_CTX* getEngine()
-        {
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-            return aes;
-    #else
-            return &aes;
-    #endif
-        }
-    
-        ~AESCryptoEngine()
-        {
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-            EVP_CIPHER_CTX_free(aes);
-    #else
-            EVP_CIPHER_CTX_cleanup(&aes);
-    #endif
-        }
-    
-    private:
-
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-        EVP_CIPHER_CTX *aes;
-    #else
-        EVP_CIPHER_CTX aes;
-    #endif
-};
-
-// A class that holds the RC4 Crypto object
-// Either CCCrpytor or EVP_CIPHER_CTX
-class RC4CryptoEngine {
-public:
-    
-    RC4CryptoEngine()
-    {
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-        rc4 = EVP_CIPHER_CTX_new();
-    #else
-        EVP_CIPHER_CTX_init(&rc4);
-    #endif
-    }
-    
-    EVP_CIPHER_CTX* getEngine()
-    {
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-        return rc4;
-    #else
-        return &rc4;
-    #endif
-    }
-    
-    ~RC4CryptoEngine()
-    {
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-        EVP_CIPHER_CTX_free(rc4);
-    #else
-        EVP_CIPHER_CTX_cleanup(&rc4);
-    #endif
-    }
-    
-private:
-    
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    EVP_CIPHER_CTX *rc4;
-    #else
-    EVP_CIPHER_CTX rc4;
-    #endif
-};
-    
-/** A class that can encrypt/decrpyt streamed data block wise
- *  This is used in the input and output stream encryption implementation.
- *  Only the RC4 encryption algorithm is supported
- */
-class PdfRC4Stream {
-public:
-    PdfRC4Stream( unsigned char rc4key[256], unsigned char rc4last[256], unsigned char* key, const size_t keylen )
-    : m_a( 0 ), m_b( 0 )
-    {
-        size_t i;
-        size_t j;
-        size_t t;
-        
-        if (memcmp(key,rc4key,keylen) != 0)
-        {
-            for (i = 0; i < 256; i++)
-                m_rc4[i] = static_cast<unsigned char>(i);
-            
-            j = 0;
-            for (i = 0; i < 256; i++)
-            {
-                t = static_cast<size_t>(m_rc4[i]);
-                j = (j + t + static_cast<size_t>(key[i % keylen])) % 256;
-                m_rc4[i] = m_rc4[j];
-                m_rc4[j] = static_cast<unsigned char>(t);
-            }
-            
-            memcpy(rc4key, key, keylen);
-            memcpy(rc4last, m_rc4, 256);
-        }
-        else
-        {
-            memcpy(m_rc4, rc4last, 256);
-        }
-    }
-    
-    ~PdfRC4Stream()
-    {
-    }
-    
-    /** Encrypt or decrypt a block
-     *  
-     *  \param pBuffer the input/output buffer. Data is read from this buffer and also stored here
-     *  \param lLen    the size of the buffer 
-     */
-    pdf_long Encrypt( char* pBuffer, pdf_long lLen )
-    {
-        unsigned char k;
-        pdf_long t, i;
-        
-        // Do not encode data with no length
-        if( !lLen )
-            return lLen;
-        
-        for (i = 0; i < lLen; i++ )
-        {
-            m_a = (m_a + 1) % 256;
-            t   = m_rc4[m_a];
-            m_b = (m_b + t) % 256;
-            
-            m_rc4[m_a] = m_rc4[m_b];
-            m_rc4[m_b] = static_cast<unsigned char>(t);
-            
-            k = m_rc4[(m_rc4[m_a] + m_rc4[m_b]) % 256];
-            pBuffer[i] = pBuffer[i] ^ k;
-        }
-        
-        return lLen;
-    }
-    
-private:
-    unsigned char m_rc4[256];
-    
-    int           m_a;
-    int           m_b;
-    
-};
-
-/** A PdfOutputStream that encrypt all data written
- *  using the RC4 encryption algorithm
- */
-class PdfRC4OutputStream : public PdfOutputStream {
-public:
-    PdfRC4OutputStream( PdfOutputStream* pOutputStream, unsigned char rc4key[256], unsigned char rc4last[256], unsigned char* key, int keylen )
-    : m_pOutputStream( pOutputStream ), m_stream( rc4key, rc4last, key, keylen )
-    {
-    }
-    
-    virtual ~PdfRC4OutputStream()
-    {
-    }
-    
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen )
-    {
-        // Do not encode data with no length
-        if( !lLen )
-            return lLen;
-        
-        char* pOutputBuffer = static_cast<char*>(malloc( sizeof(char) * lLen ));
-        if( !pOutputBuffer )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-        }
-        
-        memcpy(pOutputBuffer, pBuffer, lLen);
-        
-        m_stream.Encrypt( pOutputBuffer, lLen );
-        m_pOutputStream->Write( pOutputBuffer, lLen );
-        
-        free( pOutputBuffer );
-        return lLen;
-    }
-    
-    /** Close the PdfOutputStream.
-     *  This method may throw exceptions and has to be called 
-     *  before the descructor to end writing.
-     *
-     *  No more data may be written to the output device
-     *  after calling close.
-     */
-    virtual void Close() 
-    {
-    }
-    
-private:
-    PdfOutputStream* m_pOutputStream;
-    PdfRC4Stream     m_stream;
-};
-
-/** A PdfInputStream that decrypts all data read
- *  using the RC4 encryption algorithm
- */
-class PdfRC4InputStream : public PdfInputStream {
-public:
-    PdfRC4InputStream( PdfInputStream* pInputStream, unsigned char rc4key[256], unsigned char rc4last[256], 
-                      unsigned char* key, int keylen )
-    : m_pInputStream( pInputStream ), m_stream( rc4key, rc4last, key, keylen )
-    {
-    }
-    
-    virtual ~PdfRC4InputStream() 
-    {
-    }
-    
-    /** Read data from the input stream
-     *  
-     *  \param pBuffer the data will be stored into this buffer
-     *  \param lLen    the size of the buffer and number of bytes
-     *                 that will be read
-     *
-     *  \returns the number of bytes read, -1 if an error ocurred
-     *           and zero if no more bytes are available for reading.
-     */
-    virtual pdf_long Read( char* pBuffer, pdf_long lLen )
-    {
-        // Do not encode data with no length
-        if( !lLen )
-            return lLen;
-        
-        m_pInputStream->Read( pBuffer, lLen );
-        m_stream.Encrypt( pBuffer, lLen );
-        
-        return lLen;
-    }
-    
-private:
-    PdfInputStream* m_pInputStream;
-    PdfRC4Stream    m_stream;
-};
-
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-// ---------------------------
-// PdfEncrypt implementation
-// Based on code from Ulrich Telle: http://wxcode.sourceforge.net/components/wxpdfdoc/
-// ---------------------------
-
-static unsigned char padding[] =
-"\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
-
-PdfEncrypt *
-PdfEncrypt::CreatePdfEncrypt( const std::string & userPassword, 
-                             const std::string & ownerPassword, 
-                             int protection,
-                             EPdfEncryptAlgorithm eAlgorithm, 
-                             EPdfKeyLength eKeyLength )
-{
-    PdfEncrypt *pdfEncrypt = NULL;
-    
-    switch (eAlgorithm)
-    {
-        case ePdfEncryptAlgorithm_AESV2:
-            pdfEncrypt = new PdfEncryptAESV2(userPassword, ownerPassword, protection);
-            break;
-#ifdef PODOFO_HAVE_LIBIDN
-        case ePdfEncryptAlgorithm_AESV3:
-            pdfEncrypt = new PdfEncryptAESV3(userPassword, ownerPassword, protection);
-            break;
-#endif // PODOFO_HAVE_LIBIDN
-        case ePdfEncryptAlgorithm_RC4V2:           
-        case ePdfEncryptAlgorithm_RC4V1:
-        default:
-            pdfEncrypt = new PdfEncryptRC4(userPassword, ownerPassword, protection, eAlgorithm, eKeyLength);
-            break;
-    }
-    return pdfEncrypt;
-}
-
-PdfEncrypt* PdfEncrypt::CreatePdfEncrypt( const PdfObject* pObject )
-{
-    PdfEncrypt* pdfEncrypt = NULL;
-    if( !pObject->GetDictionary().HasKey( PdfName("Filter") ) ||
-       pObject->GetDictionary().GetKey( PdfName("Filter" ) )->GetName() != PdfName("Standard") )
-    {
-        std::ostringstream oss;
-        if( pObject->GetDictionary().HasKey( PdfName("Filter") ) )
-        {
-            oss << "Unsupported encryption filter: " << pObject->GetDictionary().GetKey( PdfName("Filter" ) )->GetName().GetName();
-        }
-        else
-        {
-            oss << "Encryption dictionary does not have a key /Filter.";
-        }
-        
-        PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedFilter, oss.str().c_str() );
-    }
-    
-    long lV;
-    long long lLength;
-    int rValue;
-    int pValue;
-    PdfString oValue;
-    PdfString uValue;
-    
-    try {
-        PdfString sTmp;
-        
-        lV           = static_cast<long>(pObject->GetDictionary().GetKey( PdfName("V") )->GetNumber());
-        rValue       = static_cast<int>(pObject->GetDictionary().GetKey( PdfName("R") )->GetNumber());
-        
-        pValue       = static_cast<int>(pObject->GetDictionary().GetKey( PdfName("P") )->GetNumber());
-        
-        oValue       = pObject->GetDictionary().GetKey( PdfName("O") )->GetString();        
-        uValue       = pObject->GetDictionary().GetKey( PdfName("U") )->GetString();
-        
-        if( pObject->GetDictionary().HasKey( PdfName("Length") ) )
-        {
-            lLength = pObject->GetDictionary().GetKey( PdfName("Length") )->GetNumber();
-        }
-        else
-        {
-            lLength = 0;
-        }
-        
-    } catch( PdfError & e ) {
-        e.AddToCallstack( __FILE__, __LINE__, "Invalid key in encryption dictionary" );
-        throw e;
-    }
-    
-    if( (lV == 1L) && (rValue == 2L || rValue == 3L)
-       && PdfEncrypt::IsEncryptionEnabled( ePdfEncryptAlgorithm_RC4V1 ) ) 
-    {
-        pdfEncrypt = new PdfEncryptRC4(oValue, uValue, pValue, rValue, ePdfEncryptAlgorithm_RC4V1, 40);
-    }
-    else if( (lV == 2L) && (rValue == 3L)
-            && PdfEncrypt::IsEncryptionEnabled( ePdfEncryptAlgorithm_RC4V2 ) ) 
-    {
-        // [Alexey] - lLength is long long. Please make changes in encryption algorithms
-        pdfEncrypt = new PdfEncryptRC4(oValue, uValue, pValue, rValue, ePdfEncryptAlgorithm_RC4V2, static_cast<int>(lLength));
-    }
-    else if( (lV == 4L) && (rValue == 4L)
-            && PdfEncrypt::IsEncryptionEnabled( ePdfEncryptAlgorithm_AESV2 ) ) 
-    {
-        pdfEncrypt = new PdfEncryptAESV2(oValue, uValue, pValue);      
-    }
-#ifdef PODOFO_HAVE_LIBIDN
-    else if( (lV == 5L) && (rValue == 5L) 
-            && PdfEncrypt::IsEncryptionEnabled( ePdfEncryptAlgorithm_AESV3 ) ) 
-    {
-        PdfString permsValue   = pObject->GetDictionary().GetKey( PdfName("Perms") )->GetString();
-        PdfString oeValue      = pObject->GetDictionary().GetKey( PdfName("OE") )->GetString();
-        PdfString ueValue      = pObject->GetDictionary().GetKey( PdfName("UE") )->GetString();
-        
-        pdfEncrypt = new PdfEncryptAESV3(oValue, oeValue, uValue, ueValue, pValue, permsValue);     
-    }
-#endif // PODOFO_HAVE_LIBIDN
-    else
-    {
-        std::ostringstream oss;
-        oss << "Unsupported encryption method Version=" << lV << " Revision=" << rValue;
-        PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedFilter, oss.str().c_str() );
-    }
-    return pdfEncrypt;
-}
-
-PdfEncrypt *
-PdfEncrypt::CreatePdfEncrypt(const PdfEncrypt & rhs )  
-{
-    PdfEncrypt *pdfEncrypt = NULL;
-    
-    if (rhs.m_eAlgorithm == ePdfEncryptAlgorithm_AESV2)
-        pdfEncrypt = new PdfEncryptAESV2(rhs);
-#ifdef PODOFO_HAVE_LIBIDN
-    else if (rhs.m_eAlgorithm == ePdfEncryptAlgorithm_AESV3)
-        pdfEncrypt = new PdfEncryptAESV3(rhs);
-#endif // PODOFO_HAVE_LIBIDN
-    else
-        pdfEncrypt = new PdfEncryptRC4(rhs);
-    return pdfEncrypt;
-}
-
-PdfEncrypt::~PdfEncrypt()
-{
-}
-    
-int PdfEncrypt::GetEnabledEncryptionAlgorithms()
-{
-    return PdfEncrypt::s_nEnabledEncryptionAlgorithms;
-}
-
-void PdfEncrypt::SetEnabledEncryptionAlgorithms(int nEncryptionAlgorithms)
-{
-    PdfEncrypt::s_nEnabledEncryptionAlgorithms = nEncryptionAlgorithms;
-}
-
-bool PdfEncrypt::IsEncryptionEnabled(EPdfEncryptAlgorithm eAlgorithm)
-{
-    return (PdfEncrypt::s_nEnabledEncryptionAlgorithms & eAlgorithm) != 0;
-}
-
-PdfEncrypt::PdfEncrypt( const PdfEncrypt & rhs )
-{
-    m_eAlgorithm = rhs.m_eAlgorithm;
-    m_eKeyLength = rhs.m_eKeyLength;
-    
-    m_pValue = rhs.m_pValue;
-    m_rValue = rhs.m_rValue;
-    
-    m_keyLength = rhs.m_keyLength;
-    
-    m_curReference = rhs.m_curReference;
-    m_documentId   = rhs.m_documentId;
-    m_userPass     = rhs.m_userPass;
-    m_ownerPass    = rhs.m_ownerPass;
-}
-    
-bool
-PdfEncrypt::CheckKey(unsigned char key1[32], unsigned char key2[32])
-{
-    // Check whether the right password had been given
-    bool ok = true;
-    int k;
-    int kmax = (m_rValue == 3) ? 16 : 32;
-    for (k = 0; ok && k < kmax; k++)
-    {
-        ok = ok && (key1[k] == key2[k]);
-    }
-    
-    return ok;
-}
-
-PdfEncryptMD5Base::PdfEncryptMD5Base( const PdfEncrypt & rhs ) : PdfEncrypt(rhs)
-{
-    const PdfEncrypt* ptr = &rhs;
-    
-    memcpy( m_uValue, rhs.GetUValue(), sizeof(unsigned char) * 32 );
-    memcpy( m_oValue, rhs.GetOValue(), sizeof(unsigned char) * 32 );
-    
-    memcpy( m_encryptionKey, rhs.GetEncryptionKey(), sizeof(unsigned char) * 16 );
-    
-    memcpy( m_rc4key, static_cast<const PdfEncryptMD5Base*>(ptr)->m_rc4key, sizeof(unsigned char) * 16 );
-    memcpy( m_rc4last, static_cast<const PdfEncryptMD5Base*>(ptr)->m_rc4last, sizeof(unsigned char) * 256 );
-}
-
-void
-PdfEncryptMD5Base::PadPassword(const std::string& password, unsigned char pswd[32])
-{
-    size_t m = password.length();
-    
-    if (m > 32) m = 32;
-    
-    size_t j;
-    size_t p = 0;
-    for (j = 0; j < m; j++)
-    {
-        pswd[p++] = static_cast<unsigned char>( password[j] );
-    }
-    for (j = 0; p < 32 && j < 32; j++)
-    {
-        pswd[p++] = padding[j];
-    }
-}
-
-bool
-PdfEncryptMD5Base::Authenticate(const std::string& documentID, const std::string& password,
-                                const std::string& uValue, const std::string& oValue,
-                                int pValue, int lengthValue, int rValue)
-{
-    m_pValue = pValue;
-    m_keyLength = lengthValue / 8;
-    m_rValue = rValue;
-    
-    memcpy(m_uValue, uValue.c_str(), 32);
-    memcpy(m_oValue, oValue.c_str(), 32);
-    
-    return Authenticate(password, documentID);
-}
-
-void
-PdfEncryptMD5Base::ComputeOwnerKey(unsigned char userPad[32], unsigned char ownerPad[32],
-                                   int keyLength, int revision, bool authenticate,
-                                   unsigned char ownerKey[32])
-{
-    unsigned char mkey[MD5_DIGEST_LENGTH];
-    unsigned char digest[MD5_DIGEST_LENGTH];
-    
-    MD5_CTX ctx;
-    int status = MD5_Init(&ctx);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing MD5 hashing engine" );
-    status = MD5_Update(&ctx, ownerPad, 32);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    status = MD5_Final(digest,&ctx);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    
-    if ((revision == 3) || (revision == 4))
-    {
-        // only use for the input as many bit as the key consists of
-        for (int k = 0; k < 50; ++k)
-        {
-            status = MD5_Init(&ctx);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing MD5 hashing engine" );
-            status = MD5_Update(&ctx, digest, keyLength);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-            status = MD5_Final(digest,&ctx);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-        }
-        memcpy(ownerKey, userPad, 32);
-        for (unsigned int i = 0; i < 20; ++i)
-        {
-            for (int j = 0; j < keyLength ; ++j)
-            {
-                if (authenticate)
-                    mkey[j] = static_cast<unsigned char>(static_cast<unsigned int>(digest[j] ^ (19-i)));
-                else
-                    mkey[j] = static_cast<unsigned char>(static_cast<unsigned int>(digest[j] ^ i));
-            }
-            RC4(mkey, keyLength, ownerKey, 32, ownerKey, 32);
-        }
-    }
-    else
-    {
-        RC4(digest, 5, userPad, 32, ownerKey, 32);
-    }
-}
-
-void
-PdfEncryptMD5Base::ComputeEncryptionKey(const std::string& documentId,
-                                        unsigned char userPad[32], unsigned char ownerKey[32],
-                                        int pValue, int keyLength, int revision,
-                                        unsigned char userKey[32])
-{
-    int j;
-    int k;
-    m_keyLength = keyLength / 8;
-    
-    MD5_CTX ctx;
-    int status = MD5_Init(&ctx);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing MD5 hashing engine" );
-    status = MD5_Update(&ctx, userPad, 32);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    status = MD5_Update(&ctx, ownerKey, 32);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    
-    unsigned char ext[4];
-    ext[0] = static_cast<unsigned char> ( pValue        & 0xff);
-    ext[1] = static_cast<unsigned char> ((pValue >>  8) & 0xff);
-    ext[2] = static_cast<unsigned char> ((pValue >> 16) & 0xff);
-    ext[3] = static_cast<unsigned char> ((pValue >> 24) & 0xff);
-    status = MD5_Update(&ctx, ext, 4);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    
-    unsigned int docIdLength = static_cast<unsigned int>(documentId.length());
-    unsigned char* docId = NULL;
-    if (docIdLength > 0)
-    {
-        docId = new unsigned char[docIdLength];
-        size_t j;
-        for (j = 0; j < docIdLength; j++)
-        {
-            docId[j] = static_cast<unsigned char>( documentId[j] );
-        }
-        status = MD5_Update(&ctx, docId, docIdLength);
-        if(status != 1)
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    }
-    
-    // TODO: (Revision 3 or greater) If document metadata is not being encrypted,
-    //       pass 4 bytes with the value 0xFFFFFFFF to the MD5 hash function.
-    
-    unsigned char digest[MD5_DIGEST_LENGTH];
-    status = MD5_Final(digest,&ctx);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    
-    // only use the really needed bits as input for the hash
-    if (revision == 3 || revision == 4)
-    {
-        for (k = 0; k < 50; ++k)
-        {
-            status = MD5_Init(&ctx);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing MD5 hashing engine" );
-            status = MD5_Update(&ctx, digest, m_keyLength);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-            status = MD5_Final(digest, &ctx);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-        }
-    }
-    
-    memcpy(m_encryptionKey, digest, m_keyLength);
-    
-    // Setup user key
-    if (revision == 3 || revision == 4)
-    {
-        status = MD5_Init(&ctx);
-        if(status != 1)
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing MD5 hashing engine" );
-        status = MD5_Update(&ctx, padding, 32);
-        if(status != 1)
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-        if (docId != NULL)
-        {
-            status = MD5_Update(&ctx, docId, docIdLength);
-            if(status != 1)
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-        }
-        status = MD5_Final(digest, &ctx);
-        if(status != 1)
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-        memcpy(userKey, digest, 16);
-        for (k = 16; k < 32; ++k)
-        {
-            userKey[k] = 0;
-        }
-        for (k = 0; k < 20; k++)
-        {
-            for (j = 0; j < m_keyLength; ++j)
-            {
-                digest[j] = static_cast<unsigned char>(m_encryptionKey[j] ^ k);
-            }
-            
-            RC4(digest, m_keyLength, userKey, 16, userKey, 16);
-        }
-    }
-    else
-    {
-        RC4(m_encryptionKey, m_keyLength, padding, 32, userKey, 32);
-    }
-    if (docId != NULL)
-    {
-        delete [] docId;
-    }
-}
-
-void PdfEncryptMD5Base::CreateObjKey( unsigned char objkey[16], int* pnKeyLen ) const
-{
-    const unsigned int n = static_cast<unsigned int>(m_curReference.ObjectNumber());
-    const unsigned int g = static_cast<unsigned int>(m_curReference.GenerationNumber());
-    
-    unsigned char nkey[MD5_DIGEST_LENGTH+5+4];
-    int nkeylen = m_keyLength + 5;
-    const size_t KEY_LENGTH_SIZE_T = static_cast<size_t>(m_keyLength);
-    
-    for (size_t j = 0; j < KEY_LENGTH_SIZE_T; j++)
-    {
-        nkey[j] = m_encryptionKey[j];
-    }
-    nkey[m_keyLength+0] = static_cast<unsigned char>(0xff &  n);
-    nkey[m_keyLength+1] = static_cast<unsigned char>(0xff & (n >> 8));
-    nkey[m_keyLength+2] = static_cast<unsigned char>(0xff & (n >> 16));
-    nkey[m_keyLength+3] = static_cast<unsigned char>(0xff &  g);
-    nkey[m_keyLength+4] = static_cast<unsigned char>(0xff & (g >> 8));
-    
-    if (m_rValue == 4)
-    {
-        // AES encryption needs some 'salt'
-        nkeylen += 4;
-        nkey[m_keyLength+5] = 0x73;
-        nkey[m_keyLength+6] = 0x41;
-        nkey[m_keyLength+7] = 0x6c;
-        nkey[m_keyLength+8] = 0x54;
-    }
-    
-    GetMD5Binary(nkey, nkeylen, objkey);
-    *pnKeyLen = (m_keyLength <= 11) ? m_keyLength+5 : 16;
-}
-
-PdfEncryptRC4Base::PdfEncryptRC4Base()
-{
-    m_rc4 = new RC4CryptoEngine();
-}
-
-PdfEncryptRC4Base::~PdfEncryptRC4Base()
-{
-    delete m_rc4;
-}
-    
-/**
- * RC4 is the standard encryption algorithm used in PDF format
- */
-
-void
-PdfEncryptRC4Base::RC4(const unsigned char* key, int keylen,
-                       const unsigned char* textin, pdf_long textlen,
-                       unsigned char* textout, pdf_long textoutlen)
-{
-    EVP_CIPHER_CTX* rc4 = m_rc4->getEngine();
-    
-    if(textlen != textoutlen)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing RC4 encryption engine" );
-    
-    // Don't set the key because we will modify the parameters
-    int status = EVP_EncryptInit_ex(rc4, EVP_rc4(), NULL, NULL, NULL);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing RC4 encryption engine" );
-    
-    status = EVP_CIPHER_CTX_set_key_length(rc4, keylen);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing RC4 encryption engine" );
-    
-    // We finished modifying parameters so now we can set the key
-    status = EVP_EncryptInit_ex(rc4, NULL, NULL, key, NULL);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing RC4 encryption engine" );
-    
-    int dataOutMoved;
-    status = EVP_EncryptUpdate(rc4, textout, &dataOutMoved, textin, textlen);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error RC4-encrypting data" );
-    
-    status = EVP_EncryptFinal_ex(rc4, &textout[dataOutMoved], &dataOutMoved);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error RC4-encrypting data" );
-}
-        
-void
-PdfEncryptMD5Base::GetMD5Binary(const unsigned char* data, int length, unsigned char* digest)
-{
-    int status;
-    MD5_CTX ctx;
-    status = MD5_Init(&ctx);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing MD5 hashing engine" );
-    status = MD5_Update(&ctx, data, length);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-    status = MD5_Final(digest,&ctx);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error MD5-hashing data" );
-}
-
-void PdfEncryptMD5Base::GenerateInitialVector(unsigned char iv[AES_IV_LENGTH])
-{
-    GetMD5Binary(reinterpret_cast<const unsigned char*>(m_documentId.c_str()), 
-                 static_cast<unsigned int>(m_documentId.length()), iv);
-}
-    
-PdfString PdfEncryptMD5Base::GetMD5String( const unsigned char* pBuffer, int nLength )
-{
-    char data[MD5_DIGEST_LENGTH];
-    
-    GetMD5Binary( pBuffer, nLength, reinterpret_cast<unsigned char*>(data) );
-    
-    return PdfString( data, MD5_DIGEST_LENGTH, true );
-}
-    
-void PdfEncryptMD5Base::CreateEncryptionDictionary( PdfDictionary & rDictionary ) const
-{
-    rDictionary.AddKey( PdfName("Filter"), PdfName("Standard") );
-    
-    if(m_eAlgorithm == ePdfEncryptAlgorithm_AESV2)
-    {
-        PdfDictionary cf;
-        PdfDictionary stdCf;
-        
-        stdCf.AddKey( PdfName("CFM"), PdfName("AESV2") );
-        stdCf.AddKey( PdfName("Length"), static_cast<pdf_int64>(16LL) );
-        
-        rDictionary.AddKey( PdfName("O"), PdfString( reinterpret_cast<const char*>(this->GetOValue()), 32, true ) );
-        rDictionary.AddKey( PdfName("U"), PdfString( reinterpret_cast<const char*>(this->GetUValue()), 32, true ) );
-        
-        stdCf.AddKey( PdfName("AuthEvent"), PdfName("DocOpen") );
-        cf.AddKey( PdfName("StdCF"), stdCf );
-        
-        rDictionary.AddKey( PdfName("CF"), cf );
-        rDictionary.AddKey( PdfName("StrF"), PdfName("StdCF") );
-        rDictionary.AddKey( PdfName("StmF"), PdfName("StdCF") );
-        
-        rDictionary.AddKey( PdfName("V"), static_cast<pdf_int64>(4LL) );
-        rDictionary.AddKey( PdfName("R"), static_cast<pdf_int64>(4LL) );
-        rDictionary.AddKey( PdfName("Length"), static_cast<pdf_int64>(128LL) );
-    }
-    else if(m_eAlgorithm == ePdfEncryptAlgorithm_RC4V1)
-    {
-        rDictionary.AddKey( PdfName("V"), static_cast<pdf_int64>(1LL) );
-        // Can be 2 or 3
-        rDictionary.AddKey( PdfName("R"), static_cast<pdf_int64>(m_rValue) );
-    }
-    else if(m_eAlgorithm == ePdfEncryptAlgorithm_RC4V2)
-    {
-        rDictionary.AddKey( PdfName("V"), static_cast<pdf_int64>(2LL) );
-        rDictionary.AddKey( PdfName("R"), static_cast<pdf_int64>(3LL) );
-        rDictionary.AddKey( PdfName("Length"), PdfVariant( static_cast<pdf_int64>(m_eKeyLength) ) );
-    }
-    
-    rDictionary.AddKey( PdfName("O"), PdfString( reinterpret_cast<const char*>(this->GetOValue()), 32, true ) );
-    rDictionary.AddKey( PdfName("U"), PdfString( reinterpret_cast<const char*>(this->GetUValue()), 32, true ) );
-    rDictionary.AddKey( PdfName("P"), PdfVariant( static_cast<pdf_int64>(this->GetPValue()) ) );
-}
-    
-void
-PdfEncryptRC4::GenerateEncryptionKey(const PdfString & documentId)
-{
-    unsigned char userpswd[32];
-    unsigned char ownerpswd[32];
-    
-    // Pad passwords
-    PadPassword( m_userPass,  userpswd  );
-    PadPassword( m_ownerPass, ownerpswd );
-    
-    // Compute O value
-    ComputeOwnerKey(userpswd, ownerpswd, m_keyLength, m_rValue, false, m_oValue);
-    
-    // Compute encryption key and U value
-    m_documentId = std::string( documentId.GetString(), documentId.GetLength() );
-    ComputeEncryptionKey(m_documentId, userpswd,
-                         m_oValue, m_pValue, m_eKeyLength, m_rValue, m_uValue);
-}
-    
-bool PdfEncryptRC4::Authenticate( const std::string & password, const PdfString & documentId )
-{
-    bool ok = false;
-    
-    m_documentId = std::string( documentId.GetString(), documentId.GetLength() );
-    
-    // Pad password
-    unsigned char userKey[32];
-    unsigned char pswd[32];
-    PadPassword( password, pswd );
-    
-    // Check password: 1) as user password, 2) as owner password
-    ComputeEncryptionKey(m_documentId, pswd, m_oValue, m_pValue, m_eKeyLength, m_rValue, userKey);
-    
-    ok = CheckKey(userKey, m_uValue);
-    if (!ok)
-    {
-        unsigned char userpswd[32];
-        ComputeOwnerKey( m_oValue, pswd, m_keyLength, m_rValue, true, userpswd );
-        ComputeEncryptionKey( m_documentId, userpswd, m_oValue, m_pValue, m_eKeyLength, m_rValue, userKey );
-        ok = CheckKey( userKey, m_uValue );
-        
-        if( ok )
-            m_ownerPass = password;
-    }
-    else
-        m_userPass = password;
-    
-    return ok;
-}
-    
-pdf_long PdfEncryptRC4::CalculateStreamOffset() const
-{
-    return 0;
-}
-
-pdf_long
-PdfEncryptRC4::CalculateStreamLength(pdf_long length) const
-{
-    return length;
-}
-
-void
-PdfEncryptRC4::Encrypt(const unsigned char* inStr, pdf_long inLen,
-                       unsigned char* outStr, pdf_long outLen) const
-{
-    unsigned char objkey[MD5_DIGEST_LENGTH];
-    int keylen;
-    
-    CreateObjKey( objkey, &keylen );
-    
-    const_cast<PdfEncryptRC4*>(this)->RC4(objkey, keylen, inStr, inLen, outStr, outLen);
-}
-
-void
-PdfEncryptRC4::Decrypt(const unsigned char* inStr, pdf_long inLen,
-                       unsigned char* outStr, pdf_long outLen) const
-{
-    Encrypt(inStr, inLen, outStr, outLen);
-}
-
-PdfInputStream* PdfEncryptRC4::CreateEncryptionInputStream( PdfInputStream* pInputStream )
-{
-    unsigned char objkey[MD5_DIGEST_LENGTH];
-    int keylen;
-    
-    this->CreateObjKey( objkey, &keylen );
-    
-    return new PdfRC4InputStream( pInputStream, m_rc4key, m_rc4last, objkey, keylen );
-}
-
-PdfEncryptRC4::PdfEncryptRC4(PdfString oValue, PdfString uValue, int pValue, int rValue, EPdfEncryptAlgorithm eAlgorithm, long length)
-{
-    m_pValue = pValue;
-    m_rValue = rValue;
-    m_eAlgorithm = eAlgorithm;
-    m_eKeyLength = static_cast<EPdfKeyLength>(length);
-    m_keyLength  = length/8;
-    memcpy( m_oValue, oValue.GetString(), 32 );
-    memcpy( m_uValue, uValue.GetString(), 32 );
-    
-    // Init buffers
-    memset(m_rc4key, 0, 16);
-    memset(m_rc4last, 0, 256);
-    memset(m_encryptionKey, 0, 32);
-}
-
-PdfEncryptRC4::PdfEncryptRC4( const std::string & userPassword, const std::string & ownerPassword, int protection,
-                             EPdfEncryptAlgorithm eAlgorithm, EPdfKeyLength eKeyLength )
-{
-    // setup object
-    int keyLength = static_cast<int>(eKeyLength);
-    
-    m_userPass = userPassword;
-    m_ownerPass =  ownerPassword;
-    m_eAlgorithm = eAlgorithm;
-    m_eKeyLength = eKeyLength;
-    
-    switch (eAlgorithm)
-    {
-        case ePdfEncryptAlgorithm_RC4V2:
-            keyLength = keyLength - keyLength % 8;
-            keyLength = (keyLength >= 40) ? ((keyLength <= 128) ? keyLength : 128) : 40;
-            m_rValue = 3;
-            m_keyLength = keyLength / 8;
-            break;
-        case ePdfEncryptAlgorithm_RC4V1:
-        default:
-            m_rValue = 2;
-            m_keyLength = 40 / 8;
-            break;
-        case ePdfEncryptAlgorithm_AESV2:
-#ifdef PODOFO_HAVE_LIBIDN
-        case ePdfEncryptAlgorithm_AESV3:
-#endif // PODOFO_HAVE_LIBIDN
-            break;
-    }
-    
-    // Init buffers
-    memset(m_rc4key, 0, 16);
-    memset(m_oValue, 0, 48);
-    memset(m_uValue, 0, 48);
-    memset(m_rc4last, 0, 256);
-    memset(m_encryptionKey, 0, 32);
-    
-    // Compute P value
-    m_pValue = PERMS_DEFAULT | protection;
-}
-
-PdfOutputStream* PdfEncryptRC4::CreateEncryptionOutputStream( PdfOutputStream* pOutputStream )
-{
-    unsigned char objkey[MD5_DIGEST_LENGTH];
-    int keylen;
-    
-    this->CreateObjKey( objkey, &keylen );
-    
-    return new PdfRC4OutputStream( pOutputStream, m_rc4key, m_rc4last, objkey, keylen );
-}
-    
-PdfEncryptAESBase::PdfEncryptAESBase()
-{
-    m_aes = new AESCryptoEngine();
-}
-
-PdfEncryptAESBase::~PdfEncryptAESBase()
-{
-    delete m_aes;
-}
-    
-#ifdef __APPLE__
-    void
-PdfEncryptAESBase::AES(const unsigned char* key, int keyLen, const unsigned char* iv,
-                       const unsigned char* textin, pdf_long textlen,
-                       unsigned char* textout, pdf_long textoutlen)
-{   
-    CCCryptorRef* aes = m_aes->getEngine();
-    
-    CCCryptorStatus status = CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, key, keyLen, iv, aes);
-    if(status != kCCSuccess)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing AES encryption engine" );
-    
-    pdf_long requiredOutputLength = CCCryptorGetOutputLength(*aes, textlen, true);
-    if(requiredOutputLength != textoutlen)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    size_t dataOutMoved;
-    status = CCCryptorUpdate(*aes, textin, textlen, textout, textoutlen, &dataOutMoved);
-    if(status != kCCSuccess)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    status = CCCryptorFinal(*aes, &textout[dataOutMoved], textoutlen-dataOutMoved, &dataOutMoved);
-    if(status != kCCSuccess)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-}
-    
-#else // __APPLE__
-    
-void
-PdfEncryptAESBase::AES(const unsigned char* key, int keyLen, const unsigned char* iv,
-                       const unsigned char* textin, pdf_long textlen,
-                       unsigned char* textout, pdf_long ) // To avoid Wunused-parameter
-{
-    EVP_CIPHER_CTX* aes = m_aes->getEngine();
-    
-    int status;
-    if(keyLen == PdfEncrypt::ePdfKeyLength_128/8)
-        status = EVP_EncryptInit_ex(aes, EVP_aes_128_cbc(), NULL, key, iv);
-#ifdef PODOFO_HAVE_LIBIDN
-    else if (keyLen == PdfEncrypt::ePdfKeyLength_256/8)
-        status = EVP_EncryptInit_ex(aes, EVP_aes_256_cbc(), NULL, key, iv);
-#endif
-    else
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Invalid AES key length" );
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing AES encryption engine" );
-    
-    int dataOutMoved;
-    status = EVP_EncryptUpdate(aes, textout, &dataOutMoved, textin, textlen);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    status = EVP_EncryptFinal_ex(aes, &textout[dataOutMoved], &dataOutMoved);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-}
-#endif // __APPLE__
-    
-void
-PdfEncryptAESV2::GenerateEncryptionKey(const PdfString & documentId)
-{
-    unsigned char userpswd[32];
-    unsigned char ownerpswd[32];
-    
-    // Pad passwords
-    PadPassword( m_userPass,  userpswd  );
-    PadPassword( m_ownerPass, ownerpswd );
-    
-    // Compute O value
-    ComputeOwnerKey(userpswd, ownerpswd, m_keyLength, m_rValue, false, m_oValue);
-    
-    // Compute encryption key and U value
-    m_documentId = std::string( documentId.GetString(), documentId.GetLength() );
-    ComputeEncryptionKey(m_documentId, userpswd,
-                         m_oValue, m_pValue, m_eKeyLength, m_rValue, m_uValue);
-}
-
-bool PdfEncryptAESV2::Authenticate( const std::string & password, const PdfString & documentId )
-{
-    bool ok = false;
-    
-    m_documentId = std::string( documentId.GetString(), documentId.GetLength() );
-    
-    // Pad password
-    unsigned char userKey[32];
-    unsigned char pswd[32];
-    PadPassword( password, pswd );
-    
-    // Check password: 1) as user password, 2) as owner password
-    ComputeEncryptionKey(m_documentId, pswd, m_oValue, m_pValue, m_eKeyLength, m_rValue, userKey);
-    
-    ok = CheckKey(userKey, m_uValue);
-    if (!ok)
-    {
-        unsigned char userpswd[32];
-        ComputeOwnerKey( m_oValue, pswd, m_keyLength, m_rValue, true, userpswd );
-        ComputeEncryptionKey( m_documentId, userpswd, m_oValue, m_pValue, m_eKeyLength, m_rValue, userKey );
-        ok = CheckKey( userKey, m_uValue );
-        
-        if( ok )
-            m_ownerPass = password;
-    }
-    else
-        m_userPass = password;
-    
-    return ok;
-}
-    
-pdf_long PdfEncryptAESV2::CalculateStreamOffset() const
-{
-    return AES_IV_LENGTH;
-}
-    
-void
-PdfEncryptAESV2::Encrypt(const unsigned char* inStr, pdf_long inLen,
-                         unsigned char* outStr, pdf_long outLen) const
-{
-    unsigned char objkey[MD5_DIGEST_LENGTH];
-    int keylen;
-    
-    CreateObjKey( objkey, &keylen );
-    
-    pdf_long offset = CalculateStreamOffset();
-    const_cast<PdfEncryptAESV2*>(this)->GenerateInitialVector(outStr);
-    
-    const_cast<PdfEncryptAESV2*>(this)->AES(objkey, keylen, outStr, inStr, inLen, &outStr[offset], outLen-offset);
-}
-
-void
-PdfEncryptAESV2::Decrypt(const unsigned char* inStr, pdf_long inLen,
-                         unsigned char* outStr, pdf_long outLen) const
-{
-    unsigned char objkey[MD5_DIGEST_LENGTH];
-    int keylen;
-    
-    CreateObjKey( objkey, &keylen );
-    
-    pdf_long offset = CalculateStreamOffset();
-    
-    const_cast<PdfEncryptAESV2*>(this)->AES(objkey, keylen, inStr, &inStr[offset], inLen-offset, outStr, outLen);
-}
-    
-PdfEncryptAESV2::PdfEncryptAESV2( const std::string & userPassword, const std::string & ownerPassword, int protection) : PdfEncryptAESBase()
-{
-    // setup object
-    m_userPass = userPassword;
-    m_ownerPass = ownerPassword;
-    m_eAlgorithm = ePdfEncryptAlgorithm_AESV2;
-    
-    m_rValue = 4;
-    m_eKeyLength = ePdfKeyLength_128;
-    m_keyLength = ePdfKeyLength_128 / 8;
-    
-    // Init buffers
-    memset(m_rc4key, 0 ,16);
-    memset(m_rc4last, 0 ,256);
-    memset(m_oValue, 0 ,48);
-    memset(m_uValue, 0 ,48);
-    memset(m_encryptionKey, 0 ,32);
-    
-    // Compute P value
-    m_pValue = PERMS_DEFAULT | protection;
-}
-    
-PdfEncryptAESV2::PdfEncryptAESV2(PdfString oValue, PdfString uValue, int pValue) : PdfEncryptAESBase()
-{
-    m_pValue = pValue;
-    m_eAlgorithm = ePdfEncryptAlgorithm_AESV2;
-    
-    m_eKeyLength = ePdfKeyLength_128;
-    m_keyLength  = ePdfKeyLength_128 / 8;
-    m_rValue	 = 4;
-    memcpy( m_oValue, oValue.GetString(), 32 );
-    memcpy( m_uValue, uValue.GetString(), 32 );
-    
-    // Init buffers
-    memset(m_rc4key, 0 ,16);
-    memset(m_rc4last, 0 ,256);
-    memset(m_encryptionKey, 0 ,32);
-}
-
-pdf_long
-PdfEncryptAESV2::CalculateStreamLength(pdf_long length) const
-{
-    pdf_long realLength = ((length + 15) & ~15) + AES_IV_LENGTH;
-    if (length % 16 == 0)
-    {
-        realLength += 16;
-    }
-    
-    return realLength;
-}
-    
-PdfInputStream* PdfEncryptAESV2::CreateEncryptionInputStream( PdfInputStream* )
-{
-    /*unsigned char objkey[MD5_DIGEST_LENGTH];
-     int keylen;
-     
-     this->CreateObjKey( objkey, &keylen );*/
-    
-    PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "CreateEncryptionInputStream does not yet support AESV2" );
-}
-    
-PdfOutputStream* PdfEncryptAESV2::CreateEncryptionOutputStream( PdfOutputStream* )
-{
-    /*unsigned char objkey[MD5_DIGEST_LENGTH];
-     int keylen;
-     
-     this->CreateObjKey( objkey, &keylen );*/
-    
-    PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "CreateEncryptionOutputStream does not yet support AESV2" );
-}
-    
-#ifdef PODOFO_HAVE_LIBIDN
-    
-PdfEncryptSHABase::PdfEncryptSHABase( const PdfEncrypt & rhs ) : PdfEncrypt(rhs)
-{
-    const PdfEncrypt* ptr = &rhs;
-    
-    memcpy( m_uValue, rhs.GetUValue(), sizeof(unsigned char) * 48 );
-    memcpy( m_oValue, rhs.GetOValue(), sizeof(unsigned char) * 48 );
-    
-    memcpy( m_encryptionKey, rhs.GetEncryptionKey(), sizeof(unsigned char) * 32 );
-    
-    memcpy( m_permsValue, static_cast<const PdfEncryptSHABase*>(ptr)->m_permsValue, sizeof(unsigned char) * 16 );
-    
-    memcpy( m_ueValue, static_cast<const PdfEncryptSHABase*>(ptr)->m_ueValue, sizeof(unsigned char) * 32 );
-    memcpy( m_oeValue, static_cast<const PdfEncryptSHABase*>(ptr)->m_oeValue, sizeof(unsigned char) * 32 );
-}
-    
-void PdfEncryptSHABase::ComputeUserKey(const unsigned char * userpswd, int len)
-{
-    // Generate User Salts
-    unsigned char vSalt[8];
-    unsigned char kSalt[8];
-    
-    for(int i=0; i< 8 ; i++)
-    {
-        vSalt[i] = rand()%255;
-        kSalt[i] = rand()%255;
-    }
-    
-    // Generate hash for U
-    unsigned char hashValue[32];
-    
-    SHA256_CTX context;
-    SHA256_Init(&context);
-    
-    SHA256_Update(&context, userpswd, len);
-    SHA256_Update(&context, vSalt, 8);
-    SHA256_Final(hashValue, &context);
-    
-    // U = hash + validation salt + key salt
-    memcpy(m_uValue, hashValue, 32);
-    memcpy(m_uValue+32, vSalt, 8);
-    memcpy(m_uValue+32+8, kSalt, 8);
-    
-    // Generate hash for UE
-    SHA256_Init(&context);
-    SHA256_Update(&context, userpswd, len);
-    SHA256_Update(&context, kSalt, 8);
-    SHA256_Final(hashValue, &context);
-    
-    // UE = AES-256 encoded file encryption key with key=hash
-    // CBC mode, no padding, init vector=0
-    
-    EVP_CIPHER_CTX *aes;
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    aes = EVP_CIPHER_CTX_new();
-    #else
-    EVP_CIPHER_CTX aes_local;
-    EVP_CIPHER_CTX_init(&aes_local);
-    aes = &aes_local;
-    #endif
-    
-    int status = EVP_EncryptInit_ex(aes, EVP_aes_256_cbc(), NULL, hashValue, NULL);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing AES encryption engine" );
-    EVP_CIPHER_CTX_set_padding(aes, 0); // disable padding
-    
-    int dataOutMoved;
-    status = EVP_EncryptUpdate(aes, m_ueValue, &dataOutMoved, m_encryptionKey, m_keyLength);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    status = EVP_EncryptFinal_ex(aes, &m_ueValue[dataOutMoved], &dataOutMoved);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    EVP_CIPHER_CTX_free(aes);
-    #else
-    EVP_CIPHER_CTX_cleanup(&aes_local);
-    #endif
-}
-
-void PdfEncryptSHABase::ComputeOwnerKey(const unsigned char * ownerpswd, int len)
-{
-    // Generate User Salts
-    unsigned char vSalt[8];
-    unsigned char kSalt[8];
-    
-    for(int i=0; i< 8 ; i++)
-    {
-        vSalt[i] = rand()%255;
-        kSalt[i] = rand()%255;
-    }
-    
-    // Generate hash for O
-    unsigned char hashValue[32];
-    SHA256_CTX context;
-    SHA256_Init(&context);
-    SHA256_Update(&context, ownerpswd, len);
-    SHA256_Update(&context, vSalt, 8);
-    SHA256_Update(&context, m_uValue, 48);
-    SHA256_Final(hashValue, &context);
-    
-    // O = hash + validation salt + key salt
-    memcpy(m_oValue, hashValue, 32);
-    memcpy(m_oValue+32, vSalt, 8);
-    memcpy(m_oValue+32+8, kSalt, 8);
-    
-    // Generate hash for OE
-    SHA256_Init(&context);
-    SHA256_Update(&context, ownerpswd, len);
-    SHA256_Update(&context, kSalt, 8);
-    SHA256_Update(&context, m_uValue, 48);
-    SHA256_Final(hashValue, &context);
-    
-    // OE = AES-256 encoded file encryption key with key=hash
-    // CBC mode, no padding, init vector=0
-    
-    EVP_CIPHER_CTX *aes;
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    aes = EVP_CIPHER_CTX_new();
-    #else
-    EVP_CIPHER_CTX aes_local;
-    EVP_CIPHER_CTX_init(&aes_local);
-    aes = &aes_local;
-    #endif
-    
-    int status = EVP_EncryptInit_ex(aes, EVP_aes_256_cbc(), NULL, hashValue, NULL);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing AES encryption engine" );
-    EVP_CIPHER_CTX_set_padding(aes, 0); // disable padding
-    
-    int dataOutMoved;
-    status = EVP_EncryptUpdate(aes, m_oeValue, &dataOutMoved, m_encryptionKey, m_keyLength);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    status = EVP_EncryptFinal_ex(aes, &m_oeValue[dataOutMoved], &dataOutMoved);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    EVP_CIPHER_CTX_free(aes);
-    #else
-    EVP_CIPHER_CTX_cleanup(&aes_local);
-    #endif
-}
-
-void PdfEncryptSHABase::PreprocessPassword( const std::string &password, unsigned char* outBuf, int &len)
-{
-    char* password_sasl;
-    
-    if (stringprep_profile(password.c_str(), &password_sasl, "SASLprep", STRINGPREP_NO_UNASSIGNED) != STRINGPREP_OK)
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidPassword, "Error processing password through SASLprep" );
-    }
-    
-    int l = strlen(password_sasl);
-    len = l > 127 ? 127 : l;
-    
-    memcpy(outBuf, password_sasl, len);
-    free(password_sasl);
-}
-
-void
-PdfEncryptSHABase::ComputeEncryptionKey()
-{
-    // Seed once for all
-    srand ( time(NULL) );
-    
-    for(int i=0; i< m_keyLength ; i++)
-        m_encryptionKey[i] = rand()%255;
-}
-    
-bool
-PdfEncryptSHABase::Authenticate(const std::string& documentID, const std::string& password,
-                                const std::string& uValue, const std::string& ueValue,
-                                const std::string& oValue, const std::string& oeValue,
-                                int pValue, const std::string& permsValue,
-                                int lengthValue, int rValue)
-{
-    m_pValue = pValue;
-    m_keyLength = lengthValue / 8;
-    m_rValue = rValue;
-    
-    memcpy(m_uValue, uValue.c_str(), 48);
-    memcpy(m_ueValue, ueValue.c_str(), 32);
-    memcpy(m_oValue, oValue.c_str(), 48);
-    memcpy(m_oeValue, oeValue.c_str(), 32);
-    memcpy(m_permsValue, permsValue.c_str(), 16);
-    
-    return Authenticate(password, documentID);
-}
-    
-void PdfEncryptSHABase::GenerateInitialVector(unsigned char iv[AES_IV_LENGTH])
-{
-    for (int i=0; i<AES_IV_LENGTH; i++)
-        iv[i] = rand()%255;
-}
-    
-void PdfEncryptSHABase::CreateEncryptionDictionary( PdfDictionary & rDictionary ) const
-{
-    rDictionary.AddKey( PdfName("Filter"), PdfName("Standard") );
-    
-    PdfDictionary cf;
-    PdfDictionary stdCf;
-    
-    rDictionary.AddKey( PdfName("V"), static_cast<pdf_int64>(5LL) );
-    rDictionary.AddKey( PdfName("R"), static_cast<pdf_int64>(5LL) );
-    rDictionary.AddKey( PdfName("Length"), static_cast<pdf_int64>(256LL) );
-    
-    stdCf.AddKey( PdfName("CFM"), PdfName("AESV3") );
-    stdCf.AddKey( PdfName("Length"), static_cast<pdf_int64>(32LL) );
-    
-    rDictionary.AddKey( PdfName("O"), PdfString( reinterpret_cast<const char*>(this->GetOValue()), 48, true ) );
-    rDictionary.AddKey( PdfName("OE"), PdfString( reinterpret_cast<const char*>(this->GetOEValue()), 32, true ) );
-    rDictionary.AddKey( PdfName("U"), PdfString( reinterpret_cast<const char*>(this->GetUValue()), 48, true ) );
-    rDictionary.AddKey( PdfName("UE"), PdfString( reinterpret_cast<const char*>(this->GetUEValue()), 32, true ) );
-    rDictionary.AddKey( PdfName("Perms"), PdfString( reinterpret_cast<const char*>(this->GetPermsValue()), 16, true ) );
-    
-    stdCf.AddKey( PdfName("AuthEvent"), PdfName("DocOpen") );
-    cf.AddKey( PdfName("StdCF"), stdCf );
-    
-    rDictionary.AddKey( PdfName("CF"), cf );
-    rDictionary.AddKey( PdfName("StrF"), PdfName("StdCF") );
-    rDictionary.AddKey( PdfName("StmF"), PdfName("StdCF") );
-    
-    rDictionary.AddKey( PdfName("P"), PdfVariant( static_cast<pdf_int64>(this->GetPValue()) ) );
-}
-    
-void
-PdfEncryptAESV3::GenerateEncryptionKey(const PdfString &)
-{
-    // Prepare passwords
-    unsigned char userpswd[127];
-    unsigned char ownerpswd[127];
-    int userpswdLen;
-    int ownerpswdLen;
-    PreprocessPassword(m_userPass, userpswd, userpswdLen);
-    PreprocessPassword(m_ownerPass, ownerpswd, ownerpswdLen);
-    
-    // Compute encryption key
-    ComputeEncryptionKey();
-    
-    // Compute U and UE values
-    ComputeUserKey(userpswd, userpswdLen);
-    
-    // Compute O and OE value
-    ComputeOwnerKey(ownerpswd, ownerpswdLen);
-    
-    // Compute Perms value
-    unsigned char perms[16];
-    // First 4 bytes = 32bits permissions
-    perms[3] = (m_pValue >> 24) & 0xff;
-    perms[2] = (m_pValue >> 16) & 0xff;
-    perms[1] = (m_pValue >> 8) & 0xff;
-    perms[0] = m_pValue & 0xff;
-    // Placeholder for future versions that may need 64-bit permissions
-    perms[4] = 0xff;
-    perms[5] = 0xff;
-    perms[6] = 0xff;
-    perms[7] = 0xff;
-    // TODO : if EncryptMetadata is false, this value shoud be set to 'F'
-    perms[8] = 'T';
-    // Next 3 bytes are mandatory
-    perms[9] = 'a';
-    perms[10] = 'd';
-    perms[11] = 'b';
-    // Next 4 bytes are ignored
-    perms[12] = 0;
-    perms[13] = 0;
-    perms[14] = 0;
-    perms[15] = 0;
-    
-    // Encrypt Perms value
-    
-    EVP_CIPHER_CTX *aes;
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    aes = EVP_CIPHER_CTX_new();
-    #else
-    EVP_CIPHER_CTX aes_local;
-    EVP_CIPHER_CTX_init(&aes_local);
-    aes = &aes_local;
-    #endif
-    
-    int status = EVP_EncryptInit_ex(aes, EVP_aes_256_ecb(), NULL, m_encryptionKey, NULL);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error initializing AES encryption engine" );
-    EVP_CIPHER_CTX_set_padding(aes, 0); // disable padding
-    
-    int dataOutMoved;
-    status = EVP_EncryptUpdate(aes, m_permsValue, &dataOutMoved, perms, 16);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    status = EVP_EncryptFinal_ex(aes, &m_permsValue[dataOutMoved], &dataOutMoved);
-    if(status != 1)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Error AES-encrypting data" );
-    
-    #ifdef PODOFO_HAVE_OPENSSL_1_1
-    EVP_CIPHER_CTX_free(aes);
-    #else
-    EVP_CIPHER_CTX_cleanup(&aes_local);
-    #endif
-}
-
-bool PdfEncryptAESV3::Authenticate( const std::string & password, const PdfString & )
-{
-    bool ok = false;
-    
-    // Prepare password
-    unsigned char pswd_sasl[127];
-    int pswdLen;
-    PreprocessPassword(password, pswd_sasl, pswdLen);
-    
-    unsigned char valSalt[8];
-    unsigned char keySalt[8];
-    
-    // Test 1: is it the user key ?
-    memcpy(valSalt, &m_uValue[32], 8);
-    memcpy(keySalt, &m_uValue[40], 8);
-    unsigned char hashValue[32];
-    SHA256_CTX context;
-    SHA256_Init(&context);
-    SHA256_Update(&context, pswd_sasl, pswdLen);
-    SHA256_Update(&context, valSalt, 8);
-    SHA256_Final(hashValue, &context);
-    
-    ok = CheckKey(hashValue, m_uValue);
-    if(!ok)
-    {
-        // Test 2: is it the owner key ?
-        memcpy(valSalt, &m_oValue[32], 8);
-        memcpy(keySalt, &m_oValue[40], 8);
-        SHA256_Init(&context);
-        SHA256_Update(&context, pswd_sasl, pswdLen);
-        SHA256_Update(&context, valSalt, 8);
-        SHA256_Update(&context, m_uValue, 48);
-        SHA256_Final(hashValue, &context);
-        
-        ok = CheckKey(hashValue, m_oValue);
-        
-        if(ok)
-            m_ownerPass = password;
-    }
-    else
-        m_userPass = password;
-    
-    // TODO Validate permissions (or not...)
-    
-    return ok;
-}
-
-pdf_long PdfEncryptAESV3::CalculateStreamOffset() const
-{
-    return AES_IV_LENGTH;
-}
-
-void
-PdfEncryptAESV3::Encrypt(const unsigned char* inStr, pdf_long inLen,
-                         unsigned char* outStr, pdf_long outLen) const
-{
-    pdf_long offset = CalculateStreamOffset();
-    const_cast<PdfEncryptAESV3*>(this)->GenerateInitialVector(outStr);
-    
-    const_cast<PdfEncryptAESV3*>(this)->AES(const_cast<unsigned char*>(m_encryptionKey), m_keyLength, outStr, inStr, inLen, &outStr[offset], outLen-offset);
-}
-
-void
-PdfEncryptAESV3::Decrypt(const unsigned char* inStr, pdf_long inLen,
-                         unsigned char* outStr, pdf_long outLen) const
-{
-    pdf_long offset = CalculateStreamOffset();
-    
-    const_cast<PdfEncryptAESV3*>(this)->AES(const_cast<unsigned char*>(m_encryptionKey), m_keyLength, inStr, &inStr[offset], inLen-offset, outStr, outLen);
-}
-
-PdfEncryptAESV3::PdfEncryptAESV3( const std::string & userPassword, const std::string & ownerPassword, int protection) : PdfEncryptAESBase()
-{
-    // setup object
-    m_userPass = userPassword;
-    m_ownerPass = ownerPassword;
-    m_eAlgorithm = ePdfEncryptAlgorithm_AESV3;
-    
-    m_rValue = 5;
-    m_eKeyLength = ePdfKeyLength_256;
-    m_keyLength = ePdfKeyLength_256 / 8;
-    
-    // Init buffers
-    memset(m_oValue, 0 ,48);
-    memset(m_uValue, 0 ,48);
-    memset(m_encryptionKey, 0 ,32);
-    memset(m_ueValue, 0 ,32);
-    memset(m_oeValue, 0 ,32);
-    
-    // Compute P value
-    m_pValue = PERMS_DEFAULT | protection;
-}
-
-PdfEncryptAESV3::PdfEncryptAESV3(PdfString oValue,PdfString oeValue, PdfString uValue, PdfString ueValue, int pValue, PdfString permsValue) : PdfEncryptAESBase()
-{
-    m_pValue = pValue;
-    m_eAlgorithm = ePdfEncryptAlgorithm_AESV3;
-    
-    m_eKeyLength = ePdfKeyLength_256;
-    m_keyLength  = ePdfKeyLength_256 / 8;
-    m_rValue	 = 5;
-    memcpy( m_oValue, oValue.GetString(), 48 );
-    memcpy( m_oeValue, oeValue.GetString(), 32 );
-    memcpy( m_uValue, uValue.GetString(), 48 );
-    memcpy( m_ueValue, ueValue.GetString(), 32 );
-    memcpy( m_permsValue, permsValue.GetString(), 16 );
-    memset(m_encryptionKey, 0 ,32);
-}
-
-pdf_long
-PdfEncryptAESV3::CalculateStreamLength(pdf_long length) const
-{
-    pdf_long realLength = ((length + 15) & ~15) + AES_IV_LENGTH;
-    if (length % 16 == 0)
-    {
-        realLength += 16;
-    }
-    
-    return realLength;
-}
-
-PdfInputStream* PdfEncryptAESV3::CreateEncryptionInputStream( PdfInputStream* )
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "CreateEncryptionInputStream does not yet support AESV3" );
-}
-
-PdfOutputStream* PdfEncryptAESV3::CreateEncryptionOutputStream( PdfOutputStream* )
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "CreateEncryptionOutputStream does not yet support AESV3" );
-}
-    
-#endif // PODOFO_HAVE_LIBIDN
-#else  // PODOFO_HAVE_OPENSSL
-PdfEncrypt *
-PdfEncrypt::CreatePdfEncrypt( const std::string & userPassword, 
-                              const std::string & ownerPassword, 
-                              int protection,
-                              EPdfEncryptAlgorithm eAlgorithm, 
-                              EPdfKeyLength eKeyLength )
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time" );
-    return NULL;
-}
-
-PdfEncrypt* PdfEncrypt::CreatePdfEncrypt( const PdfObject* pObject )
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time" );
-    return NULL;
-}
-
-PdfEncrypt *
-PdfEncrypt::CreatePdfEncrypt(const PdfEncrypt & rhs )  
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncrypt::CreatePdfEncrypt: Encryption support was disabled during compile time" );
-    return NULL;
-}
-
-PdfEncrypt::~PdfEncrypt()
-{
-}
-
-PdfString PdfEncryptMD5Base::GetMD5String( const unsigned char* pBuffer, int nLength )
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_NotCompiled, "PdfEncryptMD5Base::GetMD5String: Encryption support was disabled during compile time" );
-    return PdfString();
-}
-
-#endif // PODOFO_HAVE_OPENSSL
-}
--- src/base/PdfError.cpp.orig	2024-06-29 17:32:05.050339968 +0000
+++ src/base/PdfError.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,649 +0,0 @@
-/**************************************************************************
- *    Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-// PdfError.h doesn't, and can't, include PdfDefines.h so we do so here.
-// PdfDefines.h will include PdfError.h for us.
-#include "PdfDefines.h"
-#include "PdfDefinesPrivate.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-
-namespace PoDoFo {
-
-bool PdfError::s_DgbEnabled = true;
-bool PdfError::s_LogEnabled = true;
-
-// OC 17.08.2010 New to optionally replace stderr output by a callback:
-PdfError::LogMessageCallback* PdfError::m_fLogMessageCallback = NULL;
-
-//static
-PdfError::LogMessageCallback* PdfError::SetLogMessageCallback(LogMessageCallback* fLogMessageCallback)
-{
-    PdfError::LogMessageCallback* old_fLogMessageCallback = m_fLogMessageCallback;
-    m_fLogMessageCallback = fLogMessageCallback;
-    return old_fLogMessageCallback;
-}
-
-PdfErrorInfo::PdfErrorInfo()
-    : m_nLine( -1 )
-{
-}
-
-PdfErrorInfo::PdfErrorInfo( int line, const char* pszFile, const char* pszInfo )
-    : m_nLine( line ), m_sFile( pszFile ? pszFile : "" ), m_sInfo( pszInfo ? pszInfo : "" )
-{
-
-}
- 
-PdfErrorInfo::PdfErrorInfo( int line, const char* pszFile, const wchar_t* pszInfo )
-    : m_nLine( line ), m_sFile( pszFile ? pszFile : "" ), m_swInfo( pszInfo ? pszInfo : L"" )
-{
-
-}
-PdfErrorInfo::PdfErrorInfo( const PdfErrorInfo & rhs )
-{
-    this->operator=( rhs );
-}
-
-const PdfErrorInfo & PdfErrorInfo::operator=( const PdfErrorInfo & rhs )
-{
-    m_nLine  = rhs.m_nLine;
-    m_sFile  = rhs.m_sFile;
-    m_sInfo  = rhs.m_sInfo;
-    m_swInfo = rhs.m_swInfo;
-
-    return *this;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-
-PdfError::PdfError()
-{
-    m_error = ePdfError_ErrOk;
-}
-
-PdfError::PdfError( const EPdfError & eCode, const char* pszFile, int line, 
-                    const char* pszInformation )
-{
-    this->SetError( eCode, pszFile, line, pszInformation );
-}
-
-PdfError::PdfError( const PdfError & rhs )
-    : std::exception()
-{
-    this->operator=( rhs );
-}
-
-PdfError::~PdfError() throw()
-{
-}
-    
-const PdfError & PdfError::operator=( const PdfError & rhs )
-{
-    m_error     = rhs.m_error;
-    m_callStack = rhs.m_callStack;
-
-    return *this;
-}
-
-const PdfError & PdfError::operator=( const EPdfError & eCode )
-{
-    m_error = eCode;
-    m_callStack.clear();
-    
-    return *this;
-}
-
-bool PdfError::operator==( const PdfError & rhs )
-{
-    return this->operator==( rhs.m_error );
-}
-
-bool PdfError::operator==( const EPdfError & eCode )
-{
-    return m_error == eCode;
-}
-
-bool PdfError::operator!=( const PdfError & rhs )
-{
-    return this->operator!=( rhs.m_error );
-}
-
-bool PdfError::operator!=( const EPdfError & eCode )
-{
-    return !this->operator==( eCode );
-}
-
-void PdfError::PrintErrorMsg() const
-{
-    TCIDequeErrorInfo it = m_callStack.begin();
-    const char* pszMsg   = PdfError::ErrorMessage( m_error );
-    const char* pszName  = PdfError::ErrorName( m_error );
-
-    int i                = 0;
-
-    PdfError::LogErrorMessage( eLogSeverity_Error, "\n\nPoDoFo encounter an error. Error: %i %s\n", m_error, pszName ? pszName : "" );
-
-    if( pszMsg )
-        PdfError::LogErrorMessage( eLogSeverity_Error, "\tError Description: %s\n", pszMsg );
-    
-    if( m_callStack.size() )
-        PdfError::LogErrorMessage( eLogSeverity_Error, "\tCallstack:\n" );
-
-    while( it != m_callStack.end() )
-    {
-        if( !(*it).GetFilename().empty() )
-            PdfError::LogErrorMessage( eLogSeverity_Error, "\t#%i Error Source: %s:%i\n", i, (*it).GetFilename().c_str(), (*it).GetLine() );
-
-        if( !(*it).GetInformation().empty() )
-            PdfError::LogErrorMessage( eLogSeverity_Error, "\t\tInformation: %s\n", (*it).GetInformation().c_str() );
-
-        if( !(*it).GetInformationW().empty() )
-            PdfError::LogErrorMessage( eLogSeverity_Error, L"\t\tInformation: %s\n", (*it).GetInformationW().c_str() );
-
-        ++i;
-        ++it;
-    }
-
-        
-    PdfError::LogErrorMessage( eLogSeverity_Error, "\n\n" );
-}
-
-const char* PdfError::what() const throw()
-{
-    return PdfError::ErrorName( m_error );
-}
-
-const char* PdfError::ErrorName( EPdfError eCode )
-{
-    const char* pszMsg = NULL;
-
-    switch( eCode ) 
-    {
-        case ePdfError_ErrOk:
-            pszMsg = "ePdfError_ErrOk"; 
-            break;
-        case ePdfError_TestFailed:
-            pszMsg = "ePdfError_TestFailed"; 
-            break;
-        case ePdfError_InvalidHandle:
-            pszMsg = "ePdfError_InvalidHandle"; 
-            break;
-        case ePdfError_FileNotFound:
-            pszMsg = "ePdfError_FileNotFound"; 
-            break;
-        case ePdfError_InvalidDeviceOperation:
-            pszMsg = "ePdfError_InvalidDeviceOperation";
-            break;
-        case ePdfError_UnexpectedEOF:
-            pszMsg = "ePdfError_UnexpectedEOF"; 
-            break;
-        case ePdfError_OutOfMemory:
-            pszMsg = "ePdfError_OutOfMemory"; 
-            break;
-        case ePdfError_ValueOutOfRange:
-            pszMsg = "ePdfError_ValueOutOfRange"; 
-            break;
-        case ePdfError_InternalLogic:
-            pszMsg = "ePdfError_InternalLogic";
-            break;
-        case ePdfError_InvalidEnumValue:
-            pszMsg = "ePdfError_InvalidEnumValue";
-            break;
-        case ePdfError_BrokenFile:
-            pszMsg = "ePdfError_BrokenFile";
-            break;
-        case ePdfError_PageNotFound:
-            pszMsg = "ePdfError_PageNotFound";
-            break;
-        case ePdfError_NoPdfFile:
-            pszMsg = "ePdfError_NoPdfFile"; 
-            break;
-        case ePdfError_NoXRef:
-            pszMsg = "ePdfError_NoXRef"; 
-            break;
-        case ePdfError_NoTrailer:
-            pszMsg = "ePdfError_NoTrailer"; 
-            break;
-        case ePdfError_NoNumber:
-            pszMsg = "ePdfError_NoNumber"; 
-            break;
-        case ePdfError_NoObject:
-            pszMsg = "ePdfError_NoObject"; 
-            break;
-        case ePdfError_NoEOFToken:
-            pszMsg = "ePdfError_NoEOFToken"; 
-            break;
-        case ePdfError_InvalidTrailerSize:
-            pszMsg = "ePdfError_InvalidTrailerSize"; 
-            break;
-        case ePdfError_InvalidLinearization:
-            pszMsg = "ePdfError_InvalidLinearization"; 
-            break;
-        case ePdfError_InvalidDataType:
-            pszMsg = "ePdfError_InvalidDataType"; 
-            break;
-        case ePdfError_InvalidXRef:
-            pszMsg = "ePdfError_InvalidXRef"; 
-            break;
-        case ePdfError_InvalidXRefStream:
-            pszMsg = "ePdfError_InvalidXRefStream"; 
-            break;
-        case ePdfError_InvalidXRefType:
-            pszMsg = "ePdfError_InvalidXRefType"; 
-            break;
-        case ePdfError_InvalidPredictor:
-            pszMsg = "ePdfError_InvalidPredictor"; 
-            break;
-        case ePdfError_InvalidStrokeStyle:
-            pszMsg = "ePdfError_InvalidStrokeStyle"; 
-            break;
-        case ePdfError_InvalidHexString:
-            pszMsg = "ePdfError_InvalidHexString"; 
-            break;
-        case ePdfError_InvalidStream:
-            pszMsg = "ePdfError_InvalidStream"; 
-            break;
-        case ePdfError_InvalidStreamLength:
-            pszMsg = "ePdfError_InvalidStream"; 
-            break;
-        case ePdfError_InvalidKey:
-            pszMsg = "ePdfError_InvalidKey";
-            break;
-        case ePdfError_InvalidName:
-            pszMsg = "ePdfError_InvalidName";
-            break;
-        case ePdfError_InvalidEncryptionDict:
-            pszMsg = "ePdfError_InvalidEncryptionDict";    /**< The encryption dictionary is invalid or misses a required key */
-            break;
-        case ePdfError_InvalidPassword:                    /**< The password used to open the PDF file was invalid */
-            pszMsg = "ePdfError_InvalidPassword";
-            break;
-        case ePdfError_InvalidFontFile:
-            pszMsg = "ePdfError_InvalidFontFile";
-            break;
-        case ePdfError_InvalidContentStream:
-            pszMsg = "ePdfError_InvalidContentStream";
-            break;
-        case ePdfError_UnsupportedFilter:
-            pszMsg = "ePdfError_UnsupportedFilter"; 
-            break;
-        case ePdfError_UnsupportedFontFormat:    /**< This font format is not supported by PoDoFO. */
-            pszMsg = "ePdfError_UnsupportedFontFormat";
-            break;
-        case ePdfError_ActionAlreadyPresent:
-            pszMsg = "ePdfError_ActionAlreadyPresent"; 
-            break;
-        case ePdfError_WrongDestinationType:
-            pszMsg = "ePdfError_WrongDestinationType";
-            break;
-        case ePdfError_MissingEndStream:
-            pszMsg = "ePdfError_MissingEndStream"; 
-            break;
-        case ePdfError_Date:
-            pszMsg = "ePdfError_Date"; 
-            break;
-        case ePdfError_Flate:
-            pszMsg = "ePdfError_Flate"; 
-            break;
-        case ePdfError_FreeType:
-            pszMsg = "ePdfError_FreeType"; 
-            break;
-        case ePdfError_SignatureError:
-            pszMsg = "ePdfError_SignatureError";
-            break;
-        case ePdfError_MutexError:
-            pszMsg = "ePdfError_MutexError";
-            break;
-        case ePdfError_UnsupportedImageFormat:    /**< This image format is not supported by PoDoFO. */
-            pszMsg = "ePdfError_UnsupportedImageFormat";
-            break;
-        case ePdfError_CannotConvertColor:       /**< This color format cannot be converted. */
-            pszMsg = "ePdfError_CannotConvertColor";
-            break;
-        case ePdfError_NotImplemented:
-            pszMsg = "ePdfError_NotImplemented";
-            break;
-        case ePdfError_NotCompiled:
-            pszMsg = "ePdfError_NotCompiled";
-            break;
-        case ePdfError_DestinationAlreadyPresent:
-            pszMsg = "ePdfError_DestinationAlreadyPresent"; 
-            break;
-        case ePdfError_ChangeOnImmutable:
-            pszMsg = "ePdfError_ChangeOnImmutable";
-            break;
-        case ePdfError_Unknown:
-            pszMsg = "ePdfError_Unknown"; 
-            break;
-        default:
-            break;
-    }
-
-    return pszMsg;
-}
-
-const char* PdfError::ErrorMessage( EPdfError eCode )
-{
-    const char* pszMsg = NULL;
-
-    switch( eCode ) 
-    {
-        case ePdfError_ErrOk:
-            pszMsg = "No error during execution.";
-            break;
-        case ePdfError_TestFailed:
-            pszMsg = "An error curred in an automatic test included in PoDoFo.";
-            break;
-        case ePdfError_InvalidHandle:
-            pszMsg = "A NULL handle was passed, but initialized data was expected.";
-            break;
-        case ePdfError_FileNotFound:
-            pszMsg = "The specified file was not found.";
-            break;
-        case ePdfError_InvalidDeviceOperation:
-            pszMsg = "Tried to do something unsupported to an I/O device like seek a non-seekable input device";
-            break;
-        case ePdfError_UnexpectedEOF:
-            pszMsg = "End of file was reached unxexpectedly.";
-            break;
-        case ePdfError_OutOfMemory:
-            pszMsg = "PoDoFo is out of memory.";
-            break;
-        case ePdfError_ValueOutOfRange:
-            pszMsg = "The passed value is out of range.";
-            break;
-        case ePdfError_InternalLogic:
-            pszMsg = "An internal error occurred.";
-            break;
-        case ePdfError_InvalidEnumValue:
-            pszMsg = "An invalid enum value was specified.";
-            break;
-        case ePdfError_BrokenFile:
-            pszMsg = "The file content is broken.";
-            break;
-        case ePdfError_PageNotFound:
-            pszMsg = "The requested page could not be found in the PDF.";
-            break;
-        case ePdfError_NoPdfFile:
-            pszMsg = "This is not a PDF file.";
-            break;
-        case ePdfError_NoXRef:
-            pszMsg = "No XRef table was found in the PDF file.";
-            break;
-        case ePdfError_NoTrailer:
-            pszMsg = "No trailer was found in the PDF file.";
-            break;
-        case ePdfError_NoNumber:
-            pszMsg = "A number was expected but not found.";
-            break;
-        case ePdfError_NoObject:
-            pszMsg = "A object was expected but not found.";
-            break;
-        case ePdfError_NoEOFToken:
-            pszMsg = "No EOF Marker was found in the PDF file.";
-            break;
-
-        case ePdfError_InvalidTrailerSize:
-        case ePdfError_InvalidLinearization:
-        case ePdfError_InvalidDataType:
-        case ePdfError_InvalidXRef:
-        case ePdfError_InvalidXRefStream:
-        case ePdfError_InvalidXRefType:
-        case ePdfError_InvalidPredictor:
-        case ePdfError_InvalidStrokeStyle:
-        case ePdfError_InvalidHexString:
-        case ePdfError_InvalidStream:
-        case ePdfError_InvalidStreamLength:
-        case ePdfError_InvalidKey:
-        case ePdfError_InvalidName:
-            break;
-        case ePdfError_InvalidEncryptionDict:
-            pszMsg = "The encryption dictionary is invalid or misses a required key.";
-            break;
-        case ePdfError_InvalidPassword:
-            pszMsg = "The password used to open the PDF file was invalid.";
-            break;
-        case ePdfError_InvalidFontFile:
-            pszMsg = "The font file is invalid.";
-            break;
-        case ePdfError_InvalidContentStream:
-            pszMsg = "The content stream is invalid due to mismatched context pairing or other problems.";
-            break;
-        case ePdfError_UnsupportedFilter:
-            break;
-        case ePdfError_UnsupportedFontFormat:
-            pszMsg = "This font format is not supported by PoDoFO.";
-            break;
-        case ePdfError_DestinationAlreadyPresent:
-        case ePdfError_ActionAlreadyPresent:
-            pszMsg = "Outlines can have either destinations or actions."; 
-            break;
-        case ePdfError_WrongDestinationType:
-            pszMsg = "The requested field is not available for the given destination type";
-            break;
-        case ePdfError_MissingEndStream:
-        case ePdfError_Date:
-            break;
-        case ePdfError_Flate:
-            pszMsg = "ZLib returned an error.";
-            break;
-        case ePdfError_FreeType:
-            pszMsg = "FreeType returned an error.";
-            break;
-        case ePdfError_SignatureError:
-            pszMsg = "The signature contains an error.";
-            break;
-        case ePdfError_MutexError:
-            pszMsg = "Error during a mutex operation.";
-            break;
-        case ePdfError_UnsupportedImageFormat:
-            pszMsg = "This image format is not supported by PoDoFO.";
-            break;
-        case ePdfError_CannotConvertColor:
-            pszMsg = "This color format cannot be converted.";
-            break;
-        case ePdfError_ChangeOnImmutable:
-            pszMsg = "Changing values on immutable objects is not allowed.";
-            break;
-        case ePdfError_NotImplemented:
-            pszMsg = "This feature is currently not implemented.";
-            break;
-        case ePdfError_NotCompiled:
-            pszMsg = "This feature was disabled during compile time.";
-            break;
-        case ePdfError_Unknown:
-            pszMsg = "Error code unknown.";
-            break;
-        default:
-            break;
-    }
-
-    return pszMsg;
-}
-
-void PdfError::LogMessage( ELogSeverity eLogSeverity, const char* pszMsg, ... )
-{
-	if(!PdfError::LoggingEnabled())
-		return;
-
-#ifdef DEBUG
-    const ELogSeverity eMinSeverity = eLogSeverity_Debug;
-#else
-    const ELogSeverity eMinSeverity = eLogSeverity_Information;
-#endif // DEBUG
-
-    // OC 17.08.2010 BugFix: Higher level is lower value
- // if( eLogSeverity < eMinSeverity )
-    if( eLogSeverity > eMinSeverity )
-        return;
-
-    va_list  args;
-    va_start( args, pszMsg );
-
-    LogMessageInternal( eLogSeverity, pszMsg, args );
-    va_end( args );
-}
-
-void PdfError::LogErrorMessage( ELogSeverity eLogSeverity, const char* pszMsg, ... )
-{
-    va_list  args;
-    va_start( args, pszMsg );
-
-    LogMessageInternal( eLogSeverity, pszMsg, args );
-    va_end( args );
-}
-
-void PdfError::LogMessageInternal( ELogSeverity eLogSeverity, const char* pszMsg, va_list & args )
-{
-    const char* pszPrefix = NULL;
-
-    switch( eLogSeverity ) 
-    {
-        case eLogSeverity_Error:
-            break;
-        case eLogSeverity_Critical:
-	    pszPrefix = "CRITICAL: ";
-            break;
-        case eLogSeverity_Warning:
-	    pszPrefix = "WARNING: ";
-            break;
-	case eLogSeverity_Information:
-            break;
-	case eLogSeverity_Debug:
-	    pszPrefix = "DEBUG: ";
-            break;
-	case eLogSeverity_None:
-	case eLogSeverity_Unknown:
-        default:
-            break;
-    }
-
-    // OC 17.08.2010 New to optionally replace stderr output by a callback:
-    if ( m_fLogMessageCallback != NULL )
-    {
-        m_fLogMessageCallback->LogMessage(eLogSeverity, pszPrefix, pszMsg, args);
-        return;
-    }
-
-    if( pszPrefix )
-        fprintf( stderr, "%s", pszPrefix );
-
-    vfprintf( stderr, pszMsg, args );
-}
-
-void PdfError::LogMessage( ELogSeverity eLogSeverity, const wchar_t* pszMsg, ... )
-{
-	if(!PdfError::LoggingEnabled())
-		return;
-
-#ifdef DEBUG
-    const ELogSeverity eMinSeverity = eLogSeverity_Debug;
-#else
-    const ELogSeverity eMinSeverity = eLogSeverity_Information;
-#endif // DEBUG
-
-    // OC 17.08.2010 BugFix: Higher level is lower value
- // if( eLogSeverity < eMinSeverity )
-    if( eLogSeverity > eMinSeverity )
-        return;
-
-    va_list  args;
-    va_start( args, pszMsg );
-
-    LogMessageInternal( eLogSeverity, pszMsg, args );
-    va_end( args );
-}
-
-void PdfError::LogErrorMessage( ELogSeverity eLogSeverity, const wchar_t* pszMsg, ... )
-{
-    va_list  args;
-    va_start( args, pszMsg );
-
-    LogMessageInternal( eLogSeverity, pszMsg, args );
-    va_end( args );
-}
-
-void PdfError::LogMessageInternal( ELogSeverity eLogSeverity, const wchar_t* pszMsg, va_list & args )
-{
-    const wchar_t* pszPrefix = NULL;
-
-    switch( eLogSeverity ) 
-    {
-        case eLogSeverity_Error:
-            break;
-        case eLogSeverity_Critical:
-	    pszPrefix = L"CRITICAL: ";
-            break;
-        case eLogSeverity_Warning:
-	    pszPrefix = L"WARNING: ";
-            break;
-	case eLogSeverity_Information:
-            break;
-	case eLogSeverity_Debug:
-	    pszPrefix = L"DEBUG: ";
-            break;
-	case eLogSeverity_None:
-	case eLogSeverity_Unknown:
-        default:
-            break;
-    }
-
-    // OC 17.08.2010 New to optionally replace stderr output by a callback:
-    if ( m_fLogMessageCallback != NULL )
-    {
-        m_fLogMessageCallback->LogMessage(eLogSeverity, pszPrefix, pszMsg, args);
-        return;
-    }
-
-    if( pszPrefix )
-        fwprintf( stderr, pszPrefix );
-
-    vfwprintf( stderr, pszMsg, args );
-}
-
-void PdfError::DebugMessage( const char* pszMsg, ... )
-{
-	if ( !PdfError::DebugEnabled() )		
-            return;
-
-	const char* pszPrefix = "DEBUG: ";
-
-	va_list  args;
-	va_start( args, pszMsg );
-
-    // OC 17.08.2010 New to optionally replace stderr output by a callback:
-    if ( m_fLogMessageCallback != NULL )
-    {
-        m_fLogMessageCallback->LogMessage(eLogSeverity_Debug, pszPrefix, pszMsg, args);
-        return;
-    }
-
-	if( pszPrefix )
-		fprintf( stderr, "%s", pszPrefix );
-
-	vfprintf( stderr, pszMsg, args );
-	va_end( args );
-}
-
-};
--- src/base/PdfError.h.orig	2024-06-29 17:32:05.105339719 +0000
+++ src/base/PdfError.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,561 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_ERROR_H_
-#define _PDF_ERROR_H_
-
-// PdfError.h should not include PdfDefines.h, since it is included by it.
-// It should avoid depending on anything defined in PdfDefines.h .
-
-#include "podofoapi.h"
-#include <string>
-#include <queue>
-#include <cstdarg>
-
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200 // same pragma as in PdfDefines.h which we cannot include here
-#pragma warning(disable: 4251)
-#endif
-
-/** \file PdfError.h
- *  Error information and logging is implemented in this file.
- */
-
-namespace PoDoFo {
-
-/** Error Code defines which are used in PdfError to describe the error.
- *
- *  If you add an error code to this enum, please also add it to PdfError::ErrorName
- *  and PdfError::ErrorMessage.
- * 
- *  \see PdfError
- */
-enum EPdfError {
-    ePdfError_ErrOk = 0,                /**< The default value indicating no error. */
-
-    ePdfError_TestFailed,               /**< Used in PoDoFo tests, to indicate that a test failed for some reason. */
-
-    ePdfError_InvalidHandle,            /**< Null pointer was passed, but null pointer is not allowed. */
-    ePdfError_FileNotFound,             /**< A file was not found or cannot be opened. */
-    ePdfError_InvalidDeviceOperation,	/**< Tried to do something unsupported to an I/O device like seek a non-seekable input device */
-    ePdfError_UnexpectedEOF,            /**< End of file was reached but data was expected. */
-    ePdfError_OutOfMemory,              /**< Not enough memory to complete an operation. */
-    ePdfError_ValueOutOfRange,          /**< The specified memory is out of the allowed range. */
-    ePdfError_InternalLogic,            /**< An internal sanity check or assertion failed. */ 
-    ePdfError_InvalidEnumValue,         /**< An invalid enum value was specified. */
-
-    ePdfError_PageNotFound,             /**< The requested page could not be found in the PDF. */
-
-    ePdfError_NoPdfFile,                /**< The file is no PDF file. */
-    ePdfError_NoXRef,                   /**< The PDF file has no or an invalid XRef table. */
-    ePdfError_NoTrailer,                /**< The PDF file has no or an invalid trailer. */
-    ePdfError_NoNumber,                 /**< A number was expected in the PDF file, but the read string is no number. */
-    ePdfError_NoObject,                 /**< A object was expected and non was found. */
-    ePdfError_NoEOFToken,               /**< The PDF file has no or an invalid EOF marker. */
-
-    ePdfError_InvalidTrailerSize,       /**< The trailer size is invalid. */
-    ePdfError_InvalidLinearization,     /**< The linearization directory of a web-optimized PDF file is invalid. */
-    ePdfError_InvalidDataType,          /**< The passed datatype is invalid or was not recognized */
-    ePdfError_InvalidXRef,              /**< The XRef table is invalid */
-    ePdfError_InvalidXRefStream,        /**< A XRef steam is invalid */
-    ePdfError_InvalidXRefType,          /**< The XRef type is invalid or was not found */
-    ePdfError_InvalidPredictor,         /**< Invalid or unimplemented predictor */
-    ePdfError_InvalidStrokeStyle,       /**< Invalid stroke style during drawing */
-    ePdfError_InvalidHexString,         /**< Invalid hex string */
-    ePdfError_InvalidStream,            /**< The stream is invalid */
-    ePdfError_InvalidStreamLength,      /**< The stream length is invlaid */
-    ePdfError_InvalidKey,               /**< The specified key is invalid */
-    ePdfError_InvalidName,              /**< The specified Name is not valid in this context */
-    ePdfError_InvalidEncryptionDict,    /**< The encryption dictionary is invalid or misses a required key */
-    ePdfError_InvalidPassword,          /**< The password used to open the PDF file was invalid */
-    ePdfError_InvalidFontFile,          /**< The font file is invalid */
-    ePdfError_InvalidContentStream,     /**< The content stream is invalid due to mismatched context pairing or other problems */
-
-    ePdfError_UnsupportedFilter,        /**< The requested filter is not yet implemented. */
-    ePdfError_UnsupportedFontFormat,    /**< This font format is not supported by PoDoFO. */
-    ePdfError_ActionAlreadyPresent,     /**< An Action was already present when trying to add a Destination */
-    ePdfError_WrongDestinationType,     /**< The requested field is not available for the given destination type */
-
-    ePdfError_MissingEndStream,         /**< The required token endstream was not found. */
-    ePdfError_Date,                     /**< Date/time error */
-    ePdfError_Flate,                    /**< Error in zlib */
-    ePdfError_FreeType,                 /**< Error in FreeType */
-    ePdfError_SignatureError,           /**< Error in signature */
-
-    ePdfError_MutexError,               /**< Error during a mutex operation */
-
-    ePdfError_UnsupportedImageFormat,   /**< This image format is not supported by PoDoFO. */
-    ePdfError_CannotConvertColor,       /**< This color format cannot be converted. */
-
-    ePdfError_NotImplemented,           /**< This feature is currently not implemented. */
-
-    ePdfError_DestinationAlreadyPresent,/**< An destination was already present when trying to add a Action */
-    ePdfError_ChangeOnImmutable,        /**< Changing values on immutable objects is not allowed. */
-
-    ePdfError_NotCompiled,              /**< This feature was disabled during compile time. */
-
-    ePdfError_BrokenFile,               /**< The file content is broken. */
-
-    ePdfError_Unknown = 0xffff          /**< Unknown error */
-};
-
-/**
- * Used in PdfError::LogMessage to specify the log level.
- *
- * \see PdfError::LogMessage
- */
-enum ELogSeverity {
-    eLogSeverity_Critical,            /**< Critical unexpected error */
-    eLogSeverity_Error,               /**< Error */
-    eLogSeverity_Warning,             /**< Warning */
-    eLogSeverity_Information,         /**< Information message */
-    eLogSeverity_Debug,               /**< Debug information */
-    eLogSeverity_None,                /**< No specified level */
-
-    eLogSeverity_Unknown = 0xffff     /**< Unknown log level */
-};
-
-/** \def PODOFO_RAISE_ERROR( x )
- *  
- *  Set the value of the variable eCode (which has to exist in the current function) to x
- *  and return the eCode.
- */
-#define PODOFO_RAISE_ERROR( x ) throw ::PoDoFo::PdfError( x, __FILE__, __LINE__ );
-
-/** \def PODOFO_RAISE_ERROR_INFO( x, y )
- *  
- *  Set the value of the variable eCode (which has to exist in the current function) to x
- *  and return the eCode. Additionally additional information on the error y is set. 
- *  y can be a C string, but can also be a C++ std::string.
- */
-#define PODOFO_RAISE_ERROR_INFO( x, y ) throw ::PoDoFo::PdfError( x, __FILE__, __LINE__, y );
-
-/** \def PODOFO_RAISE_LOGIC_IF( x, y )
- *
- *  Evaluate `x' as a binary predicate and if it is true, raise a logic error with the
- *  info string `y' .
- *
- *  This macro will be undefined when NDEBUG is set, so it's compiled out for release
- *  builds. Use it for expensive or extremely frequent sanity checking.
- *
- *  We define it then UNDEF it to help out doxygen.
- */
-#ifndef NDEBUG
-    // Woo for double-negatives. We define PODOFO_RAISE_LOGIC_IF unless we've been told not to by NDEBUG.
-    #define PODOFO_RAISE_LOGIC_IF( x, y ) { if (x) throw ::PoDoFo::PdfError( ePdfError_InternalLogic, __FILE__, __LINE__, y ); };
-#else
-    #define PODOFO_RAISE_LOGIC_IF( x, y ) {};
-#endif
-
-class PODOFO_API PdfErrorInfo {
- public:
-    PdfErrorInfo();
-    PdfErrorInfo( int line, const char* pszFile, const char* pszInfo );
-    PdfErrorInfo( int line, const char* pszFile, std::string pszInfo );
-    PdfErrorInfo( int line, const char* pszFile, const wchar_t* pszInfo );
-	PdfErrorInfo( const PdfErrorInfo & rhs );
-
-    const PdfErrorInfo & operator=( const PdfErrorInfo & rhs );
-
-    inline int GetLine() const { return m_nLine; }
-    inline const std::string & GetFilename() const { return m_sFile; }
-    inline const std::string & GetInformation() const { return m_sInfo; }
-    inline const std::wstring & GetInformationW() const { return m_swInfo; }
-
-    inline void SetInformation( const char* pszInfo ) { m_sInfo = pszInfo ? pszInfo : ""; }
-    inline void SetInformation( std::string pszInfo ) { m_sInfo = pszInfo; }
-    inline void SetInformation( const wchar_t* pszInfo ) { m_swInfo = pszInfo ? pszInfo : L""; }
-
- private:
-    int          m_nLine;
-    std::string  m_sFile;
-    std::string  m_sInfo;
-	std::wstring m_swInfo;
-};
-
-
-typedef std::deque<PdfErrorInfo>        TDequeErrorInfo;
-typedef TDequeErrorInfo::iterator       TIDequeErrorInfo;
-typedef TDequeErrorInfo::const_iterator TCIDequeErrorInfo;
-
-
-// This is required to generate the documentation with Doxygen.
-// Without this define doxygen thinks we have a class called PODOFO_EXCEPTION_API(PODOFO_API) ...
-#define PODOFO_EXCEPTION_API_DOXYGEN PODOFO_EXCEPTION_API(PODOFO_API)
-
-/** The error handling class of PoDoFo lib.
- *  Whenever a function encounters an error
- *  a PdfError object is returned.
- *  
- *  A PdfError with Error() == ErrOk means
- *  successfull execution.
- *
- *  This class provides also meaningfull
- *  error descriptions.
- */
-class PODOFO_EXCEPTION_API_DOXYGEN PdfError : public std::exception {
- public:
-
-    // OC 17.08.2010 New to optionally replace stderr output by a callback:
-    class LogMessageCallback
-    {
-    public:
-        virtual ~LogMessageCallback() {} // every class with virtual methods needs a virtual destructor
-        virtual void LogMessage( ELogSeverity eLogSeverity, const char* pszPrefix, const char* pszMsg, va_list & args ) = 0;
-        virtual void LogMessage( ELogSeverity eLogSeverity, const wchar_t* pszPrefix, const wchar_t* pszMsg, va_list & args ) = 0;
-    };
-
-    /** Set a global static LogMessageCallback functor to repleace stderr output in LogMessageInternal
-     *  \param fLogMessageCallback the pointer to the new callback functor object
-     *  \returns the pointer to the previous callback functor object
-     */
-    static LogMessageCallback* SetLogMessageCallback(LogMessageCallback* fLogMessageCallback);
-
-    /** Create a PdfError object initialized to ErrOk
-     */
-    PdfError();
-
-    /** Create a PdfError object with a given error code.
-     *  \param eCode the error code of this object
-     *  \param pszFile the file in which the error has occured. 
-     *         Use the compiler macro __FILE__ to initialize the field.
-     *  \param line the line in which the error has occured.
-     *         Use the compiler macro __LINE__ to initialize the field.
-     *  \param pszInformation additional information on this error
-     */
-    PdfError( const EPdfError & eCode, const char* pszFile = NULL, int line = 0, 
-              const char* pszInformation = NULL );
-
-    /** Create a PdfError object with a given error code.
-     *  \param eCode the error code of this object
-     *  \param pszFile the file in which the error has occured. 
-     *         Use the compiler macro __FILE__ to initialize the field.
-     *  \param line the line in which the error has occured.
-     *         Use the compiler macro __LINE__ to initialize the field.
-     *  \param sInformation additional information on this error
-     */
-    explicit PdfError( const EPdfError & eCode, const char* pszFile, int line, 
-                        std::string sInformation );
-
-    /** Copy constructor
-     *  \param rhs copy the contents of rhs into this object
-     */
-    PdfError( const PdfError & rhs );
-
-    virtual ~PdfError() throw();
-    
-    /** Assignment operator
-     *  \param rhs another PdfError object
-     *  \returns this object
-     */
-    const PdfError & operator=( const PdfError & rhs );
-
-    /** Overloaded assignment operator
-     *  \param eCode a EPdfError code
-     *  \returns this object
-     */
-    const PdfError & operator=( const EPdfError & eCode );
-
-    /** Comparison operator compares 2 PdfError objects
-     *  \param rhs another PdfError object
-     *  \returns true if both objects have the same error code.
-     */
-    bool operator==( const PdfError & rhs );
-
-    /** Overloaded comparison operator compares 2 PdfError objects
-     *  \param eCode an erroce code
-     *  \returns true if this object has the same error code.
-     */
-    bool operator==( const EPdfError & eCode );
-
-    /** Comparison operator compares 2 PdfError objects
-     *  \param rhs another PdfError object
-     *  \returns true if both objects have the different error code.
-     */
-    bool operator!=( const PdfError & rhs );
-
-    /** Overloaded comparison operator compares 2 PdfError objects
-     *  \param eCode an erroce code
-     *  \returns true if this object has different error code.
-     */
-    bool operator!=( const EPdfError & eCode );
-
-    /** Return the error code of this object
-     *  \returns the error code of this object
-     */
-    inline EPdfError GetError() const;
-
-    /** Get access to the internal callstack of this error
-     *  \return the callstack
-     */
-    inline const TDequeErrorInfo & GetCallstack() const;
-
-    /** Set the error code of this object.
-     *  \param eCode the error code of this object
-     *  \param pszFile the filename of the source file causing
-     *                 the error or NULL. Typically you will use
-     *                 the gcc macro __FILE__ here.
-     *  \param line    the line of source causing the error
-     *                 or 0. Typically you will use the gcc 
-     *                 macro __LINE__ here.
-     *  \param sInformation additional information on the error.
-     *         e.g. how to fix the error. This string is intended to 
-     *         be shown to the user.
-     */
-    inline void SetError( const EPdfError & eCode, const char* pszFile, int line,
-                        std::string sInformation );
-
-    /** Set the error code of this object.
-     *  \param eCode the error code of this object
-     *  \param pszFile the filename of the source file causing
-     *                 the error or NULL. Typically you will use
-     *                 the gcc macro __FILE__ here.
-     *  \param line    the line of source causing the error
-     *                 or 0. Typically you will use the gcc 
-     *                 macro __LINE__ here.
-     *  \param pszInformation additional information on the error.
-     *         e.g. how to fix the error. This string is intended to 
-     *         be shown to the user.
-     */
-    inline void SetError( const EPdfError & eCode, const char* pszFile = NULL, int line = 0, const char* pszInformation = NULL );
-
-    /** Set additional error informatiom
-     *  \param pszInformation additional information on the error.
-     *         e.g. how to fix the error. This string is intended to 
-     *         be shown to the user.
-     */
-    inline void SetErrorInformation( const char* pszInformation );
-
-    /** Set additional error informatiom
-     *  \param pszInformation additional information on the error.
-     *         e.g. how to fix the error. This string is intended to 
-     *         be shown to the user.
-     */
-    inline void SetErrorInformation( const wchar_t* pszInformation );
-
-	/** Add callstack information to an error object. Always call this function
-     *  if you get an error object but do not handle the error but throw it again.
-     *
-     *  \param pszFile the filename of the source file causing
-     *                 the error or NULL. Typically you will use
-     *                 the gcc macro __FILE__ here.
-     *  \param line    the line of source causing the error
-     *                 or 0. Typically you will use the gcc 
-     *                 macro __LINE__ here.
-     *  \param pszInformation additional information on the error.
-     *         e.g. how to fix the error. This string is intended to 
-     *         be shown to the user.
-     */
-    inline void AddToCallstack( const char* pszFile = NULL, int line = 0, const char* pszInformation = NULL );
-
-	/** Add callstack information to an error object. Always call this function
-     *  if you get an error object but do not handle the error but throw it again.
-     *
-     *  \param pszFile the filename of the source file causing
-     *                 the error or NULL. Typically you will use
-     *                 the gcc macro __FILE__ here.
-     *  \param line    the line of source causing the error
-     *                 or 0. Typically you will use the gcc 
-     *                 macro __LINE__ here.
-     *  \param sInformation additional information on the error.
-     *         e.g. how to fix the error. This string is intended to 
-     *         be shown to the user.
-     */
-    inline void AddToCallstack( const char* pszFile, int line, std::string sInformation );
-
-    /** \returns true if an error code was set 
-     *           and false if the error code is ePdfError_ErrOk
-     */
-    inline bool IsError() const;
-
-    /** Print an error message to stderr
-     */
-    void PrintErrorMsg() const;
-
-    /** Reimplemented from std::exception.
-     *  \returns a c string describing the error.
-     *  Annotated throw() in defiance of CODINGSTYLE.txt because we can't discard qualifiers on override.
-     */
-    virtual const char* what() const throw();
-    
-    /** Get the name for a certain error code.
-     *  \returns the name or NULL if no name for the specified
-     *           error code is available.
-     */
-    PODOFO_NOTHROW static const char* ErrorName( EPdfError eCode );
-
-    /** Get the error message for a certain error code.
-     *  \returns the error message or NULL if no error
-     *           message for the specified error code
-     *           is available.
-     */
-    static const char* ErrorMessage( EPdfError eCode );
-
-    /** Log a message to the logging system defined for PoDoFo.
-     *  \param eLogSeverity the sevirity of the log message
-     *  \param pszMsg       the message to be logged
-     */
-    static void LogMessage( ELogSeverity eLogSeverity, const char* pszMsg, ... );
-
-    /** Log a message to the logging system defined for PoDoFo.
-     *  \param eLogSeverity the sevirity of the log message
-     *  \param pszMsg       the message to be logged
-     */
-    static void LogMessage( ELogSeverity eLogSeverity, const wchar_t* pszMsg, ... );
-
-     /** Enable or disable Logging
-     *  \param bEnable       enable (true) or disable (false)
-     */
-    static void EnableLogging( bool bEnable ) { PdfError::s_LogEnabled = bEnable; }
-	
-    /** Is the display of debugging messages enabled or not?
-     */
-    static bool LoggingEnabled() { return PdfError::s_LogEnabled; }
-    
-    /** Log a message to the logging system defined for PoDoFo for debugging
-     *  \param pszMsg       the message to be logged
-     */
-    static void DebugMessage( const char* pszMsg, ... );
-
-    /** Enable or disable the display of debugging messages
-     *  \param bEnable       enable (true) or disable (false)
-     */
-    static void EnableDebug( bool bEnable ) { PdfError::s_DgbEnabled = bEnable; }
-	
-    /** Is the display of debugging messages enabled or not?
-     */
-    static bool DebugEnabled() { return PdfError::s_DgbEnabled; }
-
- private:
-    /** Log a message to the logging system defined for PoDoFo.
-     *
-     *  This call does not check if logging is enabled and always
-     *  prints the error message
-     *
-     *  \param eLogSeverity the sevirity of the log message
-     *  \param pszMsg       the message to be logged
-     */
-    static void LogErrorMessage( ELogSeverity eLogSeverity, const char* pszMsg, ... );
-
-    /** Log a message to the logging system defined for PoDoFo.
-     *
-     *  This call does not check if logging is enabled and always
-     *  prints the error message
-     *
-     *  \param eLogSeverity the sevirity of the log message
-     *  \param pszMsg       the message to be logged
-     */
-    static void LogErrorMessage( ELogSeverity eLogSeverity, const wchar_t* pszMsg, ... );
-
-    static void LogMessageInternal( ELogSeverity eLogSeverity, const char* pszMsg, va_list & args );
-    static void LogMessageInternal( ELogSeverity eLogSeverity, const wchar_t* pszMsg, va_list & args );
-
- private:
-    EPdfError          m_error;
-
-    TDequeErrorInfo    m_callStack;
-
-    static bool        s_DgbEnabled;
-    static bool        s_LogEnabled;
-
-    // OC 17.08.2010 New to optionally replace stderr output by a callback:
-    static LogMessageCallback* m_fLogMessageCallback;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfError PdfError::GetError() const
-{
-    return m_error;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const TDequeErrorInfo & PdfError::GetCallstack() const
-{
-    return m_callStack;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfError::SetError( const EPdfError & eCode, const char* pszFile, int line, const char* pszInformation )
-{
-    m_error = eCode;
-    this->AddToCallstack( pszFile, line, pszInformation );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfError::AddToCallstack( const char* pszFile, int line, const char* pszInformation )
-{
-    m_callStack.push_front( PdfErrorInfo( line, pszFile, pszInformation ) );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfError::SetError( const EPdfError & eCode, const char* pszFile, int line, std::string sInformation )
-{
-    m_error = eCode;
-    this->AddToCallstack( pszFile, line, sInformation );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfError::AddToCallstack( const char* pszFile, int line, std::string sInformation )
-{
-    m_callStack.push_front( PdfErrorInfo( line, pszFile, sInformation ) );
-}
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfError::SetErrorInformation( const char* pszInformation )
-{
-    if( m_callStack.size() )
-        m_callStack.front().SetInformation( pszInformation ? pszInformation : "" );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfError::SetErrorInformation( const wchar_t* pszInformation )
-{
-    if( m_callStack.size() )
-        m_callStack.front().SetInformation( pszInformation ? pszInformation : L"" );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfError::IsError() const
-{
-    return (m_error != ePdfError_ErrOk);
-}
-
-};
-
-#endif /* _PDF_ERROR_H_ */
-
-
-
--- src/base/PdfFilter.cpp.orig	2011-08-23 18:34:44.000000000 +0000
+++ src/base/PdfFilter.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,427 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfDefines.h"
-#include "PdfFilter.h"
-
-#include "PdfArray.h"
-#include "PdfDictionary.h"
-#include "PdfFiltersPrivate.h"
-#include "PdfOutputStream.h"
-#include "PdfDefinesPrivate.h"
-
-namespace PoDoFo {
-
-// All known filters
-static const char* aszFilters[] = {
-    "ASCIIHexDecode",
-    "ASCII85Decode",
-    "LZWDecode",
-    "FlateDecode",
-    "RunLengthDecode",
-    "CCITTFaxDecode", 
-    "JBIG2Decode",
-    "DCTDecode",
-    "JPXDecode",
-    "Crypt",
-    NULL
-};
-
-static const char* aszShortFilters[] = {
-    "AHx",
-    "A85",
-    "LZW",
-    "Fl",
-    "RL",
-    "CCF", 
-    "", ///< There is no shortname for JBIG2Decode
-    "DCT",
-    "", ///< There is no shortname for JPXDecode 
-    "", ///< There is no shortname for Crypt
-    NULL
-};
-
-/** Create a filter that is a PdfOutputStream.
- *
- *  All data written to this stream is encoded using a
- *  filter and written to another PdfOutputStream.
- *
- *  The passed output stream is owned by this PdfOutputStream
- *  and deleted along with it.
- */
-class PdfFilteredEncodeStream : public PdfOutputStream{
- public:
-    /** Create a filtered output stream.
-     *
-     *  All data written to this stream is encoded using the passed filter type
-     *  and written to the passed output stream which will be deleted 
-     *  by this PdfFilteredEncodeStream.
-     *
-     *  \param pOutputStream write all data to this output stream after encoding the data.
-     *  \param eFilter use this filter for encoding.
-     *  \param bOwnStream if true pOutputStream will be deleted along with this filter
-     */
-    PdfFilteredEncodeStream( PdfOutputStream* pOutputStream, const EPdfFilter eFilter, bool bOwnStream )
-        : m_pOutputStream( pOutputStream )
-    {
-        m_filter = PdfFilterFactory::Create( eFilter );
-
-        if( !m_filter.get() ) 
-        {
-            PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-        }
-
-        m_filter->BeginEncode( pOutputStream );
-
-        if( !bOwnStream )
-            m_pOutputStream = NULL;
-    }
-
-    virtual ~PdfFilteredEncodeStream()
-    {
-        delete m_pOutputStream;
-    }
-
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen )
-    {
-        m_filter->EncodeBlock( pBuffer, lLen );
-        
-        return 0;
-    }
-
-    virtual void Close() 
-    {
-        m_filter->EndEncode();
-    }
-
-private:
-    PdfOutputStream*         m_pOutputStream;
-    std::auto_ptr<PdfFilter> m_filter;
-};
-
-/** Create a filter that is a PdfOutputStream.
- *
- *  All data written to this stream is decoded using a
- *  filter and written to another PdfOutputStream.
- *
- *  The passed output stream is owned by this PdfOutputStream
- *  and deleted along with it.
- */
-class PdfFilteredDecodeStream : public PdfOutputStream {
- public:
-    /** Create a filtered output stream.
-     *
-     *  All data written to this stream is decoded using the passed filter type
-     *  and written to the passed output stream which will be deleted 
-     *  by this PdfFilteredEncodeStream.
-     *
-     *  \param pOutputStream write all data to this output stream after decoding the data.
-     *                       The PdfOutputStream is deleted along with this object.
-     *  \param eFilter use this filter for decoding.
-     *  \param bOwnStream if true pOutputStream will be deleted along with this filter
-     *  \param pDecodeParms additional parameters for decoding
-     */
-    PdfFilteredDecodeStream( PdfOutputStream* pOutputStream, const EPdfFilter eFilter, bool bOwnStream,
-                             const PdfDictionary* pDecodeParms = NULL )
-        : m_pOutputStream( pOutputStream ), m_bFilterFailed( false )
-    {
-        m_filter = PdfFilterFactory::Create( eFilter );
-        if( !m_filter.get() ) 
-        {
-            PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-        }
-
-        m_filter->BeginDecode( pOutputStream, pDecodeParms );
-
-        if( !bOwnStream )
-            m_pOutputStream = NULL;
-    }
-
-    virtual ~PdfFilteredDecodeStream()
-    {
-        delete m_pOutputStream;
-    }
-
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen )
-    {
-        try {
-            m_filter->DecodeBlock( pBuffer, lLen );
-        }
-        catch( const PdfError & e ) 
-        {
-            m_bFilterFailed = true;
-            throw e;
-        }
-
-        return 0;
-    }
-
-    virtual void Close() 
-    {
-        if( !m_bFilterFailed ) 
-        {
-            m_filter->EndDecode();
-        }
-    }
-
-private:
-    PdfOutputStream*         m_pOutputStream;
-    std::auto_ptr<PdfFilter> m_filter;
-    bool                     m_bFilterFailed;
-};
-
-
-// -----------------------------------------------------
-// Actual PdfFilter code
-// -----------------------------------------------------
-
-
-PdfFilter::PdfFilter() 
-    : m_pOutputStream( NULL )
-{
-}
-
-void PdfFilter::Encode( const char* pInBuffer, pdf_long lInLen, char** ppOutBuffer, pdf_long* plOutLen ) const
-{
-    if( !this->CanEncode() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-    }
-
-    PdfMemoryOutputStream stream;
-
-    const_cast<PdfFilter*>(this)->BeginEncode( &stream );
-    const_cast<PdfFilter*>(this)->EncodeBlock( pInBuffer, lInLen );
-    const_cast<PdfFilter*>(this)->EndEncode();
-
-    *ppOutBuffer = stream.TakeBuffer();
-    *plOutLen    = stream.GetLength();
-}
-
-void PdfFilter::Decode( const char* pInBuffer, pdf_long lInLen, char** ppOutBuffer, pdf_long* plOutLen, 
-                        const PdfDictionary* pDecodeParms ) const
-{
-    if( !this->CanDecode() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-    }
-
-    PdfMemoryOutputStream stream;
-
-    const_cast<PdfFilter*>(this)->BeginDecode( &stream, pDecodeParms );
-    const_cast<PdfFilter*>(this)->DecodeBlock( pInBuffer, lInLen );
-    const_cast<PdfFilter*>(this)->EndDecode();
-
-    *ppOutBuffer = stream.TakeBuffer();
-    *plOutLen    = stream.GetLength();
-}
-
-// -----------------------------------------------------
-// PdfFilterFactory code
-// -----------------------------------------------------
-
-std::auto_ptr<PdfFilter> PdfFilterFactory::Create( const EPdfFilter eFilter ) 
-{
-    PdfFilter* pFilter = NULL;
-    switch( eFilter )
-    {
-        case ePdfFilter_ASCIIHexDecode:
-            pFilter = new PdfHexFilter();
-            break;
-            
-        case ePdfFilter_ASCII85Decode:
-            pFilter = new PdfAscii85Filter();
-            break;
-            
-        case ePdfFilter_LZWDecode:
-            pFilter = new PdfLZWFilter();
-            break;
-            
-        case ePdfFilter_FlateDecode:
-            pFilter = new PdfFlateFilter();
-            break;
-            
-        case ePdfFilter_RunLengthDecode:
-            pFilter = new PdfRLEFilter();
-            break;
-            
-        case ePdfFilter_DCTDecode:
-#ifdef PODOFO_HAVE_JPEG_LIB
-            pFilter = new PdfDCTFilter();
-            break;
-#else
-            break;
-#endif // PODOFO_HAVE_JPEG_LIB
-
-        case ePdfFilter_CCITTFaxDecode:
-#ifdef PODOFO_HAVE_TIFF_LIB
-            pFilter = new PdfCCITTFilter();
-            break;
-#else
-            break;
-#endif // PODOFO_HAVE_TIFF_LIB
-
-
-        case ePdfFilter_JBIG2Decode:
-        case ePdfFilter_JPXDecode:
-        case ePdfFilter_Crypt:
-        default:
-            break;
-    }
-
-    return std::auto_ptr<PdfFilter>(pFilter);
-}
-
-PdfOutputStream* PdfFilterFactory::CreateEncodeStream( const TVecFilters & filters, PdfOutputStream* pStream ) 
-{
-    TVecFilters::const_iterator it = filters.begin();
-
-    PODOFO_RAISE_LOGIC_IF( !filters.size(), "Cannot create an EncodeStream from an empty list of filters" );
-
-    PdfFilteredEncodeStream* pFilter = new PdfFilteredEncodeStream( pStream, *it, false );
-    ++it;
-
-    while( it != filters.end() ) 
-    {
-        pFilter = new PdfFilteredEncodeStream( pFilter, *it, true );
-        ++it;
-    }
-
-    return pFilter;
-}
-
-PdfOutputStream* PdfFilterFactory::CreateDecodeStream( const TVecFilters & filters, PdfOutputStream* pStream,
-                                                       const PdfDictionary* pDictionary ) 
-{
-    TVecFilters::const_reverse_iterator it = filters.rbegin();
-
-    PODOFO_RAISE_LOGIC_IF( !filters.size(), "Cannot create an DecodeStream from an empty list of filters" );
-
-    // TODO: support arrays and indirect objects here and the short name /DP
-    if( pDictionary && pDictionary->HasKey( "DecodeParms" ) && pDictionary->GetKey( "DecodeParms" )->IsDictionary() )
-        pDictionary = &(pDictionary->GetKey( "DecodeParms" )->GetDictionary());
-
-    PdfFilteredDecodeStream* pFilter = new PdfFilteredDecodeStream( pStream, *it, false, pDictionary );
-    ++it;
-
-    while( it != filters.rend() ) 
-    {
-        pFilter = new PdfFilteredDecodeStream( pFilter, *it, true, pDictionary );
-        ++it;
-    }
-
-    return pFilter;
-}
-
-EPdfFilter PdfFilterFactory::FilterNameToType( const PdfName & name, bool bSupportShortNames )
-{
-    int i = 0;
-
-    while( aszFilters[i] )
-    {
-        if( name == aszFilters[i] )
-            return static_cast<EPdfFilter>(i);
-        
-        ++i;
-    }
-
-    if( bSupportShortNames )
-    {
-        i = 0;
-        while( aszShortFilters[i] )
-        {
-            if( name == aszShortFilters[i] )
-                return static_cast<EPdfFilter>(i);
-            
-            ++i;
-        }        
-    }
-
-    PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedFilter, name.GetName().c_str() );
-}
-
-const char* PdfFilterFactory::FilterTypeToName( EPdfFilter eFilter )
-{
-    return aszFilters[static_cast<int>(eFilter)];
-}
-
-TVecFilters PdfFilterFactory::CreateFilterList( const PdfObject* pObject )
-{
-    TVecFilters filters;
-
-    const PdfObject* pObj    = NULL;
-
-    if( pObject->IsDictionary() && pObject->GetDictionary().HasKey( "Filter" ) )
-        pObj = pObject->GetDictionary().GetKey( "Filter" );
-    else if( pObject->IsArray() )
-        pObj = pObject;
-    else if( pObject->IsName() ) 
-        pObj = pObject;
-
-
-    if (!pObj)
-	// Object had no /Filter key . Return a null filter list.
-	return filters;
-
-    if( pObj->IsName() ) 
-        filters.push_back( PdfFilterFactory::FilterNameToType( pObj->GetName() ) );
-    else if( pObj->IsArray() ) 
-    {
-        TCIVariantList it = pObj->GetArray().begin();
-
-        while( it != pObj->GetArray().end() )
-        {
-            if ( (*it).IsName() )
-			{
-                filters.push_back( PdfFilterFactory::FilterNameToType( (*it).GetName() ) );
-            }
-            else if ( (*it).IsReference() )
-            {
-                PdfObject* pFilter = pObject->GetOwner()->GetObject( (*it).GetReference() );
-                if( pFilter == NULL ) 
-                {
-                    PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Filter array contained unexpected reference" );
-                }
-
-                filters.push_back( PdfFilterFactory::FilterNameToType( pFilter->GetName() ) );
-            }
-            else 
-            {
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Filter array contained unexpected non-name type" );
-			}
-                
-            ++it;
-        }
-    }
-
-    return filters;
-}
-
-};
--- src/base/PdfFilter.h.orig	2011-01-12 19:36:35.000000000 +0000
+++ src/base/PdfFilter.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,503 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_FILTER_H_
-#define _PDF_FILTER_H_
-
-#include <memory>
-#include <cassert>
-
-#include "PdfDefines.h"
-
-#include "PdfInputStream.h"
-#include "PdfOutputStream.h"
-
-namespace PoDoFo {
-
-class PdfDictionary;
-class PdfName;
-class PdfObject;
-class PdfOutputStream;
-
-typedef std::vector<EPdfFilter>            TVecFilters;
-typedef TVecFilters::iterator              TIVecFilters;
-typedef TVecFilters::const_iterator        TCIVecFilters;
-
-/** Every filter in PoDoFo has to implement this interface.
- * 
- *  The two methods Encode and Decode have to be implemented 
- *  for every filter.
- *
- *  The output buffers are malloc'ed in the functions and have
- *  to be free'd by the caller.
- */
-class PODOFO_API PdfFilter {
- public:
-    /** Construct and initialize a new filter
-     */
-    PdfFilter();
-
-    /** All classes with virtual functions need a virtual destructor
-     */
-    inline virtual ~PdfFilter();
-
-    /** Check wether encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    virtual bool CanEncode() const = 0; 
-
-    /** Encodes a buffer using a filter. The buffer will malloc'ed and
-     *  has to be free'd by the caller.
-     *
-     *  This function uses BeginEncode()/EncodeBlock()/EndEncode()
-     *  internally, so it's not safe to use when progressive encoding
-     *  is in progress.
-     *
-     *  \param pInBuffer input buffer
-     *  \param lInLen    length of the input buffer
-     *  \param ppOutBuffer pointer to the buffer of the encoded data
-     *  \param plOutLen pointer to the length of the output buffer
-     */
-    void Encode( const char* pInBuffer, pdf_long lInLen, char** ppOutBuffer, pdf_long* plOutLen ) const;
-
-    /** Begin progressively encoding data using this filter.
-     *
-     *  This method sets the filter's output stream and may
-     *  perform other operations defined by particular filter
-     *  implementations. It calls BeginEncodeImpl().
-     *
-     *  \param pOutput encoded data will be written to this stream.
-     *
-     *  Call EncodeBlock() to encode blocks of data and use EndEncode
-     *  to finish the encoding process.
-     *
-     *  \see EncodeBlock
-     *  \see EndEncode
-     */
-    inline void BeginEncode( PdfOutputStream* pOutput );
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncode. Ownership of the block is not taken
-     *  and remains with the caller.
-     *
-     *  The filter implementation need not immediately process the buffer,
-     *  and might internally buffer some or all of it. However, if it does
-     *  this the buffer's contents will be copied, so it is guaranteed to be
-     *  safe to free the passed buffer after this call returns.
-     *
-     *  This method is a wrapper around EncodeBlockImpl().
-     *
-     *  BeginEncode() must be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncode() after all data has been encoded
-     *
-     *  \see BeginEncode
-     *  \see EndEncode
-     */
-    inline void EncodeBlock( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data and reset the stream's state.
-     *
-     *  \see BeginEncode
-     *  \see EncodeBlock
-     */
-    inline void EndEncode();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    virtual bool CanDecode() const = 0; 
-
-    /** Decodes a buffer using a filter. The buffer will malloc'ed and
-     *  has to be free'd by the caller.
-     *  
-     *  \param pInBuffer input buffer
-     *  \param lInLen    length of the input buffer
-     *  \param ppOutBuffer pointer to the buffer of the decoded data
-     *  \param plOutLen pointer to the length of the output buffer
-     *  \param pDecodeParms optional pointer to an decode parameters dictionary
-     *                      containing additional information to decode the data.
-     *                      This pointer must be NULL if no decode parameter dictionary
-     *                      is available.
-     */
-    void Decode( const char* pInBuffer, pdf_long lInLen, char** ppOutBuffer, pdf_long* plOutLen, const PdfDictionary* pDecodeParms = NULL ) const;
-
-    /** Begin progressively decoding data using this filter.
-     *
-     *  This method sets the filter's output stream and may
-     *  perform other operations defined by particular filter
-     *  implementations. It calls BeginDecodeImpl().
-     *
-     *  \param pOutput decoded data will be written to this stream.
-     *  \param pDecodeParms a dictionary containing addiational information for decoding
-     *
-     *  Call DecodeBlock() to decode blocks of data and use EndDecode
-     *  to finish the decoding process.
-     *
-     *  \see DecodeBlock
-     *  \see EndDecode
-     */
-    inline void BeginDecode( PdfOutputStream* pOutput, const PdfDictionary* pDecodeParms = NULL );
-
-    /** Decode a block of data and write it to the PdfOutputStream
-     *  specified by BeginDecode. Ownership of the block is not taken
-     *  and remains with the caller.
-     *
-     *  The filter implementation need not immediately process the buffer,
-     *  and might internally buffer some or all of it. However, if it does
-     *  this the buffer's contents will be copied, so it is guaranteed to be
-     *  safe to free the passed buffer after this call returns.
-     *
-     *  This method is a wrapper around DecodeBlockImpl().
-     *
-     *  BeginDecode() must be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndDecode() after all data has been decoded
-     *
-     *  \see BeginDecode
-     *  \see EndDecode
-     */
-    inline void DecodeBlock( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish decoding of data and reset the stream's state.
-     *
-     *  \see BeginDecode
-     *  \see DecodeBlock
-     */
-    inline void EndDecode();
-
-    /** Type of this filter.
-     *  \returns the type of this filter
-     */
-    virtual EPdfFilter GetType() const = 0;
-
-    PODOFO_NOTHROW inline PdfOutputStream* GetStream() const { return m_pOutputStream; }
-
- protected:
-    /**
-     * Indicate that the filter has failed, and will be non-functional until BeginEncode()
-     * or BeginDecode() is next called. Call this instead of EndEncode() or EndDecode if 
-     * something went wrong. It clears the stream output but otherwise does nothing.
-     *
-     * After this method is called futher calls to EncodeBlock(), DecodeBlock(), EndDecode() and
-     * EndEncode() before the next BeginEncode() or BeginDecode() are guaranteed to throw
-     * without calling their virtual implementations.
-     */
-    PODOFO_NOTHROW inline void FailEncodeDecode();
-
-    /** Real implementation of `BeginEncode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for encoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndEncode() was called since the last BeginEncode()/EncodeBlock().
-     *
-     * \see BeginEncode */
-    virtual void BeginEncodeImpl( ) { }
-
-    /** Real implementation of `EncodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to encode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndEncodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginEncode() has been called, and ensures that
-     *  EndEncode() has not been called since the last BeginEncode().
-     *
-     * \see EncodeBlock */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen ) = 0;
-
-    /** Real implementation of `EndEncode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginEncode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginEncodeImpl() has been called.
-     *
-     * \see EndEncode */
-    virtual void EndEncodeImpl() { }
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* ) { }
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen ) = 0;
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl() { }
-
- private:
-    PdfOutputStream* m_pOutputStream;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::BeginEncode( PdfOutputStream* pOutput )
-{
-    PODOFO_RAISE_LOGIC_IF( m_pOutputStream, "BeginEncode() on failed filter or without EndEncode()" );
-    m_pOutputStream = pOutput;
-
-	try {
-		BeginEncodeImpl();
-	} catch( const PdfError & e ) {
-		// Clean up and close stream
-		this->FailEncodeDecode();
-		throw e;
-	}
-}
- 
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::EncodeBlock( const char* pBuffer, pdf_long lLen )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pOutputStream, "EncodeBlock() without BeginEncode() or on failed filter" );
-
-	try {
-		EncodeBlockImpl(pBuffer, lLen);
-	} catch( const PdfError & e ) {
-		// Clean up and close stream
-		this->FailEncodeDecode();
-		throw e;
-	}
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::EndEncode()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pOutputStream, "EndEncode() without BeginEncode() or on failed filter" );
-
-	try {
-		EndEncodeImpl();
-	} catch( const PdfError & e ) {
-		// Clean up and close stream
-		this->FailEncodeDecode();
-		throw e;
-	}    
-
-    m_pOutputStream->Close();
-    m_pOutputStream = NULL;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::BeginDecode( PdfOutputStream* pOutput, const PdfDictionary* pDecodeParms )
-{
-    PODOFO_RAISE_LOGIC_IF( m_pOutputStream, "BeginDecode() on failed filter or without EndDecode()" );
-    m_pOutputStream = pOutput;
-
-	try {
-		BeginDecodeImpl( pDecodeParms );
-	} catch( const PdfError & e ) {
-		// Clean up and close stream
-		this->FailEncodeDecode();
-		throw e;
-	}    
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::DecodeBlock( const char* pBuffer, pdf_long lLen )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pOutputStream, "DecodeBlock() without BeginDecode() or on failed filter" )
-
-	try {
-		DecodeBlockImpl(pBuffer, lLen);
-	} catch( const PdfError & e ) {
-		// Clean up and close stream
-		this->FailEncodeDecode();
-		throw e;
-	}    
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::EndDecode()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pOutputStream, "EndDecode() without BeginDecode() or on failed filter" )
-
-	try {
-	    EndDecodeImpl();
-	} catch( const PdfError & e ) {
-		// Clean up and close stream
-		this->FailEncodeDecode();
-		throw e;
-	}    
-
-    if( m_pOutputStream ) 
-    {
-        m_pOutputStream->Close();
-        m_pOutputStream = NULL;
-    }
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfFilter::FailEncodeDecode()
-{
-    if ( m_pOutputStream != NULL ) // OC 19.08.2010 BugFix: Sometimes FailEncodeDecode() is called twice
-        m_pOutputStream->Close();
-    m_pOutputStream = NULL;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-PdfFilter::~PdfFilter()
-{
-    // Whoops! Didn't call EndEncode() before destroying the filter!
-    // Note that we can't do this for the user, since EndEncode() might
-    // throw and we can't safely have that in a dtor. That also means
-    // we can't throw here, but must abort.
-    assert(!m_pOutputStream);
-}
-
-
-/** A factory to create a filter object for a filter GetType from the EPdfFilter enum.
- * 
- *  All filters should be created using this factory.
- */
-class PODOFO_API PdfFilterFactory {
- public:
-    /** Create a filter from an enum.
-     *
-     *  Ownership is transferred to the caller, who should let the auto_ptr the
-     *  filter is returned in take care of freeing it when they're done with
-     *  it.
-     *
-     *  \param eFilter the GetType of filter that should be created.
-     *
-     *  \returns a new PdfFilter allocated using new or NULL if no
-     *           filter is available for this type.
-     */
-    static std::auto_ptr<PdfFilter> Create( const EPdfFilter eFilter );
-
-    /** Create a PdfOutputStream that applies a list of filters 
-     *  on all data written to it.
-     *
-     *  \param filters a list of filters
-     *  \param pStream write all data to this PdfOutputStream after it has been encoded.
-     *  \returns a new PdfOutputStream that has to be deleted by the caller.
-     *
-     *  \see PdfFilterFactory::CreateFilterList
-     */
-    static PdfOutputStream* CreateEncodeStream( const TVecFilters & filters, PdfOutputStream* pStream );
-
-    /** Create a PdfOutputStream that applies a list of filters 
-     *  on all data written to it.
-     *
-     *  \param filters a list of filters
-     *  \param pStream write all data to this PdfOutputStream after it has been decoded.
-     *  \param pDictionary pointer to a dictionary that might contain additional parameters
-     *                     for decoding the stream.
-     *                     CreateDecodeStream will look for a key named DecodeParms in this dictionary
-     *                     and pass the information found in this dictionary to the filters.
-     *
-     *  \returns a new PdfOutputStream that has to be deleted by the caller.
-     *
-     *  \see PdfFilterFactory::CreateFilterList
-     */
-    static PdfOutputStream* CreateDecodeStream( const TVecFilters & filters, PdfOutputStream* pStream, 
-                                                const PdfDictionary* pDictionary = NULL );
-
-    /** Converts a filter name to the corresponding enum
-     *  \param name of the filter without leading
-     *  \param bSupportShortNames the PDF Reference supports several
-     *         short names for filters (e.g. AHx for AsciiHexDecode), if true
-     *         support for these short names will be enabled. 
-     *         This is often used in inline images.
-     *  \returns the filter as enum
-     */
-    static EPdfFilter FilterNameToType( const PdfName & name, bool bSupportShortNames = true );
-
-    /** Converts a filter type enum to the corresponding PdfName
-     *  \param eFilter a filter type
-     *  \returns the filter as name
-     */
-    static const char* FilterTypeToName( EPdfFilter eFilter );
-
-    /** The passed PdfObject has to be a dictionary with a Filters key,
-     *  an array of filter names or a filter name.
-     *
-     *  \param pObject must define a list of filters.
-     *
-     *  \returns a list of filters
-     */
-    static TVecFilters CreateFilterList( const PdfObject* pObject );
-};
-
-
-};
-
-#endif /* _PDF_FILTER_H_ */
--- src/base/PdfFiltersPrivate.cpp.orig	2024-06-29 17:32:04.965340352 +0000
+++ src/base/PdfFiltersPrivate.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1231 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfDefines.h"
-#include "PdfFiltersPrivate.h"
-
-#include "PdfDictionary.h"
-#include "PdfOutputDevice.h"
-#include "PdfOutputStream.h"
-#include "PdfTokenizer.h"
-#include "PdfDefinesPrivate.h"
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-extern "C" {
-#include "jerror.h"
-}
-#endif // PODOFO_HAVE_JPEG_LIB
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef PODOFO_HAVE_TIFF_LIB
-extern "C" {
-#ifdef _WIN32		// For O_RDONLY
-    // TODO: DS
-#else
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#endif
-}
-#endif // PODOFO_HAVE_TIFF_LIB
-
-
-#define LZW_TABLE_SIZE      4096
-
-namespace {
-
-// Private data for PdfAscii85Filter. This will be optimised
-// by the compiler through compile-time constant expression
-// evaluation.
-const unsigned long sPowers85[] = {
-    85*85*85*85, 85*85*85, 85*85, 85, 1
-};
-
-} // end anonymous namespace
-
-
-namespace PoDoFo {
-
-/** 
- * This structur contains all necessary values
- * for a FlateDecode and LZWDecode Predictor.
- * These values are normally stored in the /DecodeParams
- * key of a PDF dictionary.
- */
-class PdfPredictorDecoder {
-
-public:
-    PdfPredictorDecoder( const PdfDictionary* pDecodeParms ) {
-        m_nPredictor   = static_cast<int>(pDecodeParms->GetKeyAsLong( "Predictor", 1L ));
-        m_nColors      = static_cast<int>(pDecodeParms->GetKeyAsLong( "Colors", 1L ));
-        m_nBPC         = static_cast<int>(pDecodeParms->GetKeyAsLong( "BitsPerComponent", 8L ));
-        m_nColumns     = static_cast<int>(pDecodeParms->GetKeyAsLong( "Columns", 1L ));
-        m_nEarlyChange = static_cast<int>(pDecodeParms->GetKeyAsLong( "EarlyChange", 1L ));
-
-        if( m_nPredictor >= 10)
-        {
-          m_bNextByteIsPredictor = true;
-          m_nCurPredictor = -1;
-        }
-        else
-        {
-          m_bNextByteIsPredictor = false;
-          m_nCurPredictor = m_nPredictor;
-        }
-
-        m_nCurRowIndex  = 0;
-        m_nBpp  = (m_nBPC * m_nColors) >> 3;
-        m_nRows = (m_nColumns * m_nColors * m_nBPC) >> 3;
-
-        m_pPrev = static_cast<char*>(malloc( sizeof(char) * m_nRows));
-        if( !m_pPrev )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-        }
-
-        memset( m_pPrev, 0, sizeof(char) * m_nRows );
-    };
-
-    ~PdfPredictorDecoder()
-    {
-        free( m_pPrev );
-    }
-
-    void Decode( const char* pBuffer, pdf_long lLen, PdfOutputStream* pStream ) 
-    {
-        if( m_nPredictor == 1 )
-        {
-            pStream->Write( pBuffer, lLen );
-            return;
-        }
-
-
-        while( lLen-- ) 
-        {
-            if( m_bNextByteIsPredictor )
-            {
-                m_nCurPredictor = *pBuffer + 10;
-                m_bNextByteIsPredictor = false;
-            }
-            else
-            {
-                switch( m_nCurPredictor )
-                {
-                    case 2: // Tiff Predictor
-                    {
-                        if(m_nBPC == 8)
-                        {   // Same as png sub
-                            int prev = (m_nCurRowIndex - m_nBpp < 0
-                                        ? 0 : m_pPrev[m_nCurRowIndex - m_nBpp]);
-                            m_pPrev[m_nCurRowIndex] = *pBuffer + prev;
-                            break;
-                        }
-
-                        // TODO: implement tiff predictor for other than 8 BPC
-                        PODOFO_RAISE_ERROR( ePdfError_InvalidPredictor );
-                        break;
-                    }
-                    case 10: // png none
-                    {
-                        m_pPrev[m_nCurRowIndex] = *pBuffer;
-                        break;
-                    }
-                    case 11: // png sub
-                    {
-                        int prev = (m_nCurRowIndex - m_nBpp < 0 
-                                    ? 0 : m_pPrev[m_nCurRowIndex - m_nBpp]);
-                        m_pPrev[m_nCurRowIndex] = *pBuffer + prev;
-                        break;
-                    }
-                    case 12: // png up
-                    {
-                        m_pPrev[m_nCurRowIndex] += *pBuffer;
-                        break;
-                    }
-                    case 13: // png average
-                    {
-                        int prev = (m_nCurRowIndex - m_nBpp < 0 
-                                    ? 0 : m_pPrev[m_nCurRowIndex - m_nBpp]);
-                        m_pPrev[m_nCurRowIndex] = ((prev + m_pPrev[m_nCurRowIndex]) >> 1) + *pBuffer;
-                        break;
-                    }
-                    case 14: // png paeth
-                    case 15: // png optimum
-                        PODOFO_RAISE_ERROR( ePdfError_InvalidPredictor );
-                        break;
-                        
-                    default:
-                    {
-                        //PODOFO_RAISE_ERROR( ePdfError_InvalidPredictor );
-                        break;
-                    }
-                }
-
-                ++m_nCurRowIndex;
-            }
-
-            ++pBuffer;
-
-            if( m_nCurRowIndex >= m_nRows ) 
-            {   // One line finished
-                m_nCurRowIndex  = 0;
-                m_bNextByteIsPredictor = (m_nCurPredictor >= 10);
-                pStream->Write( m_pPrev, m_nRows );
-            }
-        }
-    }
-
-
-private:
-    int m_nPredictor;
-    int m_nColors;
-    int m_nBPC; //< Bytes per component
-    int m_nColumns;
-    int m_nEarlyChange;
-    int m_nBpp; ///< Bytes per pixel
-
-    int m_nCurPredictor;
-    int m_nCurRowIndex;
-    int m_nRows;
-
-    bool m_bNextByteIsPredictor;
-
-    char* m_pPrev;
-};
-
-
-// -------------------------------------------------------
-// Hex
-// -------------------------------------------------------
-
-void PdfHexFilter::EncodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    char data[2];
-    while( lLen-- )
-    {
-        data[0]  = (*pBuffer & 0xF0) >> 4;
-        data[0] += (data[0] > 9 ? 'A' - 10 : '0');
-
-        data[1]  = (*pBuffer & 0x0F);
-        data[1] += (data[1] > 9 ? 'A' - 10 : '0');
-
-        GetStream()->Write( data, 2 );
-
-        ++pBuffer;
-    }
-}
-
-void PdfHexFilter::BeginDecodeImpl( const PdfDictionary* )
-{ 
-    m_cDecodedByte = 0;
-    m_bLow         = true;
-}
-
-void PdfHexFilter::DecodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    char val;
-
-    while( lLen-- ) 
-    {
-        if( PdfTokenizer::IsWhitespace( *pBuffer ) )
-        {
-            ++pBuffer;
-            continue;
-        }
-
-        val  = PdfTokenizer::GetHexValue( *pBuffer );
-        if( m_bLow ) 
-        {
-            m_cDecodedByte = (val & 0x0F);
-            m_bLow         = false;
-        }
-        else
-        {
-            m_cDecodedByte = ((m_cDecodedByte << 4) | val);
-            m_bLow         = true;
-
-            GetStream()->Write( &m_cDecodedByte, 1 );
-        }
-
-        ++pBuffer;
-    }
-}
-
-void PdfHexFilter::EndDecodeImpl()
-{ 
-    if( !m_bLow ) 
-    {
-        // an odd number of bytes was read,
-        // so the last byte is 0
-        GetStream()->Write( &m_cDecodedByte, 1 );
-    }
-}
-
-
-// -------------------------------------------------------
-// Ascii 85
-// 
-// based on public domain software from:
-// Paul Haahr - http://www.webcom.com/~haahr/
-// -------------------------------------------------------
-
-void PdfAscii85Filter::EncodeTuple( unsigned long tuple, int count )
-{
-    int      i      = 5;
-    int      z      = 0;
-    char     buf[5];
-    char     out[5];
-    char*    start  = buf;;
-
-    do 
-    {
-        *start++ = static_cast<char>(tuple % 85);
-        tuple /= 85;
-    } 
-    while (--i > 0);
-
-    i = count;
-    do 
-    {
-        out[z++] = static_cast<unsigned char>(*--start) + '!';
-    } 
-    while (i-- > 0);
-
-    GetStream()->Write( out, z );
-}
-
-void PdfAscii85Filter::BeginEncodeImpl()
-{
-    m_count = 0;
-    m_tuple = 0;
-}
-
-void PdfAscii85Filter::EncodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    unsigned int  c;
-    const char*   z = "z";
-
-    while( lLen ) 
-    {
-        c = *pBuffer & 0xff;
-        switch (m_count++) {
-            case 0: m_tuple |= ( c << 24); break;
-            case 1: m_tuple |= ( c << 16); break;
-            case 2: m_tuple |= ( c <<  8); break;
-            case 3:
-                m_tuple |= c;
-                if( 0 == m_tuple ) 
-                {
-                    GetStream()->Write( z, 1 );
-                }
-                else
-                {
-                    this->EncodeTuple( m_tuple, m_count ); 
-                }
-
-                m_tuple = 0;
-                m_count = 0;
-                break;
-        }
-        --lLen;
-        ++pBuffer;
-    }
-}
-
-void PdfAscii85Filter::EndEncodeImpl()
-{
-    if( m_count > 0 )
-        this->EncodeTuple( m_tuple, m_count );
-    //GetStream()->Write( "~>", 2 );
-}
-
-void PdfAscii85Filter::BeginDecodeImpl( const PdfDictionary* )
-{ 
-    m_count = 0;
-    m_tuple = 0;
-}
-
-void PdfAscii85Filter::DecodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    bool foundEndMarker = false;
-
-    while( lLen && !foundEndMarker ) 
-    {
-        switch ( *pBuffer ) 
-        {
-            default:
-                if ( *pBuffer < '!' || *pBuffer > 'u') 
-                {
-                    PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-                }
-
-                m_tuple += ( *pBuffer - '!') * sPowers85[m_count++];
-                if( m_count == 5 ) 
-                {
-                    WidePut( m_tuple, 4 );
-                    m_count = 0;
-                    m_tuple = 0;
-                }
-                break;
-            case 'z':
-                if (m_count != 0 ) 
-                {
-                    PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-                }
-
-                this->WidePut( 0, 4 );
-                break;
-            case '~':
-                ++pBuffer; 
-                --lLen;
-                if( lLen && *pBuffer != '>' ) 
-                {
-                    PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-                }
-                foundEndMarker = true;
-                break;
-            case '\n': case '\r': case '\t': case ' ':
-            case '\0': case '\f': case '\b': case 0177:
-                break;
-        }
-
-        --lLen;
-        ++pBuffer;
-    }
-}
-
-void PdfAscii85Filter::EndDecodeImpl()
-{ 
-    if( m_count > 0 ) 
-    {
-        m_count--;
-        m_tuple += sPowers85[m_count];
-        WidePut( m_tuple, m_count );
-    }
-}
-
-void PdfAscii85Filter::WidePut( unsigned long tuple, int bytes ) const
-{
-    char data[4];
-
-    switch( bytes ) 
-    {
-	case 4:
-            data[0] = static_cast<char>(tuple >> 24);
-            data[1] = static_cast<char>(tuple >> 16);
-            data[2] = static_cast<char>(tuple >>  8);
-            data[3] = static_cast<char>(tuple);
-            break;
-	case 3:
-            data[0] = static_cast<char>(tuple >> 24);
-            data[1] = static_cast<char>(tuple >> 16);
-            data[2] = static_cast<char>(tuple >>  8);
-            break;
-	case 2:
-            data[0] = static_cast<char>(tuple >> 24);
-            data[1] = static_cast<char>(tuple >> 16);
-            break;
-	case 1:
-            data[0] = static_cast<char>(tuple >> 24);
-            break;
-    }
-
-    GetStream()->Write( data, bytes );
-}
-
-// -------------------------------------------------------
-// Flate
-// -------------------------------------------------------
-PdfFlateFilter::PdfFlateFilter()
-    : m_pPredictor( 0 )
-{
-}
-
-PdfFlateFilter::~PdfFlateFilter()
-{
-    delete m_pPredictor;
-}
-
-void PdfFlateFilter::BeginEncodeImpl()
-{
-    m_stream.zalloc   = Z_NULL;
-    m_stream.zfree    = Z_NULL;
-    m_stream.opaque   = Z_NULL;
-
-    if( deflateInit( &m_stream, Z_DEFAULT_COMPRESSION ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_Flate );
-    }
-}
-
-void PdfFlateFilter::EncodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    this->EncodeBlockInternal( pBuffer, lLen, Z_NO_FLUSH );
-}
-
-void PdfFlateFilter::EncodeBlockInternal( const char* pBuffer, pdf_long lLen, int nMode )
-{
-    int nWrittenData = 0;
-
-    m_stream.avail_in = static_cast<long>(lLen);
-    m_stream.next_in  = reinterpret_cast<Bytef*>(const_cast<char*>(pBuffer));
-
-    do {
-        m_stream.avail_out = PODOFO_FILTER_INTERNAL_BUFFER_SIZE;
-        m_stream.next_out  = m_buffer;
-
-        if( deflate( &m_stream, nMode) == Z_STREAM_ERROR )
-        {
-            FailEncodeDecode();
-            PODOFO_RAISE_ERROR( ePdfError_Flate );
-        }
-
-
-        nWrittenData = PODOFO_FILTER_INTERNAL_BUFFER_SIZE - m_stream.avail_out;
-        try {
-            if( nWrittenData > 0 ) 
-            {
-                GetStream()->Write( reinterpret_cast<char*>(m_buffer), nWrittenData );
-            }
-        } catch( PdfError & e ) {
-            // clean up after any output stream errors
-            FailEncodeDecode();
-            e.AddToCallstack( __FILE__, __LINE__ );
-            throw e;
-        }
-    } while( m_stream.avail_out == 0 );
-}
-
-void PdfFlateFilter::EndEncodeImpl()
-{
-    this->EncodeBlockInternal( NULL, 0, Z_FINISH );
-    deflateEnd( &m_stream );
-}
-
-// --
-
-void PdfFlateFilter::BeginDecodeImpl( const PdfDictionary* pDecodeParms )
-{
-    m_stream.zalloc   = Z_NULL;
-    m_stream.zfree    = Z_NULL;
-    m_stream.opaque   = Z_NULL;
-
-    m_pPredictor = pDecodeParms ? new PdfPredictorDecoder( pDecodeParms ) : NULL;
-
-    if( inflateInit( &m_stream ) != Z_OK )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_Flate );
-    }
-}
-
-void PdfFlateFilter::DecodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    int flateErr;
-    int nWrittenData;
-
-    m_stream.avail_in = static_cast<long>(lLen);
-    m_stream.next_in  = reinterpret_cast<Bytef*>(const_cast<char*>(pBuffer));
-
-    do {
-        m_stream.avail_out = PODOFO_FILTER_INTERNAL_BUFFER_SIZE;
-        m_stream.next_out  = m_buffer;
-
-        switch( (flateErr = inflate(&m_stream, Z_NO_FLUSH)) ) {
-            case Z_NEED_DICT:
-            case Z_DATA_ERROR:
-            case Z_MEM_ERROR:
-            {
-                PdfError::LogMessage( eLogSeverity_Error, "Flate Decoding Error from ZLib: %i\n", flateErr );
-                (void)inflateEnd(&m_stream);
-
-                FailEncodeDecode();
-                PODOFO_RAISE_ERROR( ePdfError_Flate );
-            }
-            default:
-                break;
-        }
-
-        nWrittenData = PODOFO_FILTER_INTERNAL_BUFFER_SIZE - m_stream.avail_out;
-        try {
-            if( m_pPredictor ) 
-                m_pPredictor->Decode( reinterpret_cast<char*>(m_buffer), nWrittenData, GetStream() );
-            else
-                GetStream()->Write( reinterpret_cast<char*>(m_buffer), nWrittenData );
-        } catch( PdfError & e ) {
-            // clean up after any output stream errors
-            FailEncodeDecode();
-            e.AddToCallstack( __FILE__, __LINE__ );
-            throw e;
-        }
-    } while( m_stream.avail_out == 0 );
-}
-
-void PdfFlateFilter::EndDecodeImpl()
-{
-    delete m_pPredictor;
-    m_pPredictor = NULL;
-
-    (void)inflateEnd(&m_stream);
-}
-
-// -------------------------------------------------------
-// RLE
-// -------------------------------------------------------
-
-void PdfRLEFilter::BeginEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfRLEFilter::EncodeBlockImpl( const char*, pdf_long )
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfRLEFilter::EndEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfRLEFilter::BeginDecodeImpl( const PdfDictionary* )
-{ 
-    m_nCodeLen = 0;
-}
-
-void PdfRLEFilter::DecodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    while( lLen-- )
-    {
-        if( !m_nCodeLen )
-        {
-            m_nCodeLen = static_cast<int>(*pBuffer);
-        } else if( m_nCodeLen == 128 )
-            break;
-        else if( m_nCodeLen <= 127 )
-        {
-            GetStream()->Write( pBuffer, 1 );
-            m_nCodeLen--;
-        }
-        else if( m_nCodeLen >= 129 )
-        {
-            m_nCodeLen = 257 - m_nCodeLen;
-
-            while( m_nCodeLen-- ) 
-                GetStream()->Write( pBuffer, 1 );
-        }
-
-        ++pBuffer;
-    }
-}
-
-// -------------------------------------------------------
-// LZW
-// -------------------------------------------------------
-
-const unsigned short PdfLZWFilter::s_masks[] = { 0x01FF,
-                                        0x03FF,
-                                        0x07FF,
-                                        0x0FFF };
-
-const unsigned short PdfLZWFilter::s_clear  = 0x0100;      // clear table
-const unsigned short PdfLZWFilter::s_eod    = 0x0101;      // end of data
-
-PdfLZWFilter::PdfLZWFilter()
-    : m_pPredictor( 0 )
-{
-}
-
-PdfLZWFilter::~PdfLZWFilter()
-{
-    delete m_pPredictor;
-}
-
-void PdfLZWFilter::BeginEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfLZWFilter::EncodeBlockImpl( const char*, pdf_long )
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfLZWFilter::EndEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfLZWFilter::BeginDecodeImpl( const PdfDictionary* pDecodeParms )
-{ 
-    m_mask       = 0;
-    m_code_len   = 9;
-    m_character  = 0;
-
-    m_bFirst     = true;
-
-    m_pPredictor = pDecodeParms ? new PdfPredictorDecoder( pDecodeParms ) : NULL;
-
-    InitTable();
-}
-
-void PdfLZWFilter::DecodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    unsigned int       buffer_size = 0;
-    const unsigned int buffer_max  = 24;
-
-    pdf_uint32         old         = 0;
-    pdf_uint32         code        = 0;
-    pdf_uint32         buffer      = 0;
-
-    TLzwItem           item;
-
-    std::vector<unsigned char> data;
-
-    if( m_bFirst ) 
-    {
-        m_character = *pBuffer;
-        m_bFirst    = false;
-    }
-
-    while( lLen ) 
-    {
-        // Fill the buffer
-        while( buffer_size <= (buffer_max-8) && lLen )
-        {
-            buffer <<= 8;
-            buffer |= static_cast<pdf_uint32>(static_cast<unsigned char>(*pBuffer));
-            buffer_size += 8;
-
-            ++pBuffer;
-            lLen--;
-        }
-
-        // read from the buffer
-        while( buffer_size >= m_code_len ) 
-        {
-            code         = (buffer >> (buffer_size - m_code_len)) & PdfLZWFilter::s_masks[m_mask];
-            buffer_size -= m_code_len;
-
-            if( code == PdfLZWFilter::s_clear ) 
-            {
-                m_mask     = 0;
-                m_code_len = 9;
-
-                InitTable();
-            }
-            else if( code == PdfLZWFilter::s_eod ) 
-            {
-                lLen = 0;
-                break;
-            }
-            else 
-            {
-                if( code >= m_table.size() )
-                {
-                    if (old >= m_table.size())
-                    {
-                        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-                    }
-                    data = m_table[old].value;
-                    data.push_back( m_character );
-                }
-                else
-                    data = m_table[code].value;
-
-                // Write data to the output device
-                if( m_pPredictor ) 
-                    m_pPredictor->Decode( reinterpret_cast<char*>(&(data[0])), data.size(), GetStream() );
-                else
-                    GetStream()->Write( reinterpret_cast<char*>(&(data[0])), data.size());
-
-                m_character = data[0];
-                if( old < m_table.size() ) // fix the first loop
-                    data = m_table[old].value;
-                data.push_back( m_character );
-
-                item.value = data;
-                m_table.push_back( item );
-
-                old = code;
-
-                switch( m_table.size() ) 
-                {
-                    case 511:
-                    case 1023:
-                    case 2047:
-                        ++m_code_len;
-                        ++m_mask;
-                    default:
-                        break;
-                }
-            }
-        }
-    }
-}
-
-void PdfLZWFilter::EndDecodeImpl()
-{
-    delete m_pPredictor;
-    m_pPredictor = NULL;
-}
-
-void PdfLZWFilter::InitTable()
-{
-    int      i;
-    TLzwItem item;
-
-    m_table.clear();
-    m_table.reserve( LZW_TABLE_SIZE );
-
-    for( i=0;i<=255;i++ )
-    {
-        item.value.clear();
-        item.value.push_back( static_cast<unsigned char>(i) );
-        m_table.push_back( item );
-    }
-
-    // Add dummy entry, which is never used by decoder
-    item.value.clear();
-    m_table.push_back( item );
-}
-
-
-
-// -------------------------------------------------------
-// DCTDecode
-// -------------------------------------------------------
-#ifdef PODOFO_HAVE_JPEG_LIB
-
-/*
- * The actual filter implementation
- */
-PdfDCTFilter::PdfDCTFilter()
-    : m_pDevice( NULL )
-{
-}
-
-PdfDCTFilter::~PdfDCTFilter()
-{
-}
-
-void PdfDCTFilter::BeginEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfDCTFilter::EncodeBlockImpl( const char*, pdf_long )
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfDCTFilter::EndEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfDCTFilter::BeginDecodeImpl( const PdfDictionary* )
-{ 
-    // Setup variables for JPEGLib
-    m_cinfo.err = jpeg_std_error( &m_jerr );
-
-    jpeg_create_decompress( &m_cinfo );
-
-    m_pDevice = new PdfOutputDevice( &m_buffer );
-}
-
-void PdfDCTFilter::DecodeBlockImpl( const char* pBuffer, pdf_long lLen )
-{
-    m_pDevice->Write( pBuffer, lLen );
-}
-
-void PdfDCTFilter::EndDecodeImpl()
-{
-    delete m_pDevice;
-    m_pDevice = NULL;
-
-    jpeg_memory_src ( &m_cinfo, reinterpret_cast<JOCTET*>(m_buffer.GetBuffer()), m_buffer.GetSize() );
-
-    if( jpeg_read_header(&m_cinfo, TRUE) <= 0 )
-    {
-        (void) jpeg_destroy_decompress(&m_cinfo);
-
-        PODOFO_RAISE_ERROR( ePdfError_UnexpectedEOF );
-    }
-
-    jpeg_start_decompress(&m_cinfo);
-
-
-    char*      pOutBuffer;
-    JSAMPARRAY pBuffer;	
-    long       lRowBytes   = m_cinfo.output_width * m_cinfo.output_components;
-    const int  iComponents = m_cinfo.output_components;
-
-    // pBuffer will be deleted by jpeg_destroy_decompress
-    pBuffer    = (*m_cinfo.mem->alloc_sarray)( reinterpret_cast<j_common_ptr>( &m_cinfo ), JPOOL_IMAGE, lRowBytes, 1);
-    pOutBuffer = static_cast<char*>(malloc( lRowBytes * sizeof(char)) );
-
-    while( m_cinfo.output_scanline < m_cinfo.output_height ) 
-    {
-        jpeg_read_scanlines(&m_cinfo, pBuffer, 1);
-        if( iComponents == 4 ) 
-        {
-            for( unsigned int i=0, c=0; i < m_cinfo.output_width; i++, c+=4 ) 
-            {
-                pOutBuffer[c]   = pBuffer[0][i*4];
-                pOutBuffer[c+1] = pBuffer[0][i*4+1];
-                pOutBuffer[c+2] = pBuffer[0][i*4+2];
-                pOutBuffer[c+3] = pBuffer[0][i*4+3];
-            }
-        }
-        else if( iComponents == 3 ) 
-        {
-            for( unsigned int i=0, c=0; i < m_cinfo.output_width; i++, c+=3 ) 
-            {
-                pOutBuffer[c]   = pBuffer[0][i*3];
-                pOutBuffer[c+1] = pBuffer[0][i*3+1];
-                pOutBuffer[c+2] = pBuffer[0][i*3+2];
-            }
-        }
-        else if( iComponents == 1 ) 
-        {
-            memcpy( pOutBuffer, pBuffer[0], m_cinfo.output_width );
-        }
-        else
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "DCTDecode unknown components" );
-        }
-        
-        GetStream()->Write( reinterpret_cast<char*>(pOutBuffer), lRowBytes );
-    }
-
-    free( pOutBuffer );
-    (void) jpeg_destroy_decompress( &m_cinfo );
-}
-
-// -------------------------------------------------------
-// memsrc.c
-// -------------------------------------------------------
-/*
- * memsrc.c
- *
- * Copyright (C) 1994-1996, Thomas G. Lane.
- * This file is part of the Independent JPEG Group's software.
- * For conditions of distribution and use, see the accompanying README file.
- *
- * This file contains decompression data source routines for the case of
- * reading JPEG data from a memory buffer that is preloaded with the entire
- * JPEG file. This would not seem especially useful at first sight, but
- * a number of people have asked for it.
- * This is really just a stripped-down version of jdatasrc.c. Comparison
- * of this code with jdatasrc.c may be helpful in seeing how to make
- * custom source managers for other purposes.
-*/
-
-
-
-/* Expanded data source object for memory input */
-typedef struct {
-    struct jpeg_source_mgr pub; /* public fields */
-    JOCTET eoi_buffer[2]; /* a place to put a dummy EOI */
-} my_source_mgr;
-
-typedef my_source_mgr * my_src_ptr;
-
-/*
- * Initialize source --- called by jpeg_read_header
- * before any data is actually read.
- */
-
-
-
-METHODDEF(void)
-init_source (j_decompress_ptr)
-{
-    /* No work, since jpeg_memory_src set up the buffer pointer and count.
-     * Indeed, if we want to read multiple JPEG images from one buffer,
-     * this *must* not do anything to the pointer.
-     */
-}
-
-/*
- * Fill the input buffer --- called whenever buffer is emptied.
- *
- * In this application, this routine should never be called; if it is called,
- * the decompressor has overrun the end of the input buffer, implying we
- * supplied an incomplete or corrupt JPEG datastream. A simple error exit
- * might be the most appropriate response.
- *
- * But what we choose to do in this code is to supply dummy EOI markers
- * in order to force the decompressor to finish processing and supply
- * some sort of output image, no matter how corrupted.
- */
-
-METHODDEF(boolean)
-fill_input_buffer (j_decompress_ptr cinfo)
-{
-    my_src_ptr src = reinterpret_cast<my_src_ptr>(cinfo->src);
-    WARNMS(cinfo, JWRN_JPEG_EOF);
-
-    /* Create a fake EOI marker */
-    src->eoi_buffer[0] = static_cast<JOCTET>(0xFF);
-    src->eoi_buffer[1] = static_cast<JOCTET>(JPEG_EOI);
-    src->pub.next_input_byte = src->eoi_buffer;
-    src->pub.bytes_in_buffer = 2;
-
-    return TRUE;
-}
-
-/*
- * Skip data --- used to skip over a potentially large amount of
- * uninteresting data (such as an APPn marker).
- *
- * If we overrun the end of the buffer, we let fill_input_buffer deal with
- * it. An extremely large skip could cause some time-wasting here, but
- * it really isn't supposed to happen ... and the decompressor will never
- * skip more than 64K anyway.
- */
-METHODDEF(void)
-skip_input_data (j_decompress_ptr cinfo, long num_bytes)
-{
-    my_src_ptr src = reinterpret_cast<my_src_ptr>(cinfo->src);
-
-    if (num_bytes > 0) {
-        while (num_bytes > static_cast<long>(src->pub.bytes_in_buffer) ) {
-            num_bytes -= static_cast<long>(src->pub.bytes_in_buffer);
-            fill_input_buffer(cinfo);
-            /* note we assume that fill_input_buffer will never return FALSE,
-             * so suspension need not be handled.
-             */
-        }
-
-        src->pub.next_input_byte += static_cast<size_t>(num_bytes);
-        src->pub.bytes_in_buffer -= static_cast<size_t>(num_bytes);
-    }
-}
-
-/*
- * An additional method that can be provided by data source modules is the
- * resync_to_restart method for error recovery in the presence of RST markers.
- * For the moment, this source module just uses the default resync method
- * provided by the JPEG library. That method assumes that no backtracking
- * is possible.
- */
-
-/*
- * Terminate source --- called by jpeg_finish_decompress
- * after all data has been read. Often a no-op.
- *
- * NB: *not* called by jpeg_abort or jpeg_destroy; surrounding
- * application must deal with any cleanup that should happen even
- * for error exit.
- */
-METHODDEF(void)
-term_source (j_decompress_ptr)
-{
-    /* no work necessary here */
-}
-
-/*
- * Prepare for input from a memory buffer.
- */
-GLOBAL(void)
-jpeg_memory_src (j_decompress_ptr cinfo, const JOCTET * buffer, size_t bufsize)
-{
-    my_src_ptr src;
-
-    /* The source object is made permanent so that a series of JPEG images
-     * can be read from a single buffer by calling jpeg_memory_src
-     * only before the first one.
-     * This makes it unsafe to use this manager and a different source
-     * manager serially with the same JPEG object. Caveat programmer.
-     */
-
-    if (cinfo->src == NULL) { /* first time for this JPEG object? */
-        cinfo->src = static_cast<struct jpeg_source_mgr *>(
-            (*cinfo->mem->alloc_small) ( reinterpret_cast<j_common_ptr>(cinfo), JPOOL_PERMANENT,
-                                        sizeof(my_source_mgr)));
-
-    }
-
-
-    src = reinterpret_cast<my_src_ptr>(cinfo->src);
-    src->pub.init_source = init_source;
-    src->pub.fill_input_buffer = fill_input_buffer;
-    src->pub.skip_input_data = skip_input_data;
-    src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */
-    src->pub.term_source = term_source;
-
-    src->pub.next_input_byte = buffer;
-    src->pub.bytes_in_buffer = bufsize;
-}                                
-
-
-#endif // PODOFO_HAVE_JPEG_LIB
-
-#ifdef PODOFO_HAVE_TIFF_LIB
-
-#ifdef DS_CCITT_DEVELOPMENT_CODE
-// -------------------------------------------------------
-// 
-// -------------------------------------------------------
-static tsize_t dummy_read(thandle_t, tdata_t, tsize_t)
-{
-    return 0;
-}
-
-// -------------------------------------------------------
-// 
-// -------------------------------------------------------
-static tsize_t dummy_write(thandle_t, tdata_t, tsize_t size)
-{
-    return size;
-}
-
-// -------------------------------------------------------
-// 
-// -------------------------------------------------------
-static toff_t dummy_seek(thandle_t, toff_t, int)
-{
-
-}
-
-// -------------------------------------------------------
-// 
-// -------------------------------------------------------
-static int dummy_close(thandle_t)
-{
-
-}
-
-// -------------------------------------------------------
-// 
-// -------------------------------------------------------
-static toff_t dummy_size(thandle_t)
-{
-
-}
-#endif
-
-// -------------------------------------------------------
-// Actual filter code below
-// -------------------------------------------------------
-PdfCCITTFilter::PdfCCITTFilter()
-    : m_tiff( NULL )
-{
-}
-
-PdfCCITTFilter::~PdfCCITTFilter()
-{
-}
-
-void PdfCCITTFilter::BeginEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfCCITTFilter::EncodeBlockImpl( const char*, pdf_long )
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-void PdfCCITTFilter::EndEncodeImpl()
-{
-    PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-}
-
-#ifndef _MSC_VER
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wunused-parameter"
-#endif
-void PdfCCITTFilter::BeginDecodeImpl( const PdfDictionary* pDict )
-{ 
-#ifdef DS_CCITT_DEVELOPMENT_CODE
-
-    if( !pDict )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "PdfCCITTFilter required a DecodeParms dictionary" );
-    } 
-
-    m_tiff = TIFFClientOpen("podofo", "w", reinterpret_cast<thandle_t>(-1),
-                            dummy_read, dummy_write,
-                            dummy_seek, dummy_close, dummy_size, NULL, NULL);
-
-    if( !m_tiff ) 
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "TIFFClientOpen failed" );
-    }
-
-    m_tiff->tif_mode = O_RDONLY;
-
-    TIFFSetField(m_tiff, TIFFTAG_IMAGEWIDTH,      pDict->GetKeyAsLong( PdfName("Columns"), 1728 )->GetNumber() );
-    TIFFSetField(m_tiff, TIFFTAG_SAMPLESPERPIXEL, 1);
-    TIFFSetField(m_tiff, TIFFTAG_BITSPERSAMPLE,   1);
-    TIFFSetField(m_tiff, TIFFTAG_FILLORDER,       FILLORDER_LSB2MSB);
-    TIFFSetField(m_tiff, TIFFTAG_PLANARCONFIG,    PLANARCONFIG_CONTIG);
-    TIFFSetField(m_tiff, TIFFTAG_PHOTOMETRIC,     PHOTOMETRIC_MINISWHITE);
-    TIFFSetField(m_tiff, TIFFTAG_YRESOLUTION,     196.);
-    TIFFSetField(m_tiff, TIFFTAG_RESOLUTIONUNIT,  RESUNIT_INCH);
-
-    /*
-    m_tiff->tif_scanlinesize = TIFFSetField(m_tiff );
-
-    if( pDict ) 
-    {
-        long lEncoding = pDict->GetKeyAsLong( PdfName("K"), 0 );
-        if( lEncoding == 0 ) // pure 1D encoding, Group3 1D
-        {
-            TIFFSetField(faxTIFF,TIFFTAG_GROUP3OPTIONS, GROUP3OPT_1DENCODING);
-
-        }
-        else if( lEncoding < 0 ) // pure 2D encoding, Group4
-        {
-            TIFFSetField(faxTIFF,TIFFTAG_GROUP4OPTIONS, GROUP4OPT_2DENCODING);
-        }
-        else //if( lEncoding > 0 )  // mixed, Group3 2D
-        {
-            TIFFSetField(faxTIFF,TIFFTAG_GROUP3OPTIONS, GROUP3OPT_2DENCODING);
-        }
-
-    }
-    */
-
-#endif // DS_CCITT_DEVELOPMENT_CODE
-
-
-}
-#ifndef _MSC_VER
-#pragma GCC diagnostic pop
-#endif
-
-void PdfCCITTFilter::DecodeBlockImpl( const char*, pdf_long )
-{
-
-}
-
-void PdfCCITTFilter::EndDecodeImpl()
-{
-}
-
-#endif // PODOFO_HAVE_TIFF_LIB
-
-
-};
--- src/base/PdfFiltersPrivate.h.orig	2010-10-25 17:19:15.000000000 +0000
+++ src/base/PdfFiltersPrivate.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,958 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_FILTERS_PRIVATE_H_
-#define _PDF_FILTERS_PRIVATE_H_
-
-/**
- * \file PdfFiltersPrivate.h
- *
- * Provides implementations of various PDF stream filters.
- *
- * This is an internal header. It should not be included in podofo.h, and
- * should not be included directly by client applications. These filters should
- * only be accessed through the factory interface in PdfFilters.h .
- */
-
-#include "PdfDefines.h"
-#include "PdfDefinesPrivate.h"
-#include "PdfFilter.h"
-#include "PdfRefCountedBuffer.h"
-
-#include <zlib.h>
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-extern "C" {
-#ifdef _WIN32		// Collision between win and jpeg-headers
-#define XMD_H
-#undef FAR
-#endif
-#include "jpeglib.h"
-}
-#endif // PODOFO_HAVE_JPEG_LIB
-
-#ifdef PODOFO_HAVE_TIFF_LIB
-extern "C" {
-#include "tiffio.h"
-#ifdef _WIN32		// Collision between tiff and jpeg-headers
-#define XMD_H
-#undef FAR
-#endif
-}
-#endif // PODOFO_HAVE_TIFF_LIB
-
-
-namespace PoDoFo {
-
-#define PODOFO_FILTER_INTERNAL_BUFFER_SIZE 4096
-
-class PdfPredictorDecoder;
-class PdfOutputDevice;
-
-/** The ascii hex filter.
- */
-class PdfHexFilter : public PdfFilter {
- public:
-    virtual ~PdfHexFilter() { }
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl();
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    char m_cDecodedByte;
-    bool m_bLow;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfHexFilter::CanEncode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfHexFilter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfHexFilter::GetType() const
-{
-    return ePdfFilter_ASCIIHexDecode;
-}
-
-/** The Ascii85 filter.
- */
-class PdfAscii85Filter : public PdfFilter {
- public:
-    virtual ~PdfAscii85Filter() { }
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    /** Begin encoding data using this filter. Called by PdfFilter::BeginEncode.
-     *
-     *  \see EncodeBlockImpl
-     *  \see EndEncodeImpl
-     *  \see PdfFilter::BeginEncode
-     */
-    virtual void BeginEncodeImpl();
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data.
-     *
-     *  \see BeginEncodeImpl
-     *  \see EncodeBlockImpl
-     */
-    virtual void EndEncodeImpl();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl();
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    void EncodeTuple ( unsigned long tuple, int bytes );
-    void WidePut( unsigned long tuple, int bytes ) const;
-
- private:
-    int           m_count;
-    unsigned long m_tuple;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfAscii85Filter::CanEncode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfAscii85Filter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfAscii85Filter::GetType() const
-{
-    return ePdfFilter_ASCII85Decode;
-}
-
-/** The flate filter.
- */
-class PdfFlateFilter : public PdfFilter {
- public:
-    PdfFlateFilter();
-    virtual ~PdfFlateFilter();
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    /** Begin encoding data using this filter. Called by PdfFilter::BeginEncode.
-     *
-     *  \see EncodeBlockImpl
-     *  \see EndEncodeImpl
-     *  \see PdfFilter::BeginEncode
-     */
-    virtual void BeginEncodeImpl();
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data.
-     *
-     *  \see BeginEncodeImpl
-     *  \see EncodeBlockImpl
-     */
-    virtual void EndEncodeImpl();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     *  \param pDecodeParms additional parameters for decoding data
-     *
-     * \see BeginDecode 
-     */
-    virtual void BeginDecodeImpl( const PdfDictionary* pDecodeParms );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl();
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    void EncodeBlockInternal( const char* pBuffer, pdf_long lLen, int nMode );
-
- private:
-    unsigned char        m_buffer[PODOFO_FILTER_INTERNAL_BUFFER_SIZE];
-
-    z_stream             m_stream;
-    PdfPredictorDecoder* m_pPredictor;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfFlateFilter::CanEncode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfFlateFilter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfFlateFilter::GetType() const
-{
-    return ePdfFilter_FlateDecode;
-}
-
-
-/** The RLE filter.
- */
-class PdfRLEFilter : public PdfFilter {
- public:
-    virtual ~PdfRLEFilter() {}
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    virtual void BeginEncodeImpl();
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data.
-     *
-     *  \see BeginEncodeImpl
-     *  \see EncodeBlockImpl
-     */
-    virtual void EndEncodeImpl();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    int m_nCodeLen;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfRLEFilter::CanEncode() const
-{
-    return false;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfRLEFilter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfRLEFilter::GetType() const
-{
-    return ePdfFilter_RunLengthDecode;
-}
-
-/** The LZW filter.
- */
-class PdfLZWFilter : public PdfFilter {
-    struct TLzwItem {
-        std::vector<unsigned char> value;
-    };
-    
-    typedef std::vector<TLzwItem>     TLzwTable;
-    typedef TLzwTable::iterator       TILzwTable;
-    typedef TLzwTable::const_iterator TCILzwTable;
-
- public:
-    PdfLZWFilter();
-
-    virtual ~PdfLZWFilter();
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    /** Begin encoding data using this filter. Called by PdfFilter::BeginEncode.
-     *
-     *  \see EncodeBlockImpl
-     *  \see EndEncodeImpl
-     *  \see PdfFilter::BeginEncode
-     */
-    virtual void BeginEncodeImpl();
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data.
-     *
-     *  \see BeginEncodeImpl
-     *  \see EncodeBlockImpl
-     */
-    virtual void EndEncodeImpl();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl();
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    /** Initialize an lzw table.
-     */
-    void InitTable();
-
- private:
-    static const unsigned short s_masks[4];
-    static const unsigned short s_clear;
-    static const unsigned short s_eod;
-
-    TLzwTable     m_table;
-
-    unsigned int  m_mask;
-    unsigned int  m_code_len;
-    unsigned char m_character;
-
-    bool          m_bFirst;
-
-    PdfPredictorDecoder* m_pPredictor;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfLZWFilter::CanEncode() const
-{
-    return false;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfLZWFilter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfLZWFilter::GetType() const
-{
-    return ePdfFilter_LZWDecode;
-}
-
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-
-void PODOFO_API jpeg_memory_src (j_decompress_ptr cinfo, const JOCTET * buffer, size_t bufsize);
-
-/** The DCT filter can decoded JPEG compressed data.
- *  
- *  This filter requires JPEG lib to be available
- */
-class PdfDCTFilter : public PdfFilter {
- public:
-    PdfDCTFilter();
-
-    virtual ~PdfDCTFilter();
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    /** Begin encoding data using this filter. Called by PdfFilter::BeginEncode.
-     *
-     *  \see EncodeBlockImpl
-     *  \see EndEncodeImpl
-     *  \see PdfFilter::BeginEncode
-     */
-    virtual void BeginEncodeImpl();
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data.
-     *
-     *  \see BeginEncodeImpl
-     *  \see EncodeBlockImpl
-     */
-    virtual void EndEncodeImpl();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl();
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    struct jpeg_decompress_struct m_cinfo;
-    struct jpeg_error_mgr         m_jerr;
-
-    PdfRefCountedBuffer           m_buffer;
-    PdfOutputDevice*              m_pDevice;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfDCTFilter::CanEncode() const
-{
-    return false;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfDCTFilter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfDCTFilter::GetType() const
-{
-    return ePdfFilter_DCTDecode;
-}
-#endif // PODOFO_HAVE_JPEG_LIB
-
-#ifdef PODOFO_HAVE_TIFF_LIB
-
-/** The CCITT filter can decoded CCITTFaxDecode compressed data.
- *  
- *  This filter requires TIFFlib to be available
- */
-class PdfCCITTFilter : public PdfFilter {
- public:
-    PdfCCITTFilter();
-
-    virtual ~PdfCCITTFilter();
-
-    /** Check wether the encoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to encode data
-     */
-    inline virtual bool CanEncode() const; 
-
-    /** Begin encoding data using this filter. Called by PdfFilter::BeginEncode.
-     *
-     *  \see EncodeBlockImpl
-     *  \see EndEncodeImpl
-     *  \see PdfFilter::BeginEncode
-     */
-    virtual void BeginEncodeImpl();
-
-    /** Encode a block of data and write it to the PdfOutputStream
-     *  specified by BeginEncodeImpl.
-     *
-     *  BeginEncodeImpl() has to be called before this function.
-     *
-     *  \param pBuffer pointer to a buffer with data to encode
-     *  \param lLen length of data to encode.
-     *
-     *  Call EndEncodeImpl() after all data has been encoded
-     *
-     *
-     *  \see BeginEncodeImpl
-     *  \see EndEncodeImpl
-     */
-    virtual void EncodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /**
-     *  Finish encoding of data.
-     *
-     *  \see BeginEncodeImpl
-     *  \see EncodeBlockImpl
-     */
-    virtual void EndEncodeImpl();
-
-    /** Check wether the decoding is implemented for this filter.
-     * 
-     *  \returns true if the filter is able to decode data
-     */
-    inline virtual bool CanDecode() const; 
-
-    /** Real implementation of `BeginDecode()'. NEVER call this method directly.
-     *
-     *  By default this function does nothing. If your filter needs to do setup for decoding,
-     *  you should override this method.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is called, and
-     *  that EndDecode() was called since the last BeginDecode()/DecodeBlock().
-     *
-     * \see BeginDecode */
-    virtual void BeginDecodeImpl( const PdfDictionary* );
-
-    /** Real implementation of `DecodeBlock()'. NEVER call this method directly.
-     *
-     *  You must override this method to decode the buffer passed by the caller.
-     *
-     *  You are not obliged to immediately process any or all of the data in
-     *  the passed buffer, but you must ensure that you have processed it and
-     *  written it out by the end of EndDecodeImpl(). You must copy the buffer
-     *  if you're going to store it, as ownership is not transferred to the
-     *  filter and the caller may free the buffer at any time.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, ensures that BeginDecode() has been called, and ensures that
-     *  EndDecode() has not been called since the last BeginDecode().
-     *
-     * \see DecodeBlock */
-    virtual void DecodeBlockImpl( const char* pBuffer, pdf_long lLen );
-
-    /** Real implementation of `EndDecode()'. NEVER call this method directly.
-     *
-     * By the time this method returns, all filtered data must be written to the stream
-     * and the filter must be in a state where BeginDecode() can be safely called.
-     *
-     *  PdfFilter ensures that a valid stream is available when this method is
-     *  called, and ensures that BeginDecodeImpl() has been called.
-     *
-     * \see EndDecode */
-    virtual void EndDecodeImpl();
-
-    /** GetType of this filter.
-     *  \returns the GetType of this filter
-     */
-    inline virtual EPdfFilter GetType() const;
-
- private:
-    TIFF* m_tiff;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfCCITTFilter::CanEncode() const
-{
-    return false;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfCCITTFilter::CanDecode() const
-{
-    return true;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfFilter PdfCCITTFilter::GetType() const
-{
-    return ePdfFilter_CCITTFaxDecode;
-}
-#endif // PODOFO_HAVE_TIFF_LIB
-
-};
-
-
-#endif /* _PDF_FILTERS_PRIVATE_H_ */
--- src/base/PdfImmediateWriter.cpp.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/base/PdfImmediateWriter.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,182 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfImmediateWriter.h"
-
-#include "PdfFileStream.h"
-#include "PdfMemStream.h"
-#include "PdfObject.h"
-#include "PdfXRef.h"
-#include "PdfXRefStream.h"
-#include "PdfDefinesPrivate.h"
-
-namespace PoDoFo {
-
-PdfImmediateWriter::PdfImmediateWriter( PdfOutputDevice* pDevice, PdfVecObjects* pVecObjects, 
-                                        const PdfObject* pTrailer, EPdfVersion eVersion, 
-                                        PdfEncrypt* pEncrypt, EPdfWriteMode eWriteMode )
-    : PdfWriter( pVecObjects ), m_pParent( pVecObjects ), 
-      m_pDevice( pDevice ), m_pLast( NULL ), m_bOpenStream( false )
-{
-    if( m_pTrailer )
-        delete m_pTrailer;
-    m_pTrailer = new PdfObject( *pTrailer );
-
-    // register as observer for PdfVecObjects
-    m_pParent->Attach( this );
-    // register as stream factory for PdfVecObjects
-    m_pParent->SetStreamFactory( this );
-
-    this->CreateFileIdentifier( m_identifier, m_pTrailer );
-    // setup encryption
-    if( pEncrypt )
-    {
-        this->SetEncrypted( *pEncrypt );
-        m_pEncrypt->GenerateEncryptionKey( m_identifier );
-    }
-
-    // start with writing the header
-    this->SetPdfVersion( eVersion );
-    this->SetWriteMode( eWriteMode );
-    this->WritePdfHeader( m_pDevice );
-
-    m_pXRef = m_bXRefStream ? new PdfXRefStream( m_vecObjects, this ) : new PdfXRef();
-
-}
-
-PdfImmediateWriter::~PdfImmediateWriter()
-{
-    if( m_pParent ) 
-        m_pParent->Detach( this );
-    
-    delete m_pXRef;
-}
-
-void PdfImmediateWriter::WriteObject( const PdfObject* pObject )
-{
-    const int endObjLenght = 7;
-
-    this->FinishLastObject();
-
-    m_pXRef->AddObject( pObject->Reference(), m_pDevice->Tell(), true );
-    pObject->WriteObject( m_pDevice, this->GetWriteMode(), m_pEncrypt );
-    // Make sure, no one will add keys now to the object
-    const_cast<PdfObject*>(pObject)->SetImmutable(true);
-
-    // Let's cheat a bit:
-    // pObject has written an "endobj\n" as last data to the file.
-    // we simply overwrite this string with "stream\n" which 
-    // has excatly the same length.
-    m_pDevice->Seek( m_pDevice->Tell() - endObjLenght );
-    m_pDevice->Print( "stream\n" );
-    m_pLast = const_cast<PdfObject*>(pObject);
-}
-
-void PdfImmediateWriter::ParentDestructed()
-{
-    m_pParent = NULL;
-}
-
-void PdfImmediateWriter::Finish()
-{
-    // write all objects which are still in RAM
-    this->FinishLastObject();
-
-    // setup encrypt dictionary
-    if( m_pEncrypt )
-    {
-        // Add our own Encryption dictionary
-        m_pEncryptObj = m_vecObjects->CreateObject();
-        m_pEncrypt->CreateEncryptionDictionary( m_pEncryptObj->GetDictionary() );
-    }
-
-    this->WritePdfObjects( m_pDevice, *m_pParent, m_pXRef );
-
-    // write the XRef
-    pdf_long lXRefOffset = m_pDevice->Tell();
-    m_pXRef->Write( m_pDevice );
-            
-    // XRef streams contain the trailer in the XRef
-    if( !m_bXRefStream ) 
-    {
-        PdfObject trailer;
-        
-        // if we have a dummy offset we write also a prev entry to the trailer
-        FillTrailerObject( &trailer, m_pXRef->GetSize(), false, false );
-        
-        m_pDevice->Print("trailer\n");
-        trailer.WriteObject( m_pDevice, this->GetWriteMode(), NULL );
-    }
-    
-    m_pDevice->Print( "startxref\n%li\n%%%%EOF\n", lXRefOffset );
-    m_pDevice->Flush();
-
-    // we are done now
-    m_pParent->Detach( this );
-    m_pParent = NULL;
-}
-
-PdfStream* PdfImmediateWriter::CreateStream( PdfObject* pParent )
-{
-    return m_bOpenStream ? 
-        static_cast<PdfStream*>(new PdfMemStream( pParent )) :
-        static_cast<PdfStream*>(new PdfFileStream( pParent, m_pDevice ));
-}
-
-void PdfImmediateWriter::FinishLastObject()
-{
-    if( m_pLast ) 
-    {
-        m_pDevice->Print( "\nendstream\n" );
-        m_pDevice->Print( "endobj\n" );
-        
-        delete m_pParent->RemoveObject( m_pLast->Reference(), false );
-        m_pLast = NULL;
-
-    }
-}
-
-void PdfImmediateWriter::BeginAppendStream( const PdfStream* pStream )
-{
-    const PdfFileStream* pFileStream = dynamic_cast<const PdfFileStream*>(pStream );
-    if( pFileStream ) 
-    {
-        // Only one open file stream is allowed at a time
-        assert( !m_bOpenStream );
-        m_bOpenStream = true;
-
-        if( m_pEncrypt )
-            const_cast<PdfFileStream*>(pFileStream)->SetEncrypted( m_pEncrypt );
-    }
-}
-    
-void PdfImmediateWriter::EndAppendStream( const PdfStream* pStream )
-{
-    const PdfFileStream* pFileStream = dynamic_cast<const PdfFileStream*>(pStream );
-    if( pFileStream ) 
-    {
-        // A PdfFileStream has to be opened before
-        assert( m_bOpenStream );
-        m_bOpenStream = false;
-    }
-}
-
-};
-
--- src/base/PdfInputDevice.cpp.orig	2011-03-01 16:34:29.000000000 +0000
+++ src/base/PdfInputDevice.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,230 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfInputDevice.h"
-
-#include <cstdarg>
-#include <fstream>
-#include <sstream>
-#include "PdfDefinesPrivate.h"
-
-namespace PoDoFo {
-
-PdfInputDevice::PdfInputDevice()
-{
-    this->Init();
-}
-
-PdfInputDevice::PdfInputDevice( const char* pszFilename )
-{
-    this->Init();
-
-    if( !pszFilename ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    try {
-        m_pFile = fopen(pszFilename, "rb");
-        //m_pStream = new std::ifstream( pszFilename, std::ios::binary );
-        if( !m_pFile)
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-        }
-        m_StreamOwned = true;
-    }
-    catch(...) {
-        // should probably check the exact error, but for now it's a good error
-        PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-    }
-    //PdfLocaleImbue(*m_pStream);
-}
-
-#ifdef _WIN32
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200			// nicht f�r Visualstudio 6
-#else
-PdfInputDevice::PdfInputDevice( const wchar_t* pszFilename )
-{
-    this->Init();
-
-    if( !pszFilename ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    try {
-        // James McGill 16.02.2011 Fix wide character filename loading in windows
-        m_pFile = _wfopen(pszFilename, L"rb");
-        if( !m_pFile)
-        {
-            PdfError e( ePdfError_FileNotFound, __FILE__, __LINE__ );
-            e.SetErrorInformation( pszFilename );
-            throw e;
-        }
-        m_StreamOwned = true;
-    }
-    catch(...) {
-        // should probably check the exact error, but for now it's a good error
-        PdfError e( ePdfError_FileNotFound, __FILE__, __LINE__ );
-        e.SetErrorInformation( pszFilename );
-        throw e;
-    }
-}
-#endif
-#endif // _WIN32
-
-PdfInputDevice::PdfInputDevice( const char* pBuffer, size_t lLen )
-{
-    this->Init();
-
-    if( !pBuffer ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    try {
-        m_pStream = static_cast< std::istream* >( 
-            new std::istringstream( std::string( pBuffer, lLen ), std::ios::binary ) );
-        if( !m_pStream || !m_pStream->good() )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_FileNotFound );
-        }
-        m_StreamOwned = true;
-    }
-    catch(...) {
-        // should probably check the exact error, but for now it's a good error
-        PODOFO_RAISE_ERROR( ePdfError_FileNotFound );
-    }
-    PdfLocaleImbue(*m_pStream);
-}
-
-PdfInputDevice::PdfInputDevice( const std::istream* pInStream )
-{
-    this->Init();
-
-    m_pStream = const_cast< std::istream* >( pInStream );
-    if( !m_pStream->good() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_FileNotFound );
-    }
-    PdfLocaleImbue(*m_pStream);
-}
-
-PdfInputDevice::~PdfInputDevice()
-{
-    this->Close();
-
-    if ( m_StreamOwned ) 
-    {
-			if (m_pStream)
-        delete m_pStream;
-			if (m_pFile)
-				fclose(m_pFile);
-    }
-}
-
-void PdfInputDevice::Init()
-{
-    m_pStream     = NULL;
-		m_pFile = 0;
-    m_StreamOwned = false;
-    m_bIsSeekable = true;
-}
-
-void PdfInputDevice::Close()
-{
-    // nothing to do here, but maybe necessary for inheriting classes
-}
-
-int PdfInputDevice::GetChar() const
-{
-	if (m_pStream)
-    return m_pStream->get();
-	if (m_pFile)
-		return fgetc(m_pFile);
-	return 0;
-}
-
-int PdfInputDevice::Look() const 
-{
-	if (m_pStream)
-    return m_pStream->peek();
-	if (m_pFile) {
-		pdf_long lOffset = ftello( m_pFile );
-		int ch = GetChar();
-		fseeko( m_pFile, lOffset, SEEK_SET );
-		return ch;
-	}
-
-	return 0;
-}
-
-std::streamoff PdfInputDevice::Tell() const
-{
-	if (m_pStream)
-    return m_pStream->tellg();
-	if (m_pFile)
-		return ftello(m_pFile);
-	return 0;
-}
-/*
-void PdfInputDevice::Seek( std::streamoff off, std::ios_base::seekdir dir )
-{
-    if (m_bIsSeekable)
-        m_pStream->seekg( off, dir );
-    else
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDeviceOperation, "Tried to seek an unseekable input device." );
-}
-*/
-
-void PdfInputDevice::Seek( std::streamoff off, std::ios_base::seekdir dir )
-{
-    if (m_bIsSeekable)
-    {
-        if (m_pStream)
-        {
-            m_pStream->seekg( off, dir );
-        }
-
-        if (m_pFile)
-        {
-            fseeko( m_pFile, off, dir );
-        }
-    }
-    else
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDeviceOperation, "Tried to seek an unseekable input device." );
-    }
-}
-
-
-std::streamoff PdfInputDevice::Read( char* pBuffer, std::streamsize lLen )
-{
-	if (m_pStream) {
-    m_pStream->read( pBuffer, lLen );
-    return m_pStream->gcount();
-	}
-	else 
-	{
-		return fread(pBuffer, 1, lLen, m_pFile);
-	}
-}
-
-}; // namespace PoDoFo
--- src/base/PdfInputStream.cpp.orig	2011-03-11 15:26:07.000000000 +0000
+++ src/base/PdfInputStream.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,139 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfInputStream.h"
-
-#include "PdfInputDevice.h"
-#include "PdfDefinesPrivate.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <wchar.h>
-
-namespace PoDoFo {
-
-PdfFileInputStream::PdfFileInputStream( const char* pszFilename )
-{
-    m_hFile = fopen( pszFilename, "rb" );
-    if( !m_hFile ) 
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-    }
-}
-
-#ifdef _WIN32
-PdfFileInputStream::PdfFileInputStream( const wchar_t* pszFilename )
-{
-    m_hFile = _wfopen( pszFilename, L"rb" );
-    if( !m_hFile ) 
-    {
-        PdfError e( ePdfError_FileNotFound, __FILE__, __LINE__ );
-        e.SetErrorInformation( pszFilename );
-        throw e;
-    }
-}
-#endif // _WIN32
-
-PdfFileInputStream::~PdfFileInputStream()
-{
-    if( m_hFile )
-        fclose( m_hFile );
-}
-
-pdf_long PdfFileInputStream::Read( char* pBuffer, pdf_long lLen )
-{
-    if( !pBuffer ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // return zero if EOF is reached
-    if( feof( m_hFile ) )
-        return 0;
-
-    // return the number of bytes read and read the data
-    // into pBuffer
-    return fread( pBuffer, sizeof(char), lLen, m_hFile );
-}
-
-pdf_long PdfFileInputStream::GetFileLength()
-{
-    pdf_long lOffset = ftello( m_hFile );
-    pdf_long lLen;
-
-    fseeko( m_hFile, 0L, SEEK_END );
-    lLen = ftello( m_hFile );
-    fseeko( m_hFile, lOffset, SEEK_SET );
-
-    return lLen;
-}
-
-FILE*
-PdfFileInputStream::GetHandle()
-{
-    return m_hFile;
-}
-
-
-PdfMemoryInputStream::PdfMemoryInputStream( const char* pBuffer, pdf_long lBufferLen )
-    : m_pBuffer( pBuffer ), m_pCur( pBuffer ), m_lBufferLen( lBufferLen )
-{
-
-}
-
-PdfMemoryInputStream::~PdfMemoryInputStream()
-{
-}
-
-pdf_long PdfMemoryInputStream::Read( char* pBuffer, pdf_long lLen )
-{
-    if( !pBuffer ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pdf_long lRead = m_pCur - m_pBuffer;
-
-    // return zero if EOF is reached
-    if( lRead == m_lBufferLen ) 
-        return 0;
-
-    lLen = ( lRead + lLen <= m_lBufferLen ? lLen : m_lBufferLen - lRead );
-    memcpy( pBuffer, m_pCur, lLen );
-    m_pCur += lLen;
-    
-    return lLen;
-}
-
-PdfDeviceInputStream::PdfDeviceInputStream( PdfInputDevice* pDevice )
-    : m_pDevice( pDevice )
-{
-}
-
-PdfDeviceInputStream::~PdfDeviceInputStream()
-{
-}
-
-pdf_long PdfDeviceInputStream::Read( char* pBuffer, pdf_long lLen )
-{
-    return m_pDevice->Read( pBuffer, lLen );
-}
-
-};
--- src/base/PdfMemoryManagement.cpp.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/base/PdfMemoryManagement.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,88 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2009 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfMemoryManagement.h"
-#include "PdfDefinesPrivate.h"
-
-namespace PoDoFo {
-
-bool podofo_is_little_endian()
-{ 
-    int _p = 1;
-    return ((reinterpret_cast<char*>(&_p))[0] == 1);
-}
-
-void* podofo_malloc( size_t size )
-{
-    return malloc( size );
-}
-
-void* podofo_realloc( void* buffer, size_t size )
-{
-    return realloc( buffer, size );
-}
-
-void podofo_free( void* buffer )
-{
-    return free( buffer );
-}
-
-};
-
-// OC 17.08.2010: Activate showing the correct source for Memory Leak Detection in Visual Studio:
-// See: <afx.h>  looking for _AFX_NO_DEBUG_CRT
-//
-// Annotation:
-// defining the new and delete operators and initializeDebugHeap
-// have to be done inside the dll if podofo is compiled as dll.
-//
-// If podofo is compiled as static library
-// the main program is responsible for theese definitions and initialisations.
-// Specially the new operator may be implemented completely different
-// and may not be redefined here.
-#ifdef _MSC_VER
-#ifdef DEBUG_NEW // #if defined(_DEBUG) && defined(DEFINE_NEW_DEBUG_NEW)
-#if defined(COMPILING_SHARED_PODOFO) || defined(podofo_shared_EXPORTS)
-
-#undef new
-void* operator new(size_t ai_NewSize, const char* ac_File_, int ai_Line)
-{
-    return ::operator new(ai_NewSize, _NORMAL_BLOCK, ac_File_, ai_Line);
-}
-void operator delete(void* av_Ptr_, const char* ac_File_, int ai_Line)
-{
-    ::operator delete(av_Ptr_);
-}
-#define new DEBUG_NEW
-
-static int initializeDebugHeap()
-{
-  _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // _CRTDBG_CHECK_ALWAYS_DF|_CRTDBG_DELAY_FREE_MEM_DF
-  // test if the memory leak detection works:
-  static const char leakdata[] = "*** test memory leak ***";
-  char* memleak = new char[sizeof(leakdata)];
-  memcpy(memleak, leakdata, sizeof(leakdata));
-  return 1;
-}
-int isDebugHeapInitialized = initializeDebugHeap();
-
-#endif // podofo_shared_EXPORTS
-#endif // DEBUG_NEW
-#endif // _MSC_VER
--- src/base/PdfMemoryManagement.h.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/base/PdfMemoryManagement.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,59 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2009 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_MEMORY_MANAGEMENT_H_
-#define _PDF_MEMORY_MANAGEMENT_H_
-
-#include "PdfDefines.h"
-#include <stdlib.h>
-
-namespace PoDoFo {
-
-/**
- * Wrapper around malloc of the c-library used by PoDoFo.
- *
- * Is used to allocate buffers inside of PoDoFo.
- */
-PODOFO_API void* podofo_malloc( size_t size );
-
-/**
- * Wrapper around realloc of the c-library used by PoDoFo.
- */
-PODOFO_API void* podofo_realloc( void* buffer, size_t size );
-
-/**
- * Wrapper around free of the c-library used by PoDoFo.
- *
- * Use this to free memory allocated inside of PoDoFo
- * with podofo_malloc.
- */
-PODOFO_API void podofo_free( void* buffer );
-
-/**
- * Check during runtime if the current architecture is big- or little-endian.
- * \returns true if the architecture is little-endian
- */
-PODOFO_API bool podofo_is_little_endian();
-
-
-};
-
-#endif // _PDF_XREF_STREAM_PARSER_OBJECT_H_
-
--- src/base/PdfMemStream.cpp.orig	2012-12-12 22:55:46.000000000 +0000
+++ src/base/PdfMemStream.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,288 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfMemStream.h"
-
-#include "PdfArray.h"
-#include "PdfEncrypt.h"
-#include "PdfFilter.h"
-#include "PdfObject.h"
-#include "PdfOutputDevice.h"
-#include "PdfOutputStream.h"
-#include "PdfVariant.h"
-#include "PdfDefinesPrivate.h"
-
-#include <stdlib.h>
-
-namespace PoDoFo {
-
-PdfMemStream::PdfMemStream( PdfObject* pParent )
-    : PdfStream( pParent ), m_pStream( NULL ), m_pBufferStream( NULL ), m_lLength( 0 )
-{
-}
-
-PdfMemStream::PdfMemStream( const PdfMemStream & rhs )
-    : PdfStream( NULL ), m_pStream( NULL ), m_pBufferStream( NULL ), m_lLength( 0 )
-{
-    operator=(rhs);
-}
-
-PdfMemStream::~PdfMemStream()
-{
-}
-
-void PdfMemStream::BeginAppendImpl( const TVecFilters & vecFilters )
-{
-    m_buffer  = PdfRefCountedBuffer();
-	m_lLength = 0;
-
-    if( vecFilters.size() )
-    {
-        m_pBufferStream = new PdfBufferOutputStream( &m_buffer );
-        m_pStream       = PdfFilterFactory::CreateEncodeStream( vecFilters, m_pBufferStream );
-    }
-    else 
-        m_pStream = new PdfBufferOutputStream( &m_buffer );
-
-}
-
-void PdfMemStream::AppendImpl( const char* pszString, size_t lLen )
-{
-    m_pStream->Write( pszString, lLen );
-}
-
-void PdfMemStream::EndAppendImpl()
-{
-    if( m_pStream ) 
-    {
-        m_pStream->Close();
-
-        if( !m_pBufferStream ) 
-            m_lLength = dynamic_cast<PdfBufferOutputStream*>(m_pStream)->GetLength();
-
-        delete m_pStream;
-        m_pStream = NULL;
-    }
-
-    if( m_pBufferStream ) 
-    {
-        m_pBufferStream->Close();
-        m_lLength = m_pBufferStream->GetLength();
-        delete m_pBufferStream;
-        m_pBufferStream = NULL;
-    }
-
-    if( m_pParent )
-        m_pParent->GetDictionary().AddKey( PdfName::KeyLength, PdfVariant(static_cast<pdf_int64>(m_lLength) ) );
-}
-
-void PdfMemStream::GetCopy( char** pBuffer, pdf_long* lLen ) const
-{
-    if( !pBuffer || !lLen )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    *pBuffer = static_cast<char*>(malloc( sizeof( char ) * m_lLength ));
-    *lLen    = m_lLength;
-    
-    if( !*pBuffer )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-    
-    memcpy( *pBuffer, m_buffer.GetBuffer(), m_lLength );
-}
-
-
-void PdfMemStream::GetCopy(PdfOutputStream * pStream) const
-{
-	if( !pStream)
-	{
-		PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-	}
-	pStream->Write(m_buffer.GetBuffer(), m_lLength);
-}
-
-void PdfMemStream::FlateCompress()
-{
-    PdfObject*        pObj;
-    PdfVariant        vFilter( PdfName("FlateDecode" ) );
-    PdfVariant        vFilterList;
-    PdfArray          tFilters;
-
-    PdfArray::const_iterator tciFilters;
-    
-    if( !m_lLength )
-        return; // ePdfError_ErrOk
-
-    // TODO: Handle DecodeParms
-    if( m_pParent->GetDictionary().HasKey( "Filter" ) )
-    {
-        pObj = m_pParent->GetIndirectKey( "Filter" );
-
-        if( pObj->IsName() )
-        {
-            if( pObj->GetName() != "DCTDecode" && pObj->GetName() != "FlateDecode" )
-            {
-                tFilters.push_back( vFilter );
-                tFilters.push_back( *pObj );
-            }
-        }
-        else if( pObj->IsArray() )
-        {
-            tciFilters = pObj->GetArray().begin();
-
-            while( tciFilters != pObj->GetArray().end() )
-            {
-                if( (*tciFilters).IsName() )
-                {
-                    // do not compress DCTDecoded are already FlateDecoded streams again
-                    if( (*tciFilters).GetName() == "DCTDecode" || (*tciFilters).GetName() == "FlateDecode" )
-                    {
-                        return;
-                    }
-                }
-
-                ++tciFilters;
-            }
-
-            tFilters.push_back( vFilter );
-
-            tciFilters = pObj->GetArray().begin();
-
-            while( tciFilters != pObj->GetArray().end() )
-            {
-                tFilters.push_back( (*tciFilters) );
-                
-                ++tciFilters;
-            }
-        }
-        else
-            return;
-
-        vFilterList = PdfVariant( tFilters );
-        m_pParent->GetDictionary().AddKey( "Filter", vFilterList );
-
-        FlateCompressStreamData(); // throws an exception on error
-    }
-    else
-    {
-        m_pParent->GetDictionary().AddKey( "Filter", PdfName( "FlateDecode" ) );
-        FlateCompressStreamData();
-    }
-}
-
-void PdfMemStream::Uncompress()
-{
-    pdf_long         lLen;
-    char*        pBuffer = NULL;
-    
-    TVecFilters  vecEmpty;
-
-    if( m_pParent && m_pParent->IsDictionary() && m_pParent->GetDictionary().HasKey( "Filter" ) && m_lLength )
-    {
-        try {
-            this->GetFilteredCopy( &pBuffer, &lLen );
-        } catch( PdfError & e ) {
-            if( pBuffer )
-                free( pBuffer );
-
-            throw e;
-        }
-
-        this->Set( pBuffer, lLen, vecEmpty );
-        // free the memory allocated by GetFilteredCopy again.
-        podofo_free( pBuffer );
-
-        m_pParent->GetDictionary().RemoveKey( "Filter" ); 
-        if( m_pParent->GetDictionary().HasKey( "DecodeParms" ) ) 
-        {
-            m_pParent->GetDictionary().RemoveKey( "DecodeParms" ); 
-        }
-    }
-}
-
-void PdfMemStream::FlateCompressStreamData()
-{
-    char*            pBuffer;
-    pdf_long             lLen;
-
-    if( !m_lLength )
-        return;
-
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_FlateDecode );
-    if( pFilter.get() )
-    {
-        pFilter->Encode( m_buffer.GetBuffer(), m_buffer.GetSize(), &pBuffer, &lLen );
-        this->Set( pBuffer, lLen );
-    }
-    else
-    {
-        PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
-    }
-}
-
-const PdfStream & PdfMemStream::operator=( const PdfStream & rhs )
-{
-    const PdfMemStream* pStream = dynamic_cast<const PdfMemStream*>(&rhs);
-    if( pStream )
-        m_buffer = pStream->m_buffer;
-    else
-        return PdfStream::operator=( rhs );
-
-    m_lLength = rhs.GetLength();
-    if( m_pParent ) 
-        m_pParent->GetDictionary().AddKey( PdfName::KeyLength, PdfVariant( static_cast<pdf_int64>(m_lLength) ) );
-
-    return *this;
-}
-
-void PdfMemStream::Write( PdfOutputDevice* pDevice, PdfEncrypt* pEncrypt ) 
-{
-    pDevice->Print( "stream\n" );
-    if( pEncrypt ) 
-    {
-        pdf_long  lLen = this->GetLength();
-
-        pdf_long nOutputLen = pEncrypt->CalculateStreamLength(lLen);
-
-        char *pOutputBuffer = new char[nOutputLen];
-
-        pEncrypt->Encrypt( reinterpret_cast<const unsigned char*>(this->Get()), lLen,
-                          reinterpret_cast<unsigned char*>(pOutputBuffer), nOutputLen);
-        pDevice->Write( pOutputBuffer, nOutputLen );
-
-        delete[] pOutputBuffer;
-    }
-    else
-    {
-        pDevice->Write( this->Get(), this->GetLength() );
-    }
-    pDevice->Print( "\nendstream\n" );
-}
-
-pdf_long PdfMemStream::GetLength() const
-{
-    return m_lLength;
-}
-
-
-};
--- src/base/PdfName.cpp.orig	2011-09-30 11:26:36.000000000 +0000
+++ src/base/PdfName.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,204 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfName.h"
-
-#include "PdfOutputDevice.h"
-#include "PdfTokenizer.h"
-#include "PdfDefinesPrivate.h"
-
-#include <string.h>
-
-using PoDoFo::ePdfError_InvalidName;
-
-namespace {
-
-/**
- * This function writes a hex encoded representation of the character
- * `ch' to `buf', advancing the iterator by two steps.
- *
- * \warning no buffer length checking is performed, so MAKE SURE
- *          you have enough room for the two characters that
- *          will be written to the buffer.
- *
- * \param ch The character to write a hex representation of
- * \param buf An iterator (eg a char* or std::string::iterator) to write the
- *            characters to.  Must support the postfix ++, operator=(char) and
- *            dereference operators.
- */
-template<typename T>
-inline void hexchr(const unsigned char ch, T & it)
-{
-    *(it++) = "0123456789ABCDEF"[ch / 16];
-    *(it++) = "0123456789ABCDEF"[ch % 16];
-}
-
-/** Escape the input string according to the PDF name
- *  escaping rules and return the result.
- *
- *  \param it Iterator referring to the start of the input string
- *            ( eg a `const char *' or a `std::string::iterator' )
- *  \param length Length of input string
- *  \returns Escaped string
- */
-template<typename T>
-static std::string EscapeName(T it, size_t length)
-{
-    // Scan the input string once to find out how much memory we need
-    // to reserve for the encoded result string. We could do this in one
-    // pass using a std::ostringstream instead, but it's a LOT slower.
-    T it2(it);
-    unsigned int outchars = 0;
-    for (size_t i = 0; i < length; ++i)
-    {
-        // Null chars are illegal in names, even escaped
-        if (*it2 == '\0')
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidName, "Null byte in PDF name is illegal");
-        }
-        else 
-        {
-            // Leave room for either just the char, or a #xx escape of it.
-            outchars += (::PoDoFo::PdfTokenizer::IsRegular(*it2) && 
-                         ::PoDoFo::PdfTokenizer::IsPrintable(*it2) && (*it2 != '#')) ? 1 : 3;
-        }
-        ++it2;
-    }
-    // Reserve it. We can't use reserve() because the GNU STL doesn't seem to
-    // do it correctly; the memory never seems to get allocated.
-    std::string buf;
-    buf.resize(outchars);
-    // and generate the encoded string
-    std::string::iterator bufIt(buf.begin());
-    for (size_t z = 0; z < length; ++z)
-    {
-        if (::PoDoFo::PdfTokenizer::IsRegular(*it) && 
-            ::PoDoFo::PdfTokenizer::IsPrintable(*it) && 
-            (*it != '#') )
-            *(bufIt++) = *it;
-        else
-        {
-            *(bufIt++) = '#';
-            hexchr(static_cast<unsigned char>(*it), bufIt);
-        }
-        ++it;
-    }
-    return buf;
-}
-
-/** Interpret the passed string as an escaped PDF name
- *  and return the unescaped form.
- *
- *  \param it Iterator referring to the start of the input string
- *            ( eg a `const char *' or a `std::string::iterator' )
- *  \param length Length of input string
- *  \returns Unescaped string
- */
-template<typename T>
-static std::string UnescapeName(T it, size_t length)
-{
-    // We know the decoded string can be AT MOST
-    // the same length as the encoded one, so:
-    std::string buf;
-    buf.resize(length);
-    unsigned int incount = 0, outcount = 0;
-    while (incount++ < length)
-    {
-        if (*it == '#')
-        {
-            unsigned char hi = static_cast<unsigned char>(*(++it)); ++incount;
-            unsigned char low = static_cast<unsigned char>(*(++it)); ++incount;
-            hi  -= ( hi  < 'A' ? '0' : 'A'-10 );
-            low -= ( low < 'A' ? '0' : 'A'-10 );
-            buf[outcount++] = (hi << 4) | (low & 0x0F);
-        }
-        else
-            buf[outcount++] = *it;
-        ++it;
-    }
-    // Chop buffer off at number of decoded bytes
-    buf.resize(outcount);
-    return buf;
-}
-
-}; // End anonymous namespace
-
-namespace PoDoFo {
-
-const PdfName PdfName::KeyContents  = PdfName( "Contents" );
-const PdfName PdfName::KeyFlags     = PdfName( "Flags" );
-const PdfName PdfName::KeyLength    = PdfName( "Length" );
-const PdfName PdfName::KeyNull      = PdfName();
-const PdfName PdfName::KeyRect      = PdfName( "Rect" );
-const PdfName PdfName::KeySize      = PdfName( "Size" );
-const PdfName PdfName::KeySubtype   = PdfName( "Subtype" );
-const PdfName PdfName::KeyType      = PdfName( "Type" );
-const PdfName PdfName::KeyFilter    = PdfName( "Filter" );
-
-PdfName::~PdfName()
-{
-}
-
-PdfName PdfName::FromEscaped( const std::string & sName )
-{
-    return PdfName(UnescapeName(sName.begin(), sName.length()));
-}
-
-PdfName PdfName::FromEscaped( const char * pszName, pdf_long ilen )
-{
-    if( !ilen && pszName )
-        ilen = strlen( pszName );
-
-    return PdfName(UnescapeName(pszName, ilen));
-}
-
-void PdfName::Write( PdfOutputDevice* pDevice, EPdfWriteMode, const PdfEncrypt* ) const
-{
-    // Allow empty names, which are legal according to the PDF specification
-    pDevice->Print( "/" );
-    if( m_Data.length() )
-    {
-        std::string escaped( EscapeName(m_Data.begin(), m_Data.length()) );
-        pDevice->Write( escaped.c_str(), escaped.length() );
-    }
-}
-
-std::string PdfName::GetEscapedName() const
-{
-    return EscapeName(m_Data.begin(), m_Data.length());
-}
-
-bool PdfName::operator==( const char* rhs ) const
-{
-    /*
-      If the string is empty and you pass NULL - that's equivalent
-      If the string is NOT empty and you pass NULL - that's not equal
-      Otherwise, compare them
-    */
-    if( m_Data.empty() && !rhs )
-        return true;
-    else if( !m_Data.empty() && !rhs )
-        return false;
-    else
-        return ( m_Data == std::string( rhs ) );
-}
-
-};
-
--- src/base/PdfObject.cpp.orig	2011-01-04 20:25:13.000000000 +0000
+++ src/base/PdfObject.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,339 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfObject.h"
-
-#include "PdfArray.h"
-#include "PdfDictionary.h"
-#include "PdfEncrypt.h"
-#include "PdfFileStream.h"
-#include "PdfOutputDevice.h"
-#include "PdfStream.h"
-#include "PdfVariant.h"
-#include "PdfDefinesPrivate.h"
-
-#include <sstream>
-#include <fstream>
-#include <cassert>
-
-#include <string.h>
-
-using namespace std;
-
-namespace PoDoFo {
-
-PdfObject::PdfObject()
-    : PdfVariant( PdfDictionary() )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfReference & rRef, const char* pszType )
-    : PdfVariant( PdfDictionary() ), m_reference( rRef )
-{
-    InitPdfObject();
-
-    if( pszType )
-        this->GetDictionary().AddKey( PdfName::KeyType, PdfName( pszType ) );
-}
-
-PdfObject::PdfObject( const PdfReference & rRef, const PdfVariant & rVariant )
-    : PdfVariant( rVariant ), m_reference( rRef )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfVariant & var )
-    : PdfVariant( var )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( bool b )
-    : PdfVariant( b )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( pdf_int64 l )
-    : PdfVariant( l )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( double d )
-    : PdfVariant( d )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfString & rsString )
-    : PdfVariant( rsString )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfName & rName )
-    : PdfVariant( rName )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfReference & rRef )
-    : PdfVariant( rRef )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfArray & tList )
-    : PdfVariant( tList )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfDictionary & rDict )
-    : PdfVariant( rDict )
-{
-    InitPdfObject();
-}
-
-PdfObject::PdfObject( const PdfObject & rhs ) 
-    : PdfVariant( rhs ), m_reference( rhs.m_reference )
-{
-    InitPdfObject();
-
-    // DS: If you change this code, also change the assignment operator.
-    //     As the copy constructor is called very often,
-    //     it contains a copy of parts of the assignment code to be faster.
-    const_cast<PdfObject*>(&rhs)->DelayedStreamLoad();
-    m_bDelayedStreamLoadDone = rhs.DelayedStreamLoadDone();
-
-    if( rhs.m_pStream )
-        m_pStream = m_pOwner->CreateStream( *(rhs.m_pStream) );
-
-#if defined(PODOFO_EXTRA_CHECKS)
-    // Must've been demand loaded or already done
-    assert(DelayedLoadDone());
-    assert(DelayedStreamLoadDone());
-#endif
-}
-
-PdfObject::~PdfObject()
-{
-    delete m_pStream;
-    m_pStream = NULL;
-}
-
-void PdfObject::InitPdfObject()
-{
-    m_pStream                 = NULL;
-    m_pOwner                  = NULL;
-
-    m_bDelayedStreamLoadDone  = true;
-
-#if defined(PODOFO_EXTRA_CHECKS)
-    m_bDelayedStreamLoadInProgress = false;
-#endif
-}
-
-void PdfObject::WriteObject( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode,
-                             PdfEncrypt* pEncrypt, const PdfName & keyStop ) const
-{
-    DelayedStreamLoad();
-
-    if( !pDevice )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( m_reference.IsIndirect() )
-    {
-        if( (eWriteMode & ePdfWriteMode_Clean) == ePdfWriteMode_Clean ) 
-        {
-            pDevice->Print( "%i %i obj\n", m_reference.ObjectNumber(), m_reference.GenerationNumber() );
-        }
-        else 
-        {
-            pDevice->Print( "%i %i obj", m_reference.ObjectNumber(), m_reference.GenerationNumber() );
-        }
-    }
-
-    if( pEncrypt ) 
-    {
-        pEncrypt->SetCurrentReference( m_reference );
-    }
-
-    if( pEncrypt && m_pStream )
-    {
-        // Set length if it is a key
-        PdfFileStream* pFileStream = dynamic_cast<PdfFileStream*>(m_pStream);
-        if( !pFileStream )
-        {
-            // PdfFileStream handles encryption internally
-            pdf_long lLength = pEncrypt->CalculateStreamLength(m_pStream->GetLength());
-            PdfVariant varLength = static_cast<pdf_int64>(lLength);
-            *(const_cast<PdfObject*>(this)->GetIndirectKey( PdfName::KeyLength )) = varLength;
-        }
-    }
-
-    this->Write( pDevice, eWriteMode, pEncrypt, keyStop );
-    pDevice->Print( "\n" );
-
-    if( m_pStream )
-    {
-        m_pStream->Write( pDevice, pEncrypt );
-    }
-
-    if( m_reference.IsIndirect() )
-    {
-        pDevice->Print( "endobj\n" );
-    }
-}
-
-PdfObject* PdfObject::GetIndirectKey( const PdfName & key ) const
-{
-    const PdfObject* pObj = NULL;
-
-    if( this->IsDictionary() && this->GetDictionary().HasKey( key ) )
-    {
-        pObj = this->GetDictionary().GetKey( key );
-        if( pObj->IsReference() ) 
-        {
-            if( !m_pOwner )
-            {
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "Object is a reference but does not have an owner!" );
-            }
-
-            pObj = m_pOwner->GetObject( pObj->GetReference() );
-        }
-        else
-            const_cast<PdfObject*>(pObj)->SetOwner( GetOwner() );// even directs might want an owner...
-    }
-
-    // DominikS: TODO Remove const on GetIndirectKey
-    return const_cast<PdfObject*>(pObj);
-}
-
-pdf_long PdfObject::GetObjectLength( EPdfWriteMode eWriteMode )
-{
-    PdfOutputDevice device;
-
-    this->WriteObject( &device, eWriteMode, NULL  );
-
-    return device.GetLength();
-}
-
-PdfStream* PdfObject::GetStream()
-{
-    DelayedStreamLoad();
-    return GetStream_NoDL();
-}
-
-PdfStream* PdfObject::GetStream_NoDL()
-{
-    if( !m_pStream )
-    {
-        if ( GetDataType() != ePdfDataType_Dictionary )
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Tried to get stream of non-dictionary object");
-	    }
-        if ( !m_reference.IsIndirect() )
-		{
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Tried to get stream of non-indirect PdfObject");
-		}
-        if( !m_pOwner ) 
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "Tried to create stream on PdfObject lacking owning document/PdfVecObjects" );
-        }
-
-        m_pStream = m_pOwner->CreateStream( this );
-    }
-
-    SetDirty( true );
-    return m_pStream;
-}
-
-const PdfStream* PdfObject::GetStream() const
-{
-    DelayedStreamLoad();
-
-    return m_pStream;
-}
-
-void PdfObject::FlateCompressStream() 
-{
-    // TODO: If the stream isn't already in memory, defer loading and compression until first read of the stream to save some memory.
-    DelayedStreamLoad();
-
-    /*
-    if( m_pStream )
-        m_pStream->FlateCompress();
-    */
-}
-
-const PdfObject & PdfObject::operator=( const PdfObject & rhs )
-{
-    // DS: If you change this code, also change the copy constructor.
-    //     As the copy constructor is called very often,
-    //     it contains a copy of parts of this code to be faster.
-
-    delete m_pStream;
-
-    const_cast<PdfObject*>(&rhs)->DelayedStreamLoad();
-
-    m_reference     = rhs.m_reference;
-    m_pOwner        = rhs.m_pOwner;
-
-    PdfVariant::operator=( rhs );
-
-    m_bDelayedStreamLoadDone = rhs.DelayedStreamLoadDone();
-
-    if( rhs.m_pStream )
-        m_pStream = m_pOwner->CreateStream( *(rhs.m_pStream) );
-
-#if defined(PODOFO_EXTRA_CHECKS)
-    // Must've been demand loaded or already done
-    assert(DelayedLoadDone());
-    assert(DelayedStreamLoadDone());
-#endif
-
-    return *this;
-}
-
-pdf_long PdfObject::GetByteOffset( const char* pszKey, EPdfWriteMode eWriteMode )
-{
-    PdfOutputDevice device;
-
-    if( !pszKey )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( !this->GetDictionary().HasKey( pszKey ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidKey );
-    }
-
-    this->Write( &device, eWriteMode, NULL, pszKey );
-    
-    return device.GetLength();
-}
-
-};
--- src/base/PdfObjectStreamParserObject.cpp.orig	2024-06-29 17:32:05.017340117 +0000
+++ src/base/PdfObjectStreamParserObject.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,115 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfObjectStreamParserObject.h"
-
-#include "PdfDictionary.h"
-#include "PdfEncrypt.h"
-#include "PdfInputDevice.h"
-#include "PdfParserObject.h"
-#include "PdfStream.h"
-#include "PdfVecObjects.h"
-
-#include <algorithm>
-
-#if defined(PODOFO_VERBOSE_DEBUG)
-#include <iostream>
-#endif
-
-namespace PoDoFo {
-
-PdfObjectStreamParserObject::PdfObjectStreamParserObject(PdfParserObject* pParser, PdfVecObjects* pVecObjects, const PdfRefCountedBuffer & rBuffer, PdfEncrypt* pEncrypt )
-    : m_pParser( pParser ), m_vecObjects( pVecObjects ), m_buffer( rBuffer ), m_pEncrypt( pEncrypt )
-{
-
-}
-
-PdfObjectStreamParserObject::~PdfObjectStreamParserObject()
-{
-
-}
-
-void PdfObjectStreamParserObject::Parse(ObjectIdList const & list)
-{
-    long long lNum   = m_pParser->GetDictionary().GetKeyAsLong( "N", 0 );
-    long long lFirst = m_pParser->GetDictionary().GetKeyAsLong( "First", 0 );
-    
-    char* pBuffer;
-    pdf_long lBufferLen;
-    m_pParser->GetStream()->GetFilteredCopy( &pBuffer, &lBufferLen );
-
-    try {
-        this->ReadObjectsFromStream( pBuffer, lBufferLen, lNum, lFirst, list );
-        free( pBuffer );
-
-        // the object stream is not needed anymore in the final PDF
-        delete m_vecObjects->RemoveObject( m_pParser->Reference() );
-        m_pParser = NULL;
-
-    } catch( PdfError & rError ) {
-        free( pBuffer );
-        throw rError;
-    }
-}
-
-void PdfObjectStreamParserObject::ReadObjectsFromStream( char* pBuffer, pdf_long lBufferLen, long long lNum, long long lFirst, ObjectIdList const & list)
-{
-    PdfRefCountedInputDevice device( pBuffer, lBufferLen );
-    PdfTokenizer             tokenizer( device, m_buffer );
-    PdfVariant               var;
-    int                      i = 0;
-
-    while( static_cast<long long>(i) < lNum )
-    {
-        const long long lObj     = tokenizer.GetNextNumber();
-        const long long lOff     = tokenizer.GetNextNumber();
-        const std::streamoff pos = device.Device()->Tell();
-
-        // move to the position of the object in the stream
-        device.Device()->Seek( static_cast<std::streamoff>(lFirst + lOff) );
-
-		// use a second tokenizer here so that anything that gets dequeued isn't left in the tokenizer that reads the offsets and lengths
-	    PdfTokenizer variantTokenizer( device, m_buffer );
-        variantTokenizer.GetNextVariant( var, m_pEncrypt );
-		bool should_read = std::find(list.begin(), list.end(), lObj) != list.end();
-#if defined(PODOFO_VERBOSE_DEBUG)
-        std::cerr << "ReadObjectsFromStream STREAM=" << m_pParser->Reference().ToString() <<
-			", OBJ=" << lObj <<
-			", " << (should_read ? "read" : "skipped") << std::endl;
-#endif
-		if (should_read)
-        {
-			if(m_vecObjects->GetObject(PdfReference( static_cast<int>(lObj), 0LL ))) 
-            {
-                PdfError::LogMessage( eLogSeverity_Warning, "Object: %li 0 R will be deleted and loaded again.\n", lObj );
-                delete m_vecObjects->RemoveObject(PdfReference( static_cast<int>(lObj), 0LL ),false);
-            }
-            m_vecObjects->insert_sorted( new PdfObject( PdfReference( static_cast<int>(lObj), 0LL ), var ) );
-		}
-
-        // move back to the position inside of the table of contents
-        device.Device()->Clear();
-        device.Device()->Seek( pos );
-
-        ++i;
-    }
-}
-
-}; 
--- src/base/PdfOutputStream.cpp.orig	2024-06-29 17:32:05.099339746 +0000
+++ src/base/PdfOutputStream.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,141 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfOutputStream.h"
-
-#include "PdfOutputDevice.h"
-#include "PdfRefCountedBuffer.h"
-#include "PdfDefinesPrivate.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-namespace PoDoFo {
-
-PdfFileOutputStream::PdfFileOutputStream( const char* pszFilename )
-{
-    m_hFile = fopen( pszFilename, "wb" );
-    if( !m_hFile ) 
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-    }
-}
-
-PdfFileOutputStream::~PdfFileOutputStream()
-{
-    Close();
-}
-
-pdf_long PdfFileOutputStream::Write( const char* pBuffer, pdf_long lLen )
-{
-    return fwrite( pBuffer, sizeof(char), lLen, m_hFile );
-}
-
-void PdfFileOutputStream::Close() 
-{
-    if( m_hFile )
-    {
-        fclose( m_hFile );
-        m_hFile = NULL;
-    }
-}
-
-PdfMemoryOutputStream::PdfMemoryOutputStream( pdf_long lInitial )
-    : m_lLen( 0 ), m_bOwnBuffer( true )
-{
-    m_lSize   = lInitial;
-    m_pBuffer = static_cast<char*>(podofo_malloc( m_lSize * sizeof(char) ));
-    
-    if( !m_pBuffer ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-}
-
-PdfMemoryOutputStream::PdfMemoryOutputStream( char* pBuffer, pdf_long lLen )
-    : m_lLen( 0 ), m_bOwnBuffer( false )
-{
-    m_lSize   = lLen;
-    m_pBuffer = pBuffer;
-}
-
-
-PdfMemoryOutputStream::~PdfMemoryOutputStream()
-{
-    if( m_bOwnBuffer )
-        podofo_free( m_pBuffer );
-}
-
-pdf_long PdfMemoryOutputStream::Write( const char* pBuffer, pdf_long lLen )
-{
-    if( !pBuffer ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( m_lLen + lLen > m_lSize ) 
-    {
-        if( m_bOwnBuffer )
-        {
-            // a reallocation is required
-            m_lSize = PDF_MAX( (m_lLen + lLen), (m_lSize << 1 ) );
-            m_pBuffer = static_cast<char*>(podofo_realloc( m_pBuffer, m_lSize ));
-            if( !m_pBuffer ) 
-            {
-                PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-            }
-        }
-        else
-        {
-            PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-        }
-    }
-
-    memcpy( m_pBuffer + m_lLen, pBuffer, lLen );
-    m_lLen += lLen;
-
-    return lLen;
-}
-
-PdfDeviceOutputStream::PdfDeviceOutputStream( PdfOutputDevice* pDevice )
-    : m_pDevice( pDevice )
-{
-}
-
-pdf_long PdfDeviceOutputStream::Write( const char* pBuffer, pdf_long lLen )
-{
-    pdf_long lTell = m_pDevice->Tell();
-    m_pDevice->Write( pBuffer, lLen );
-    return m_pDevice->Tell() - lTell;
-}
-
-
-pdf_long PdfBufferOutputStream::Write( const char* pBuffer, pdf_long lLen )
-{
-    if( m_lLength + lLen >= static_cast<pdf_long>(m_pBuffer->GetSize()) ) 
-        m_pBuffer->Resize( m_lLength + lLen );
-
-    memcpy( m_pBuffer->GetBuffer() + m_lLength, pBuffer, lLen );
-    m_lLength += lLen;
-    
-    return lLen;
-}
-
-};
--- src/base/PdfOutputStream.h.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/base/PdfOutputStream.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,269 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_OUTPUT_STREAM_H_
-#define _PDF_OUTPUT_STREAM_H_
-
-#include "PdfDefines.h"
-#include "PdfRefCountedBuffer.h"
-
-#include <string>
-
-namespace PoDoFo {
-
-#define INITIAL_SIZE 4096
-
-class PdfOutputDevice;
-
-/** An interface for writing blocks of data to 
- *  a data source.
- */     
-class PODOFO_API PdfOutputStream {
- public:
-
-    virtual ~PdfOutputStream() { };
-
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     *
-     *  \returns the number of bytes written, -1 if an error ocurred
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen ) = 0;
-
-    /**
-     * Helper that writes a string via Write(const char*,long)
-     */
-    inline pdf_long Write( const std::string & s );
-
-    /** Close the PdfOutputStream.
-     *  This method may throw exceptions and has to be called 
-     *  before the descructor to end writing.
-     *
-     *  No more data may be written to the output device
-     *  after calling close.
-     */
-    virtual void Close() = 0;
-};
-
-inline pdf_long PdfOutputStream::Write( const std::string & s )
-{
-    return this->Write( s.data(), s.size() );
-}
-
-/** An output stream that writes data to a file
- */
-class PODOFO_API PdfFileOutputStream : public PdfOutputStream {
- public:
-    
-    /** Open a file for writing data
-     *  
-     *  \param pszFilename the filename of the file to read
-     */
-    PdfFileOutputStream( const char* pszFilename );
-
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     *
-     *  \returns the number of bytes written, -1 if an error ocurred
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen );
-
-    /** Close the PdfOutputStream.
-     *  This method may throw exceptions and has to be called 
-     *  before the descructor to end writing.
-     *
-     *  No more data may be written to the output device
-     *  after calling close.
-     */
-    virtual void Close();
-
- private:
-    FILE* m_hFile;
-};
-
-/** An output stream that writes data to a memory buffer
- *  If the buffer is to small, it will be enlarged automatically.
- *
- *  DS: TODO: remove in favour of PdfBufferOutputStream.
- */
-class PODOFO_API PdfMemoryOutputStream : public PdfOutputStream {
- public:
-    
-    /** 
-     *  Construct a new PdfMemoryOutputStream
-     *  \param lInitial initial size of the buffer
-     */
-    PdfMemoryOutputStream( pdf_long lInitial = INITIAL_SIZE);
-
-    /**
-     * Construct a new PdfMemoryOutputStream that writes to an existing buffer
-     * \param pBuffer handle to the buffer
-     * \param lLen length of the buffer
-     */
-    PdfMemoryOutputStream( char* pBuffer, pdf_long lLen );
-
-    ~PdfMemoryOutputStream();
-
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     *
-     *  \returns the number of bytes written, -1 if an error ocurred
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen );
-
-    /** Close the PdfOutputStream.
-     *  This method may throw exceptions and has to be called 
-     *  before the descructor to end writing.
-     *
-     *  No more data may be written to the output device
-     *  after calling close.
-     */
-    virtual void Close() { }
-
-    /** \returns the length of the written data
-     */
-    inline pdf_long GetLength() const;
-
-    /**
-     *  \returns a handle to the internal buffer.
-     *
-     *  The internal buffer is now owned by the caller
-     *  and will not be deleted by PdfMemoryOutputStream.
-     *  Further calls to write are not allowed.
-     *
-     *  The caller has to free the returned malloc'ed buffer!
-     */
-    inline char* TakeBuffer();
-
- private:
-    char* m_pBuffer;
-    char* m_pCur;
-
-    pdf_long  m_lLen;
-    pdf_long  m_lSize;
-
-    bool  m_bOwnBuffer;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline pdf_long PdfMemoryOutputStream::GetLength() const
-{
-    return m_lLen;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline char* PdfMemoryOutputStream::TakeBuffer()
-{
-    char* pBuffer = m_pBuffer;
-    m_pBuffer = NULL;
-    return pBuffer;
-}
-
-/** An output stream that writes to a PdfOutputDevice
- */
-class PODOFO_API PdfDeviceOutputStream : public PdfOutputStream {
- public:
-    
-    /** 
-     *  Write to an already opened input device
-     * 
-     *  \param pDevice an output device
-     */
-    PdfDeviceOutputStream( PdfOutputDevice* pDevice );
-
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     *
-     *  \returns the number of bytes written, -1 if an error ocurred
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen );
-
-    /** Close the PdfOutputStream.
-     *  This method may throw exceptions and has to be called 
-     *  before the descructor to end writing.
-     *
-     *  No more data may be written to the output device
-     *  after calling close.
-     */
-    virtual void Close() {}
-
- private:
-    PdfOutputDevice* m_pDevice;
-};
-
-/** An output stream that writes to a PdfRefCountedBuffer.
- * 
- *  The PdfRefCountedBuffer is resized automatically if necessary.
- */
-class PODOFO_API PdfBufferOutputStream : public PdfOutputStream {
- public:
-    
-    /** 
-     *  Write to an already opened input device
-     * 
-     *  \param pBuffer data is written to this buffer
-     */
-    PdfBufferOutputStream( PdfRefCountedBuffer* pBuffer )
-        : m_pBuffer( pBuffer ), m_lLength( pBuffer->GetSize() )
-    {
-    }
-    
-    /** Write data to the output stream
-     *  
-     *  \param pBuffer the data is read from this buffer
-     *  \param lLen    the size of the buffer 
-     *
-     *  \returns the number of bytes written, -1 if an error ocurred
-     */
-    virtual pdf_long Write( const char* pBuffer, pdf_long lLen );
-
-    virtual void Close() 
-    {
-    }
-
-    /** 
-     * \returns the length of the buffers contents
-     */
-    inline pdf_long GetLength() const 
-    {
-        return m_lLength;
-    }
-
- private:
-    PdfRefCountedBuffer* m_pBuffer;
-
-    pdf_long                 m_lLength;
-};
-
-};
-
-#endif // _PDF_OUTPUT_STREAM_H_
--- src/base/PdfParser.cpp.orig	2024-06-29 17:32:05.139339566 +0000
+++ src/base/PdfParser.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1375 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfParser.h"
-
-#include "PdfArray.h"
-#include "PdfDefinesPrivate.h"
-#include "PdfDictionary.h"
-#include "PdfEncrypt.h"
-#include "PdfInputDevice.h"
-#include "PdfMemStream.h"
-#include "PdfObjectStreamParserObject.h"
-#include "PdfOutputDevice.h"
-#include "PdfParserObject.h"
-#include "PdfStream.h"
-#include "PdfVariant.h"
-#include "PdfXRefStreamParserObject.h"
-
-#include <cstring>
-#include <cstdlib>
-#include <sstream>
-#include <algorithm>
-#include <iostream>
-#include <limits>
-
-using std::cerr;
-using std::endl;
-using std::flush;
-
-#define PDF_MAGIC_LEN       8
-#define PDF_XREF_ENTRY_SIZE 20
-#define PDF_XREF_BUF        512
-
-namespace PoDoFo {
-
-long PdfParser::s_nMaxObjects = std::numeric_limits<long>::max();
-
-PdfParser::PdfParser( PdfVecObjects* pVecObjects )
-    : PdfTokenizer(), m_vecObjects( pVecObjects ), m_bStrictParsing( false )
-
-{
-    this->Init();
-}
-
-PdfParser::PdfParser( PdfVecObjects* pVecObjects, const char* pszFilename, bool bLoadOnDemand )
-    : PdfTokenizer(), m_vecObjects( pVecObjects ), m_bStrictParsing( false )
-{
-    this->Init();
-    this->ParseFile( pszFilename, bLoadOnDemand );
-}
-
-#ifdef _WIN32
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200			// nicht f�r Visualstudio 6
-#else
-PdfParser::PdfParser( PdfVecObjects* pVecObjects, const wchar_t* pszFilename, bool bLoadOnDemand )
-    : PdfTokenizer(), m_vecObjects( pVecObjects ), m_bStrictParsing( false )
-{
-    this->Init();
-    this->ParseFile( pszFilename, bLoadOnDemand );
-}
-#endif
-#endif // _WIN32
-
-PdfParser::PdfParser( PdfVecObjects* pVecObjects, const char* pBuffer, long lLen, bool bLoadOnDemand )
-    : PdfTokenizer(), m_vecObjects( pVecObjects ), m_bStrictParsing( false )
-{
-    this->Init();
-    this->ParseFile( pBuffer, lLen, bLoadOnDemand );
-}
-
-PdfParser::PdfParser( PdfVecObjects* pVecObjects, const PdfRefCountedInputDevice & rDevice, 
-                      bool bLoadOnDemand )
-    : PdfTokenizer(), m_vecObjects( pVecObjects ), m_bStrictParsing( false )
-{
-    this->Init();
-
-    if( !rDevice.Device() )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "Cannot create PdfRefCountedInputDevice." );
-    }
-
-    this->ParseFile( rDevice, bLoadOnDemand );
-}
-
-PdfParser::~PdfParser()
-{
-    Clear();
-}
-
-void PdfParser::Init() 
-{
-    m_bLoadOnDemand   = false;
-
-    m_device          = PdfRefCountedInputDevice();
-    m_pTrailer        = NULL;
-    m_pLinearization  = NULL;
-    m_offsets.clear();
-
-    m_pEncrypt        = NULL;
-
-    m_ePdfVersion     = ePdfVersion_Default;
-
-    m_nXRefOffset     = 0;
-    m_nFirstObject    = 0;
-    m_nNumObjects     = 0;
-    m_nXRefLinearizedOffset = 0;
-    m_lLastEOFOffset  = 0;
-
-    m_bIgnoreBrokenObjects = false;
-    m_nIncrementalUpdates = 0;
-    m_nReadNextTrailerLevel = 0;
-}
-
-void PdfParser::ParseFile( const char* pszFilename, bool bLoadOnDemand )
-{
-    if( !pszFilename || !pszFilename[0] )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    PdfRefCountedInputDevice device( pszFilename, "rb" );
-    if( !device.Device() )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-    }
-
-    this->ParseFile( device, bLoadOnDemand );
-}
-
-#ifdef _WIN32
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200			// nicht f�r Visualstudio 6
-#else
-void PdfParser::ParseFile( const wchar_t* pszFilename, bool bLoadOnDemand )
-{
-    if( !pszFilename || !pszFilename[0] )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    PdfRefCountedInputDevice device( pszFilename, "rb" );
-    if( !device.Device() )
-    {
-		PdfError e( ePdfError_FileNotFound, __FILE__, __LINE__ );
-		e.SetErrorInformation( pszFilename );
-		throw e;
-	}
-
-    this->ParseFile( device, bLoadOnDemand );
-}
-#endif
-#endif // _WIN32
-
-void PdfParser::ParseFile( const char* pBuffer, long lLen, bool bLoadOnDemand )
-{
-    if( !pBuffer || !lLen )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    PdfRefCountedInputDevice device( pBuffer, lLen );
-    if( !device.Device() )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "Cannot create PdfParser from buffer." );
-    }
-
-    this->ParseFile( device, bLoadOnDemand );
-}
-
-void PdfParser::ParseFile( const PdfRefCountedInputDevice & rDevice, bool bLoadOnDemand )
-{
-    Clear();
-
-    m_device = rDevice;
-
-    m_bLoadOnDemand = bLoadOnDemand;
-
-    try {
-        if( !IsPdfFile() )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_NoPdfFile );
-        }
-    
-        ReadDocumentStructure();
-        ReadObjects();
-    } catch( PdfError & e ) {
-        if( e.GetError() == ePdfError_InvalidPassword ) 
-        {
-            // Do not clean up, expect user to call ParseFile again
-            throw e;
-        }
-
-        // If this is being called from a constructor then the
-        // destructor will not be called.
-        // Clean up here  
-        Clear();
-        e.AddToCallstack( __FILE__, __LINE__, "Unable to load objects from file." );
-        throw e;
-    }
-}
-
-
-void PdfParser::Clear()
-{
-    m_setObjectStreams.clear();
-    m_offsets.clear();
-
-    m_device = PdfRefCountedInputDevice();
-
-    delete m_pTrailer;
-    m_pTrailer = NULL;
-
-    delete m_pLinearization;
-    m_pLinearization = NULL;
-
-    delete m_pEncrypt;
-    m_pEncrypt = NULL;
-
-    this->Init();
-}
-
-void PdfParser::ReadDocumentStructure()
-{
-// Ulrich Arnold 8.9.2009, deactivated because of problems during reading xref's
-//    HasLinearizationDict();
-    
-    // position at the end of the file to search the xref table.
-    m_device.Device()->Seek( 0, std::ios_base::end );
-    m_nFileSize = m_device.Device()->Tell();
-
-// James McGill 18.02.2011, validate the eof marker and when not in strict mode accept garbage after it
-    try {
-        CheckEOFMarker();
-    } catch( PdfError & e ) {
-        e.AddToCallstack( __FILE__, __LINE__, "EOF marker could not be found." );
-        throw e;
-    }
-
-    try {
-        ReadXRef( &m_nXRefOffset );
-    } catch( PdfError & e ) {
-        e.AddToCallstack( __FILE__, __LINE__, "Unable to find startxref entry in file." );
-        throw e;
-    }
-
-    try {
-        ReadTrailer();
-    } catch( PdfError & e ) {
-        e.AddToCallstack( __FILE__, __LINE__, "Unable to find trailer in file." );
-        throw e;
-    }
-
-    if( m_pLinearization )
-    {
-        try { 
-            ReadXRefContents( m_nXRefOffset, true );
-        } catch( PdfError & e ) {
-            e.AddToCallstack( __FILE__, __LINE__, "Unable to skip xref dictionary." );
-            throw e;
-        }
-
-        // another trailer directory is to follow right after this XRef section
-        try {
-            ReadNextTrailer();
-        } catch( PdfError & e ) {
-            if( e != ePdfError_NoTrailer )
-                throw e;
-        }
-    }
-
-    if( m_pTrailer->IsDictionary() && m_pTrailer->GetDictionary().HasKey( PdfName::KeySize ) )
-    {
-        m_nNumObjects = static_cast<long>(m_pTrailer->GetDictionary().GetKeyAsLong( PdfName::KeySize ));
-    }
-    else
-    {
-        PdfError::LogMessage( eLogSeverity_Warning, "PDF Standard Violation: No /Size key was specified in the trailer directory. Will attempt to recover." );
-        // Treat the xref size as unknown, and expand the xref dynamically as we read it.
-        m_nNumObjects = 0;
-    }
-
-    // allow caller to specify a max object count to avoid very slow load times on large documents
-    if (s_nMaxObjects != std::numeric_limits<long>::max()
-        && m_nNumObjects > s_nMaxObjects)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange,  "m_nNumObjects is greater than m_nMaxObjects." );
-
-    if (m_nNumObjects > 0)
-        m_offsets.resize(m_nNumObjects);
-
-    if( m_pLinearization )
-    {
-        try {
-            ReadXRefContents( m_nXRefLinearizedOffset );
-        } catch( PdfError & e ) {
-            e.AddToCallstack( __FILE__, __LINE__, "Unable to read linearized XRef section." );
-            throw e;
-        }
-    }
-
-    try {
-        ReadXRefContents( m_nXRefOffset );
-    } catch( PdfError & e ) {
-        e.AddToCallstack( __FILE__, __LINE__, "Unable to load xref entries." );
-        throw e;
-    }
-
-}
-
-bool PdfParser::IsPdfFile()
-{
-    const char* szPdfMagicStart = "%PDF-";
-    int i;
-
-    if( m_device.Device()->Read( m_buffer.GetBuffer(), PDF_MAGIC_LEN ) != PDF_MAGIC_LEN )
-        return false;
-
-    if( strncmp( m_buffer.GetBuffer(), szPdfMagicStart, strlen( szPdfMagicStart ) ) != 0 )
-        return false;
-        
-    // try to determine the excact PDF version of the file
-    for( i=0;i<=MAX_PDF_VERSION_STRING_INDEX;i++ )
-    {
-        if( strncmp( m_buffer.GetBuffer(), s_szPdfVersions[i], PDF_MAGIC_LEN ) == 0 )
-        {
-            m_ePdfVersion = static_cast<EPdfVersion>(i);
-            break;
-        }
-    }
-
-    return true;
-}
-
-void PdfParser::HasLinearizationDict()
-{
-    if (m_pLinearization)
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic,
-                "HasLinarizationDict() called twice on one object");
-    }
-
-    m_device.Device()->Seek( 0 );
-
-    // The linearization dictionary must be in the first 1024 
-    // bytes of the PDF, our buffer might be larger so.
-    // Therefore read only the first 1024 byte.
-    // Normally we should jump to the end of the file, to determine
-    // it's filesize and read the min(1024, filesize) to not fail
-    // on smaller files, but jumping to the end is against the idea
-    // of linearized PDF. Therefore just check if we read anything.
-    const std::streamoff MAX_READ = 1024;
-    PdfRefCountedBuffer linearizeBuffer( MAX_READ );
-
-    std::streamoff size = m_device.Device()->Read( linearizeBuffer.GetBuffer(), 
-                                                   linearizeBuffer.GetSize() );
-    // Only fail if we read nothing, to allow files smaller than MAX_READ
-    if( static_cast<size_t>(size) <= 0 )
-    {
-        // Clear the error state from the bad read
-        m_device.Device()->Clear();
-        return; // Ignore Error Code: ERROR_PDF_NO_TRAILER;
-    }
-
-    char * pszObj = strstr( m_buffer.GetBuffer(), "obj" );
-    if( !pszObj )
-        // strange that there is no obj in the first 1024 bytes,
-        // but ignore it
-        return;
-    
-    --pszObj; // *pszObj == 'o', so the while would fail without decrement
-    while( *pszObj && (PdfTokenizer::IsWhitespace( *pszObj ) || (*pszObj >= '0' && *pszObj <= '9')) )
-        --pszObj;
-
-    m_pLinearization = new PdfParserObject( m_vecObjects, m_device, linearizeBuffer,
-                                            pszObj - linearizeBuffer.GetBuffer() + 2 );
-
-    try {
-        // Do not care for encryption here, as the linearization dictionary does not contain strings or streams
-        // ... hint streams do, but we do not load the hintstream.
-        static_cast<PdfParserObject*>(m_pLinearization)->ParseFile( NULL );
-        if (! (m_pLinearization->IsDictionary() &&
-               m_pLinearization->GetDictionary().HasKey( "Linearized" ) ) )
-        {
-            delete m_pLinearization;
-            m_pLinearization = NULL;
-            return;
-        }
-    } catch( PdfError & e ) {
-        PdfError::LogMessage( eLogSeverity_Warning, e.what() );
-        delete m_pLinearization;
-        m_pLinearization = NULL;
-        return;
-    }
-    
-    long long      lXRef      = -1;
-    lXRef = m_pLinearization->GetDictionary().GetKeyAsLong( "T", lXRef );
-    if( lXRef == -1 )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidLinearization );
-    }
-
-    // avoid moving to a negative file position here
-    m_device.Device()->Seek( (static_cast<pdf_long>(lXRef-PDF_XREF_BUF) > 0 ? static_cast<pdf_long>(lXRef-PDF_XREF_BUF) : PDF_XREF_BUF) );
-    m_nXRefLinearizedOffset = m_device.Device()->Tell();
-
-    if( m_device.Device()->Read( m_buffer.GetBuffer(), PDF_XREF_BUF ) != PDF_XREF_BUF )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidLinearization );
-    }
-
-    m_buffer.GetBuffer()[PDF_XREF_BUF] = '\0';
-
-    // search backwards in the buffer in case the buffer contains null bytes
-    // because it is right after a stream (can't use strstr for this reason)
-    const int XREF_LEN    = 4; // strlen( "xref" );
-    int       i          = 0;
-    char*     pszStart   = NULL;
-    for( i = PDF_XREF_BUF - XREF_LEN; i >= 0; i-- )
-        if( strncmp( m_buffer.GetBuffer()+i, "xref", XREF_LEN ) == 0 )
-        {
-            pszStart = m_buffer.GetBuffer()+i;
-            break;
-        }
-
-    m_nXRefLinearizedOffset += i;
-    
-    if( !pszStart )
-    {
-        if( m_ePdfVersion < ePdfVersion_1_5 )
-        {
-            PdfError::LogMessage( eLogSeverity_Warning, 
-                                  "Linearization dictionaries are only supported with PDF version 1.5. This is 1.%i. Trying to continue.\n", 
-                                  static_cast<int>(m_ePdfVersion) );
-            // PODOFO_RAISE_ERROR( ePdfError_InvalidLinearization );
-        }
-
-        {
-            m_nXRefLinearizedOffset = static_cast<pdf_long>(lXRef);
-            /*
-            eCode = ReadXRefStreamContents();
-            i     = 0;
-            */
-        }
-    }
-}
-
-void PdfParser::MergeTrailer( const PdfObject* pTrailer )
-{
-    PdfVariant  cVar;
-
-    if( !pTrailer || !m_pTrailer )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // Only update keys, if not already present                   
-    if( pTrailer->GetDictionary().HasKey( PdfName::KeySize )      
-        && !m_pTrailer->GetDictionary().HasKey( PdfName::KeySize ) )
-        m_pTrailer->GetDictionary().AddKey( PdfName::KeySize, *(pTrailer->GetDictionary().GetKey( PdfName::KeySize )) );
-                                                                                                                         
-    if( pTrailer->GetDictionary().HasKey( "Root" )                                                                      
-        && !m_pTrailer->GetDictionary().HasKey( "Root" ))                                                               
-        m_pTrailer->GetDictionary().AddKey( "Root", *(pTrailer->GetDictionary().GetKey( "Root" )) );                    
-                                                                                                                         
-    if( pTrailer->GetDictionary().HasKey( "Encrypt" )                                                                   
-        && !m_pTrailer->GetDictionary().HasKey( "Encrypt" ) )                                                                                                                                            
-        m_pTrailer->GetDictionary().AddKey( "Encrypt", *(pTrailer->GetDictionary().GetKey( "Encrypt" )) );                                                                                               
-                                                                                                                                                                                                          
-    if( pTrailer->GetDictionary().HasKey( "Info" )                                                                                                                                                       
-        && !m_pTrailer->GetDictionary().HasKey( "Info" ) )                                                                                                                                               
-        m_pTrailer->GetDictionary().AddKey( "Info", *(pTrailer->GetDictionary().GetKey( "Info" )) );                                                                                                     
-                                                                                                                                                                                                          
-    if( pTrailer->GetDictionary().HasKey( "ID" )                                                                                                                                                         
-        && !m_pTrailer->GetDictionary().HasKey( "ID" ) )                                                                                                                                                 
-        m_pTrailer->GetDictionary().AddKey( "ID", *(pTrailer->GetDictionary().GetKey( "ID" )) );        
-}
-
-void PdfParser::ReadNextTrailer()
-{
-    // be careful changing this limit - overflow limits depend on the OS, linker settings, and how much stack space compiler allocates
-    // 500 limit prevents overflow on Win7 with VC++ 2005 with default linker stack size (1000 caused overflow with same compiler/OS)
-    const int maxReadNextTrailerLevel = 500;
-    
-    ++m_nReadNextTrailerLevel;
-    
-    if ( m_nReadNextTrailerLevel > maxReadNextTrailerLevel )
-    {
-        // avoid stack overflow on documents that have circular cross references in trailer
-        PODOFO_RAISE_ERROR( ePdfError_InvalidXRef );
-    }
-
-    // ReadXRefcontents has read the first 't' from "trailer" so just check for "railer"
-    if( this->IsNextToken( "trailer" ) )
-    //if( strcmp( m_buffer.GetBuffer(), "railer" ) == 0 )
-    {
-        PdfParserObject trailer( m_vecObjects, m_device, m_buffer );
-        try {
-            // Ignore the encryption in the trailer as the trailer may not be encrypted
-            trailer.ParseFile( NULL, true );
-        } catch( PdfError & e ) {
-            e.AddToCallstack( __FILE__, __LINE__, "The linearized trailer was found in the file, but contains errors." );
-            throw e;
-        }
-
-        // now merge the information of this trailer with the main documents trailer
-        MergeTrailer( &trailer );
-        
-        if( trailer.GetDictionary().HasKey( "Prev" ) )
-        {
-            // Whenever we read a Prev key, 
-            // we know that the file was updated.
-            m_nIncrementalUpdates++;
-
-            try {
-                ReadXRefContents( static_cast<pdf_long>(trailer.GetDictionary().GetKeyAsLong( "Prev", 0 )) );
-            } catch( PdfError & e ) {
-                e.AddToCallstack( __FILE__, __LINE__, "Unable to load /Prev xref entries." );
-                throw e;
-            }
-        }
-    }
-    else // OC 13.08.2010 BugFix: else belongs to IsNextToken( "trailer" ) and not to HasKey( "Prev" )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoTrailer );
-    }
-
-    --m_nReadNextTrailerLevel;
-}
-
-void PdfParser::ReadTrailer()
-{
-    FindToken( "trailer", PDF_XREF_BUF );
-    
-    if( !this->IsNextToken( "trailer" ) ) 
-    {
-//      if( m_ePdfVersion < ePdfVersion_1_5 )
-//		Ulrich Arnold 19.10.2009, found linearized 1.3-pdf's with trailer-info in xref-stream
-        if( m_ePdfVersion < ePdfVersion_1_3 )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_NoTrailer );
-        }
-        else
-        {
-            // Since PDF 1.5 trailer information can also be found
-            // in the crossreference stream object
-            // and a trailer dictionary is not required
-            m_device.Device()->Seek( m_nXRefOffset );
-
-            m_pTrailer = new PdfParserObject( m_vecObjects, m_device, m_buffer );
-            static_cast<PdfParserObject*>(m_pTrailer)->ParseFile( NULL, false );
-            return;
-        }
-    }
-    else 
-    {
-        m_pTrailer = new PdfParserObject( m_vecObjects, m_device, m_buffer );
-        try {
-            // Ignore the encryption in the trailer as the trailer may not be encrypted
-            static_cast<PdfParserObject*>(m_pTrailer)->ParseFile( NULL, true );
-        } catch( PdfError & e ) {
-            e.AddToCallstack( __FILE__, __LINE__, "The trailer was found in the file, but contains errors." );
-            throw e;
-        }
-#ifdef PODOFO_VERBOSE_DEBUG
-        PdfError::DebugMessage("Size=%li\n", m_pTrailer->GetDictionary().GetKeyAsLong( PdfName::KeySize, 0 ) );
-#endif // PODOFO_VERBOSE_DEBUG
-    }
-}
-
-void PdfParser::ReadXRef( pdf_long* pXRefOffset )
-{
-    FindToken( "startxref", PDF_XREF_BUF );
-
-    if( !this->IsNextToken( "startxref" ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-    
-    *pXRefOffset = this->GetNextNumber();
-}
-
-void PdfParser::ReadXRefContents( pdf_long lOffset, bool bPositionAtEnd )
-{
-    long long nFirstObject = 0;
-    long long nNumObjects  = 0;
-
-    size_t curPosition = m_device.Device()->Tell();
-    m_device.Device()->Seek(0,std::ios_base::end);
-    std::streamoff fileSize = m_device.Device()->Tell();
-    m_device.Device()->Seek(curPosition,std::ios_base::beg);
-
-    if (lOffset > fileSize)
-    { 
-        // Invalid "startxref" Peter Petrov 23 December 2008
-        FindToken( "startxref", PDF_XREF_BUF );
-        lOffset = m_device.Device()->Tell();
-        // TODO: hard coded value "4"
-        m_buffer.Resize(PDF_XREF_BUF*4);
-        FindToken2("xref", PDF_XREF_BUF*4,lOffset);
-        m_buffer.Resize(PDF_XREF_BUF);
-        lOffset = m_device.Device()->Tell();
-        m_nXRefOffset = lOffset;
-    }
-    else
-    {
-        m_device.Device()->Seek( lOffset );
-    }
-    
-    if( !this->IsNextToken( "xref" ) )
-    {
-//      if( m_ePdfVersion < ePdfVersion_1_5 )
-//		Ulrich Arnold 19.10.2009, found linearized 1.3-pdf's with trailer-info in xref-stream
-        if( m_ePdfVersion < ePdfVersion_1_3 )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-        }
-        else
-        {
-            ReadXRefStreamContents( lOffset, bPositionAtEnd );
-            return;
-        }
-    }
-
-    // read all xref subsections
-    // OC 13.08.2010: Avoid exception to terminate endless loop
-    for( int nXrefSection = 0; ; ++nXrefSection )
-    {
-        try {
-
-            // OC 13.08.2010: Avoid exception to terminate endless loop
-            if ( nXrefSection > 0 )
-            {
-                // something like PeekNextToken()
-                EPdfTokenType eType;
-                const char* pszRead;
-                bool gotToken = this->GetNextToken( pszRead, &eType );
-                if( gotToken )
-                {
-                    this->QuequeToken( pszRead, eType );
-                    if ( strcmp( "trailer", pszRead ) == 0 )
-                        break;
-                }
-            }
-
-            nFirstObject = this->GetNextNumber();
-            nNumObjects  = this->GetNextNumber();
-
-#ifdef PODOFO_VERBOSE_DEBUG
-            PdfError::DebugMessage("Reading numbers: %lli %lli\n", nFirstObject, nNumObjects );
-#endif // PODOFO_VERBOSE_DEBUG
-
-            if( bPositionAtEnd )
-            {
-#ifdef _WIN32
-				m_device.Device()->Seek( static_cast<std::streamoff>(nNumObjects* PDF_XREF_ENTRY_SIZE), std::ios_base::cur );
-#else
-                m_device.Device()->Seek( nNumObjects* PDF_XREF_ENTRY_SIZE, std::ios_base::cur );
-#endif // _WIN32
-			}
-            else
-            {
-                ReadXRefSubsection( nFirstObject, nNumObjects );
-            }
-        } catch( PdfError & e ) {
-            if( e == ePdfError_NoNumber || e == ePdfError_InvalidXRef || e == ePdfError_UnexpectedEOF ) 
-                break;
-            else 
-            {
-                e.AddToCallstack( __FILE__, __LINE__ );
-                throw e;
-            }
-        }
-    }
-
-    try {
-        ReadNextTrailer();
-    } catch( PdfError & e ) {
-        if( e != ePdfError_NoTrailer ) 
-        {
-            e.AddToCallstack( __FILE__, __LINE__ );
-            throw e;
-        }
-    }
-}
-
-void PdfParser::ReadXRefSubsection( long long & nFirstObject, long long & nNumObjects )
-{
-    pdf_int64 count = 0;
-
-#ifdef PODOFO_VERBOSE_DEBUG
-    PdfError::DebugMessage("Reading XRef Section: %lli with %lli Objects.\n", nFirstObject, nNumObjects );
-#endif // PODOFO_VERBOSE_DEBUG 
-
-    if ( nFirstObject < 0 )
-        PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange, "ReadXRefSubsection: nFirstObject is negative" );
-    if ( nNumObjects < 0 )
-        PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange, "ReadXRefSubsection: nNumObjects is negative" );
-
-    const pdf_int64 maxNum
-      = static_cast<pdf_int64>(PdfParser::s_nMaxObjects);
-
-    // overflow guard, fixes CVE-2017-5853 (signed integer overflow)
-    // also fixes CVE-2017-6844 (buffer overflow) together with below size check
-    if( (maxNum >= nNumObjects) && (nFirstObject <= maxNum - nNumObjects) )
-    {
-        if( nFirstObject + nNumObjects > m_nNumObjects )
-        {
-            // Total number of xref entries to read is greater than the /Size
-            // specified in the trailer if any. That's an error unless we're
-            // trying to recover from a missing /Size entry.
-            PdfError::LogMessage( eLogSeverity_Warning,
-              "There are more objects (%" PDF_FORMAT_INT64 ") in this XRef "
-              "table than specified in the size key of the trailer directory "
-              "(%" PDF_FORMAT_INT64 ")!\n", nFirstObject + nNumObjects,
-              static_cast<pdf_int64>( m_nNumObjects ));
-        }
-
-        if ( static_cast<pdf_uint64>( nFirstObject ) + static_cast<pdf_uint64>( nNumObjects ) > static_cast<pdf_uint64>( std::numeric_limits<size_t>::max() ) )
-            PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange,
-                "xref subsection's given entry numbers together too large" );
-    
-        if( nFirstObject + nNumObjects > m_nNumObjects )
-        {
-            try {
-#ifdef _WIN32
-                m_nNumObjects = static_cast<long>(nFirstObject + nNumObjects);
-                m_offsets.resize(static_cast<long>(nFirstObject+nNumObjects));
-#else
-                m_nNumObjects = nFirstObject + nNumObjects;
-                m_offsets.resize(nFirstObject+nNumObjects);
-#endif // _WIN32
-            } catch (std::exception &) {
-                // If m_nNumObjects*sizeof(TXRefEntry) > std::numeric_limits<size_t>::max() then
-                // resize() throws std::length_error, for smaller allocations that fail it may throw
-                // std::bad_alloc (implementation-dependent). "20.5.5.12 Restrictions on exception 
-                // handling" in the C++ Standard says any function that throws an exception is allowed 
-                // to throw implementation-defined exceptions derived the base type (std::exception)
-                // so we need to catch all std::exceptions here
-                PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-            }
-        }
-    }
-    else
-    {
-        PdfError::LogMessage( eLogSeverity_Error, "There are more objects (%" PDF_FORMAT_INT64
-            " + %" PDF_FORMAT_INT64 " seemingly) in this XRef"
-            " table than supported by standard PDF, or it's inconsistent.\n",
-            nFirstObject, nNumObjects);
-        PODOFO_RAISE_ERROR( ePdfError_InvalidXRef );
-    }
-
-    // consume all whitespaces
-    int charcode;
-    while( this->IsWhitespace((charcode = m_device.Device()->Look())) )
-    {
-        m_device.Device()->GetChar();
-    }
-
-    while( count < nNumObjects && m_device.Device()->Read( m_buffer.GetBuffer(), PDF_XREF_ENTRY_SIZE ) == PDF_XREF_ENTRY_SIZE )
-    {
-        char empty1;
-        char empty2;
-        m_buffer.GetBuffer()[PDF_XREF_ENTRY_SIZE] = '\0';
-
-#ifdef _WIN32
-		const int objID = static_cast<int>(nFirstObject+count);
-#else
-		const int objID = nFirstObject+count;
-#endif // _WIN32
-
-        if( !m_offsets[objID].bParsed )
-        {
-            m_offsets[objID].bParsed = true;
-#ifdef _WIN64
-            sscanf( m_buffer.GetBuffer(), "%10I64d %5ld %c%c%c", 
-                    &(m_offsets[objID].lOffset), 
-                    &(m_offsets[objID].lGeneration), &(m_offsets[objID].cUsed), &empty1, &empty2 );
-#else
-            long long int tmp1;
-            long int tmp2;
-            sscanf( m_buffer.GetBuffer(), "%10lld %5ld %c%c%c", 
-                    &tmp1, &tmp2, &(m_offsets[objID].cUsed), &empty1, &empty2 );
-
-            m_offsets[objID].lOffset = static_cast<pdf_long>(tmp1);
-            m_offsets[objID].lGeneration = tmp2;
-#endif
-       }
-
-        ++count;
-    }
-
-    if( count != nNumObjects )
-    {
-        PdfError::LogMessage( eLogSeverity_Warning, "Count of readobject is %i. Expected %lli.\n", count, nNumObjects );
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-}
-
-void PdfParser::ReadXRefStreamContents( pdf_long lOffset, bool bReadOnlyTrailer )
-{
-    m_device.Device()->Seek( lOffset );
-
-    PdfXRefStreamParserObject xrefObject( m_vecObjects, m_device, m_buffer, &m_offsets );
-    xrefObject.Parse();
-
-    if( !m_pTrailer )
-        m_pTrailer = new PdfParserObject( m_vecObjects, m_device, m_buffer );
-
-    MergeTrailer( &xrefObject );
-
-    if( bReadOnlyTrailer )
-        return;
-
-    xrefObject.ReadXRefTable();
-
-    // Check for a previous XRef stream
-    if(xrefObject.HasPrevious() && xrefObject.GetPreviousOffset() != lOffset) 
-    {
-        try {
-            m_nIncrementalUpdates++;
-            this->ReadXRefStreamContents( xrefObject.GetPreviousOffset(), bReadOnlyTrailer );
-        } catch(PdfError &e) {
-            /* Be forgiving, the error happens when an entry in XRef stream points
-               to a wrong place (offset) in the PDF file. */
-            if( e != ePdfError_NoNumber )
-            {
-                e.AddToCallstack( __FILE__, __LINE__ );
-                throw e;
-            }
-        }
-    }
-}
-
-bool PdfParser::QuickEncryptedCheck( const char* pszFilename ) 
-{
-    bool bEncryptStatus   = false;
-    bool bOldLoadOnDemand = m_bLoadOnDemand;
-    Init();
-    Clear();
-
-   
-    m_bLoadOnDemand   = true; // maybe will be quicker if true?
-
-    if( !pszFilename || !pszFilename[0] )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_device = PdfRefCountedInputDevice( pszFilename, "rb" );
-    if( !m_device.Device() )
-    {
-        //PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-        // If we can not open PDF file
-        // then file does not exist
-        return false;
-    }
-
-    if( !IsPdfFile() )
-    {
-        //PODOFO_RAISE_ERROR( ePdfError_NoPdfFile );
-        return false;
-    }
-
-    ReadDocumentStructure();
-    try {
-
-        m_vecObjects->Reserve( m_nNumObjects );
-
-        // Check for encryption and make sure that the encryption object
-        // is loaded before all other objects
-        const PdfObject * encObj = m_pTrailer->GetDictionary().GetKey( PdfName("Encrypt") );
-        if( encObj && ! encObj->IsNull() ) 
-        {
-            bEncryptStatus = true;
-        }
-    } catch( PdfError & e ) {
-        m_bLoadOnDemand = bOldLoadOnDemand; // Restore load on demand behaviour
-        e.AddToCallstack( __FILE__, __LINE__, "Unable to load objects from file." );
-        throw e;
-    }
-
-    m_bLoadOnDemand = bOldLoadOnDemand; // Restore load on demand behaviour
-
-    return bEncryptStatus;
-}
-
-void PdfParser::ReadObjects()
-{
-    int              i          = 0;
-    PdfParserObject* pObject    = NULL;
-
-    m_vecObjects->Reserve( m_nNumObjects );
-
-    // Check for encryption and make sure that the encryption object
-    // is loaded before all other objects
-    PdfObject* pEncrypt = m_pTrailer->GetDictionary().GetKey( PdfName("Encrypt") );
-    if( pEncrypt && !pEncrypt->IsNull() )
-    {
-#ifdef PODOFO_VERBOSE_DEBUG
-        PdfError::DebugMessage("The PDF file is encrypted.\n" );
-#endif // PODOFO_VERBOSE_DEBUG
-
-        if( pEncrypt->IsReference() ) 
-        {
-            i = pEncrypt->GetReference().ObjectNumber();
-            if( i <= 0 || static_cast<size_t>( i ) >= m_offsets.size () )
-            {
-                std::ostringstream oss;
-                oss << "Encryption dictionary references a nonexistent object " << pEncrypt->GetReference().ObjectNumber() << " " 
-                    << pEncrypt->GetReference().GenerationNumber();
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidEncryptionDict, oss.str().c_str() );
-            }
-
-            pObject = new PdfParserObject( m_vecObjects, m_device, m_buffer, m_offsets[i].lOffset );
-            if( !pObject )
-                PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-
-            pObject->SetLoadOnDemand( false ); // Never load this on demand, as we will use it immediately
-            try {
-                pObject->ParseFile( NULL ); // The encryption dictionary is not encrypted :)
-                // Never add the encryption dictionary to m_vecObjects
-                // we create a new one, if we need it for writing
-                // m_vecObjects->push_back( pObject );
-                m_offsets[i].bParsed = false;
-                m_pEncrypt = PdfEncrypt::CreatePdfEncrypt( pObject );
-                delete pObject;
-            } catch( PdfError & e ) {
-                std::ostringstream oss;
-                oss << "Error while loading object " << pObject->Reference().ObjectNumber() << " " 
-                    << pObject->Reference().GenerationNumber() << std::endl;
-                delete pObject;
-
-                e.AddToCallstack( __FILE__, __LINE__, oss.str().c_str() );
-                throw e;
-
-            }
-        }
-        else if( pEncrypt->IsDictionary() ) 
-        {
-            m_pEncrypt = PdfEncrypt::CreatePdfEncrypt( pEncrypt );
-        }
-        else
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidEncryptionDict, 
-                                     "The encryption entry in the trailer is neither an object nor a reference." ); 
-        }
-
-        // Generate encryption keys
-        // Set user password, try first with an empty password
-        bool bAuthenticate = m_pEncrypt->Authenticate( "", this->GetDocumentId() );
-#ifdef PODOFO_VERBOSE_DEBUG
-        PdfError::DebugMessage("Authentication with empty password: %i.\n", bAuthenticate );
-#endif // PODOFO_VERBOSE_DEBUG
-        if( !bAuthenticate ) 
-        {
-            // authentication failed so we need a password from the user.
-            // The user can set the password using PdfParser::SetPassword
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidPassword, "A password is required to read this PDF file.");
-        }
-
-    }
-
-    ReadObjectsInternal();
-}
-
-void PdfParser::ReadObjectsInternal() 
-{
-    int              i          = 0;
-    int              nLast      = 0;
-    PdfParserObject* pObject    = NULL;
-
-    // Read objects
-    for( i=0; i < m_nNumObjects; i++ )
-    {
-#ifdef PODOFO_VERBOSE_DEBUG
-		std::cerr << "ReadObjectsInteral\t" << i << " "
-			<< (m_offsets[i].bParsed ? "parsed" : "unparsed") << " "
-			<< m_offsets[i].cUsed << " "
-			<< m_offsets[i].lOffset << " "
-			<< m_offsets[i].lGeneration << std::endl;
-#endif
-        if( m_offsets[i].bParsed && m_offsets[i].cUsed == 'n' && m_offsets[i].lOffset > 0 )
-        {
-            //printf("Reading object %i 0 R from %li\n", i, m_offsets[i].lOffset );
-            
-            pObject = new PdfParserObject( m_vecObjects, m_device, m_buffer, m_offsets[i].lOffset );
-            if( !pObject )
-                PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-
-            pObject->SetLoadOnDemand( m_bLoadOnDemand );
-            try {
-                pObject->ParseFile( m_pEncrypt );
-                nLast = pObject->Reference().ObjectNumber();
-
-                /*
-                if( i != pObject->Reference().ObjectNumber() ) 
-                {
-                    printf("Expected %i got %i\n", i, pObject->Reference().ObjectNumber());
-                }
-                if( pObject->Reference().ObjectNumber() != i ) 
-                {
-                    printf("EXPECTED: %i got %i\n", i, pObject->Reference().ObjectNumber() );
-                    abort();
-                }
-                */
-
-                // final pdf should not contain a linerization dictionary as it contents are invalid 
-                // as we change some objects and the final xref table
-                if( m_pLinearization && nLast == static_cast<int>(m_pLinearization->Reference().ObjectNumber()) )
-                {
-                    m_vecObjects->AddFreeObject( pObject->Reference() );
-                    delete pObject;
-                }
-                else
-                    m_vecObjects->push_back( pObject );
-            } catch( PdfError & e ) {
-                std::ostringstream oss;
-                oss << "Error while loading object " << pObject->Reference().ObjectNumber() 
-                    << " " << pObject->Reference().GenerationNumber() 
-                    << " Offset = " << m_offsets[i].lOffset
-                    << " Index = " << i << std::endl;
-                delete pObject;
-
-                if( m_bIgnoreBrokenObjects ) 
-                {
-                    PdfError::LogMessage( eLogSeverity_Error, oss.str().c_str() );
-                    m_vecObjects->AddFreeObject( PdfReference( i, 0 ) );
-                }
-                else
-                {
-                    e.AddToCallstack( __FILE__, __LINE__, oss.str().c_str() );
-                    throw e;
-                }
-            }
-        }
-        else if( m_offsets[i].bParsed && m_offsets[i].cUsed == 'n' && (m_offsets[i].lOffset == 0)  )
-        {
-            // There are broken PDFs which add objects with 'n' 
-            // and 0 offset and 0 generation number
-            // to the xref table instead of using free objects
-            // treating them as free objects
-            if( m_bStrictParsing ) 
-            {
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidXRef,
-                                         "Found object with 0 offset which should be 'f' instead of 'n'." );
-            }
-            else
-            {
-                PdfError::LogMessage( eLogSeverity_Warning, 
-                                      "Treating object %i 0 R as a free object." );
-                m_vecObjects->AddFreeObject( PdfReference( i, 1LL ) );
-            }
-        }
-// Ulrich Arnold 30.7.2009: the linked free list in the xref section is not always correct in pdf's
-//							(especially Illustrator) but Acrobat still accepts them. I've seen XRefs 
-//							where some object-numbers are alltogether missing and multiple XRefs where 
-//							the link list is broken.
-//							Because PdfVecObjects relies on a unbroken range, fill the free list more
-//							robustly from all places which are either free or unparsed
-//      else if( m_offsets[i].bParsed && m_offsets[i].cUsed == 'f' && m_offsets[i].lOffset )
-//      {
-//          m_vecObjects->AddFreeObject( PdfReference( static_cast<int>(m_offsets[i].lOffset), 1LL ) ); // TODO: do not hard code
-//      }
-        else if( (!m_offsets[i].bParsed || m_offsets[i].cUsed == 'f') && i != 0 )
-        {
-			m_vecObjects->AddFreeObject( PdfReference( static_cast<int>(i), 1LL ) ); // TODO: do not hard code generation number
-        }
-    }
-
-    // all normal objects including object streams are available now,
-    // we can parse the object streams safely now.
-    //
-    // Note that even if demand loading is enabled we still currently read all
-    // objects from the stream into memory then free the stream.
-    //
-    for( i = 0; i < m_nNumObjects; i++ )
-    {
-        if( m_offsets[i].bParsed && m_offsets[i].cUsed == 's' ) // we have an object stream
-        {
-#if defined(PODOFO_VERBOSE_DEBUG)
-            if (m_bLoadOnDemand) cerr << "Demand loading on, but can't demand-load from object stream." << endl;
-#endif
-            ReadObjectFromStream( static_cast<int>(m_offsets[i].lGeneration), 
-                                  static_cast<int>(m_offsets[i].lOffset) );
-        }
-    }
-
-    if( !m_bLoadOnDemand )
-    {
-        // Force loading of streams. We can't do this during the initial
-        // run that populates m_vecObjects because a stream might have a /Length
-        // key that references an object we haven't yet read. So we must do it here
-        // in a second pass, or (if demand loading is enabled) defer it for later.
-        for (TCIVecObjects itObjects = m_vecObjects->begin();
-             itObjects != m_vecObjects->end();
-             ++itObjects)
-        {
-            pObject = dynamic_cast<PdfParserObject*>(*itObjects);
-            // only parse streams for objects that have not yet parsed
-            // their streams
-            if( pObject && pObject->HasStreamToParse() && !pObject->HasStream() )
-                pObject->GetStream();
-        }
-    }
-
-
-    // Now sort the list of objects
-    m_vecObjects->Sort();
-
-    UpdateDocumentVersion();
-}
-
-void PdfParser::SetPassword( const std::string & sPassword )
-{
-    if( !m_pEncrypt ) 
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Cannot set password for unencrypted PDF." );
-    } 
-
-    bool bAuthenticate = m_pEncrypt->Authenticate( sPassword, this->GetDocumentId() ); 
-    if( !bAuthenticate ) 
-    {
-#ifdef PODOFO_VERBOSE_DEBUG
-        PdfError::DebugMessage("Authentication with user password failed\n" );
-#endif // PODOFO_VERBOSE_DEBUG
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidPassword, "Authentication with user specified password failed.");
-    }
-    
-    ReadObjectsInternal();
-}
-
-void PdfParser::ReadObjectFromStream( int nObjNo, int )
-{
-    // check if we already have read all objects
-    // from this stream
-    if( m_setObjectStreams.find( nObjNo ) != m_setObjectStreams.end() )
-    {
-        return;
-    }
-    else
-        m_setObjectStreams.insert( nObjNo );
-
-    // generation number of object streams is always 0
-    PdfParserObject* pStream = dynamic_cast<PdfParserObject*>(m_vecObjects->GetObject( PdfReference( nObjNo, 0 ) ) );
-    if( !pStream )
-    {
-        std::ostringstream oss;
-        oss << "Loading of object " << nObjNo << " 0 R failed!" << std::endl;
-
-        PODOFO_RAISE_ERROR_INFO( ePdfError_NoObject, oss.str().c_str() );
-    }
-    
-
-	PdfObjectStreamParserObject::ObjectIdList list;
-    for( int i = 0; i < m_nNumObjects; i++ ) 
-    {
-        if( m_offsets[i].bParsed && m_offsets[i].cUsed == 's' &&
-			m_offsets[i].lGeneration == nObjNo) 
-        {
-            list.push_back(static_cast<long long>(i));
-		}
-	}
-    
-    PdfObjectStreamParserObject pParserObject( pStream, m_vecObjects, m_buffer, m_pEncrypt );
-    pParserObject.Parse( list );
-}
-
-const char* PdfParser::GetPdfVersionString() const
-{
-    return s_szPdfVersions[static_cast<int>(m_ePdfVersion)];
-}
-
-void PdfParser::FindToken( const char* pszToken, const long lRange )
-{
-// James McGill 18.02.2011, offset read position to the EOF marker if it is not the last thing in the file
-    m_device.Device()->Seek( -m_lLastEOFOffset, std::ios_base::end );
-
-    std::streamoff nFileSize = m_device.Device()->Tell();
-    if (nFileSize == -1)
-    {
-        PODOFO_RAISE_ERROR_INFO(
-                ePdfError_NoXRef,
-                "Failed to seek to EOF when looking for xref");
-    }
-
-    pdf_long lXRefBuf  = PDF_MIN( static_cast<pdf_long>(nFileSize), static_cast<pdf_long>(lRange) );
-    size_t   nTokenLen = strlen( pszToken );
-
-    m_device.Device()->Seek( -lXRefBuf, std::ios_base::cur );
-    if( m_device.Device()->Read( m_buffer.GetBuffer(), lXRefBuf ) != lXRefBuf && !m_device.Device()->Eof() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-    m_buffer.GetBuffer()[lXRefBuf] = '\0';
-
-    int i; // Do not make this unsigned, this will cause infinte loops in files without trailer
- 
-    // search backwards in the buffer in case the buffer contains null bytes
-    // because it is right after a stream (can't use strstr for this reason)
-    for( i = lXRefBuf - nTokenLen; i >= 0; i-- )
-    {
-        if( strncmp( m_buffer.GetBuffer()+i, pszToken, nTokenLen ) == 0 )
-        {
-            break;
-        }
-    }
-
-    if( !i )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-    }
-
-// James McGill 18.02.2011, offset read position to the EOF marker if it is not the last thing in the file
-    m_device.Device()->Seek( ((lXRefBuf-i)*-1)-m_lLastEOFOffset, std::ios_base::end );
-}
-
-// Peter Petrov 23 December 2008
-void PdfParser::FindToken2( const char* pszToken, const long lRange, size_t searchEnd )
-{
-    m_device.Device()->Seek( searchEnd, std::ios_base::beg );
-
-    std::streamoff nFileSize = m_device.Device()->Tell();
-    if (nFileSize == -1)
-    {
-        PODOFO_RAISE_ERROR_INFO(
-                ePdfError_NoXRef,
-                "Failed to seek to EOF when looking for xref");
-    }
-
-    pdf_long      lXRefBuf  = PDF_MIN( static_cast<pdf_long>(nFileSize), static_cast<pdf_long>(lRange) );
-    size_t        nTokenLen = strlen( pszToken );
-
-    m_device.Device()->Seek( -lXRefBuf, std::ios_base::cur );
-    if( m_device.Device()->Read( m_buffer.GetBuffer(), lXRefBuf ) != lXRefBuf && !m_device.Device()->Eof() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-    m_buffer.GetBuffer()[lXRefBuf] = '\0';
-
-    // search backwards in the buffer in case the buffer contains null bytes
-    // because it is right after a stream (can't use strstr for this reason)
-    int i; // Do not use an unsigned variable here
-    for( i = lXRefBuf - nTokenLen; i >= 0; i-- )
-        if( strncmp( m_buffer.GetBuffer()+i, pszToken, nTokenLen ) == 0 )
-        {
-            break;
-        }
-
-    if( !i )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-    }
-
-    m_device.Device()->Seek( searchEnd + (lXRefBuf-i)*-1, std::ios_base::beg );
-}
-
-const PdfString & PdfParser::GetDocumentId() 
-{
-    if( !m_pTrailer->GetDictionary().HasKey( PdfName("ID") ) )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidEncryptionDict, "No document ID found in trailer.");
-    }
-
-    return m_pTrailer->GetDictionary().GetKey( PdfName("ID") )->GetArray()[0].GetString();
-}
-
-void PdfParser::UpdateDocumentVersion()
-{
-    if( m_pTrailer->IsDictionary() && m_pTrailer->GetDictionary().HasKey( PdfName("Root") ) )
-    {
-        PdfObject* pCatalog = m_pTrailer->GetDictionary().GetKey( PdfName("Root") );
-        if( pCatalog->IsReference() ) 
-        {
-            pCatalog = m_vecObjects->GetObject( pCatalog->GetReference() );
-        }
-
-        if( pCatalog
-            && pCatalog->IsDictionary() 
-            && pCatalog->GetDictionary().HasKey( PdfName("Version" ) ) ) 
-        {
-            PdfObject* pVersion = pCatalog->GetDictionary().GetKey( PdfName( "Version" ) );
-            for(int i=0;i<=MAX_PDF_VERSION_STRING_INDEX;i++)
-            {
-                if( IsStrictParsing() && !pVersion->IsName())
-                {
-                    // Version must be of type name, according to PDF Specification
-                    PODOFO_RAISE_ERROR( ePdfError_InvalidName );
-                }
-                
-                if( pVersion->IsName() && pVersion->GetName().GetName() == s_szPdfVersionNums[i] )
-                {
-                    PdfError::LogMessage( eLogSeverity_Information,
-                                          "Updating version from %s to %s\n", 
-                                          s_szPdfVersionNums[static_cast<int>(m_ePdfVersion)],
-                                          s_szPdfVersionNums[i] );
-                    m_ePdfVersion = static_cast<EPdfVersion>(i);
-                    break;
-                }
-            }
-        }
-    }
-    
-}
-
-void PdfParser::CheckEOFMarker()
-{
-    // Check for the existence of the EOF marker
-    m_lLastEOFOffset = 0;
-    const char* pszEOFToken = "%%EOF";
-    const size_t nEOFTokenLen = 5;
-    char pszBuff[nEOFTokenLen+1];
-
-    m_device.Device()->Seek(-static_cast<int>(nEOFTokenLen), std::ios_base::end );
-    if( IsStrictParsing() )
-    {
-        // For strict mode EOF marker must be at the very end of the file
-        if( static_cast<size_t>(m_device.Device()->Read( pszBuff, nEOFTokenLen )) != nEOFTokenLen
-            && !m_device.Device()->Eof() )
-            PODOFO_RAISE_ERROR( ePdfError_NoEOFToken );
-
-        if (strncmp( pszBuff, pszEOFToken, nEOFTokenLen) != 0)
-            PODOFO_RAISE_ERROR( ePdfError_NoEOFToken );
-    }
-    else
-    {
-        // Search for the Marker from the end of the file
-        pdf_long lCurrentPos =  m_device.Device()->Tell();
-        bool bFound = false;
-        while (lCurrentPos>=0)
-        {
-            m_device.Device()->Seek( lCurrentPos, std::ios_base::beg );
-            if( static_cast<size_t>(m_device.Device()->Read( pszBuff, nEOFTokenLen )) != nEOFTokenLen 
-                && !m_device.Device()->Eof() )
-            {
-                PODOFO_RAISE_ERROR( ePdfError_NoEOFToken );
-            }
-
-            if (strncmp( pszBuff, pszEOFToken, nEOFTokenLen) == 0)
-            {
-                bFound = true;
-                break;
-            }
-            --lCurrentPos;
-        }
-
-        // Try and deal with garbage by offsetting the buffer reads in PdfParser from now on
-        if (bFound)
-            m_lLastEOFOffset = (m_nFileSize - (m_device.Device()->Tell()-1)) + nEOFTokenLen;
-        else
-            PODOFO_RAISE_ERROR( ePdfError_NoEOFToken );
-    }
-}
-
-};
-
-
-
--- src/base/PdfParser.h.orig	2012-07-15 14:29:30.000000000 +0000
+++ src/base/PdfParser.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,682 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_PARSER_H_
-#define _PDF_PARSER_H_
-
-#include "PdfDefines.h"
-#include "PdfTokenizer.h"
-#include "PdfVecObjects.h"
-
-#define W_ARRAY_SIZE 3
-#define W_MAX_BYTES  4
-
-namespace PoDoFo {
-
-typedef std::map<int,PdfObject*>    TMapObjects;
-typedef TMapObjects::iterator       TIMapObjects;
-typedef TMapObjects::const_iterator TCIMapObjects;
-
-class PdfEncrypt;
-class PdfString;
-
-/**
- * PdfParser reads a PDF file into memory. 
- * The file can be modified in memory and written back using
- * the PdfWriter class.
- * Most PDF features are supported
- */
-class PODOFO_API PdfParser : public PdfTokenizer {
-    friend class PdfDocument;
-    friend class PdfWriter;
-
- public:
-    struct TXRefEntry {
-        inline TXRefEntry() : lOffset(0), lGeneration(0), cUsed('\x00'), bParsed(false) { }
-        pdf_long lOffset;
-        long lGeneration;
-        char cUsed;
-        bool bParsed;
-    };
-
-    typedef std::vector<TXRefEntry>      TVecOffsets;
-    typedef TVecOffsets::iterator        TIVecOffsets;
-    typedef TVecOffsets::const_iterator  TCIVecOffsets;
-
-    /** Create a new PdfParser object
-     *  You have to open a PDF file using ParseFile later.
-     *  \param pVecObjects vector to write the parsed PdfObjects to
-     *
-     *  \see ParseFile  
-     */
-    PdfParser( PdfVecObjects* pVecObjects );
-
-    /** Create a new PdfParser object and open a PDF file and parse
-     *  it into memory.
-     *
-     *  \param pVecObjects vector to write the parsed PdfObjects to
-     *  \param pszFilename filename of the file which is going to be parsed
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  \see SetPassword
-     */
-    PdfParser( PdfVecObjects* pVecObjects, const char* pszFilename, bool bLoadOnDemand = true );
-
-#ifdef _WIN32
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200			// nicht f�r Visualstudio 6
-#else
-    /** Create a new PdfParser object and open a PDF file and parse
-     *  it into memory.
-     *
-     *  \param pVecObjects vector to write the parsed PdfObjects to
-     *  \param pszFilename filename of the file which is going to be parsed
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  This is an overloaded member function to allow working
-     *  with unicode characters. On Unix systes you can also path
-     *  UTF-8 to the const char* overload.
-     *
-     *  \see SetPassword
-     */
-    PdfParser( PdfVecObjects* pVecObjects, const wchar_t* pszFilename, bool bLoadOnDemand = true );
-#endif
-#endif // _WIN32
-
-    /** Create a new PdfParser object and open a PDF file and parse
-     *  it into memory.
-     *
-     *  \param pVecObjects vector to write the parsed PdfObjects to
-     *  \param pBuffer buffer containing a PDF file in memory
-     *  \param lLen length of the buffer containing the PDF file
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  \see SetPassword
-     */
-    PdfParser( PdfVecObjects* pVecObjects, const char* pBuffer, long lLen, bool bLoadOnDemand = true );
-
-    /** Create a new PdfParser object and open a PDF file and parse
-     *  it into memory.
-     *
-     *  \param pVecObjects vector to write the parsed PdfObjects to
-     *  \param rDevice read from this PdfRefCountedInputDevice
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  \see SetPassword
-     */
-    PdfParser( PdfVecObjects* pVecObjects, const PdfRefCountedInputDevice & rDevice, 
-               bool bLoadOnDemand = true );
-
-    /** Delete the PdfParser and all PdfObjects
-     */
-    virtual ~PdfParser();
-
-    /** Open a PDF file and parse it.
-     *
-     *  \param pszFilename filename of the file which is going to be parsed
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  \see SetPassword
-     */
-    void ParseFile( const char* pszFilename, bool bLoadOnDemand = true );
-
-#ifdef _WIN32
-    /** Open a PDF file and parse it.
-     *
-     *  \param pszFilename filename of the file which is going to be parsed
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  This is an overloaded member function to allow working
-     *  with unicode characters. On Unix systes you can also path
-     *  UTF-8 to the const char* overload.
-     *
-     *  \see SetPassword
-     */
-    void ParseFile( const wchar_t* pszFilename, bool bLoadOnDemand = true );
-#endif // _WIN32
-
-    /** Open a PDF file and parse it.
-     *
-     *  \param pBuffer buffer containing a PDF file in memory
-     *  \param lLen length of the buffer containing the PDF file
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  \see SetPassword
-     */
-    void ParseFile( const char* pBuffer, long lLen, bool bLoadOnDemand = true );
-
-    /** Open a PDF file and parse it.
-     *
-     *  \param rDevice the input device to read from
-     *  \param bLoadOnDemand If true all objects will be read from the file at
-     *                       the time they are accesed first.
-     *                       If false all objects will be read immediately.
-     *                       This is faster if you do not need the complete PDF 
-     *                       file in memory.
-     *
-     *
-     *  This might throw a PdfError( ePdfError_InvalidPassword ) exception
-     *  if a password is required to read this PDF.
-     *  Call SetPassword with the correct password in this case.
-     *  
-     *  \see SetPassword
-     */
-    void ParseFile( const PdfRefCountedInputDevice & rDevice, bool bLoadOnDemand = true );
-
-    /** Quick method to detect secured PDF files, i.e.
-     *  a PDF with an /Encrypt key in the trailer directory.
-     *
-     *  \returns true if document is secured, false otherwise
-     */
-    bool QuickEncryptedCheck( const char* pszFilename );
-
-    /**
-     * Retrieve the number of incremental updates that 
-     * have been applied to the last parsed PDF file.
-     *
-     * 0 means no update has been applied.
-     *
-     * \returns the number of incremental updates to the parsed PDF.
-     */
-    inline int GetNumberOfIncrementalUpdates() const;
-
-    /** Get a reference to the sorted internal objects vector.
-     *  \returns the internal objects vector.
-     */
-    inline const PdfVecObjects* GetObjects() const;
-
-    /** Get the file format version of the pdf
-     *  \returns the file format version as enum
-     */
-    inline EPdfVersion GetPdfVersion() const;
-
-    /** Get the file format version of the pdf
-     *  \returns the file format version as string
-     */
-    const char* GetPdfVersionString() const;
-
-    /** Get the trailer dictionary
-     *  which can be written unmodified to a pdf file.
-     */
-    inline const PdfObject* GetTrailer() const;
-
-    /** \returns true if this PdfParser loads all objects on demand at
-     *                the time they are accessed for the first time.
-     *                The default is to load all object immediately.
-     *                In this case false is returned.
-     */
-    inline bool GetLoadOnDemand() const;
-
-    /** \returns whether the parsed document contains linearization tables
-     */
-    bool IsLinearized() const { return m_pLinearization != NULL; }
-
-    /** \returns the length of the file
-     */
-    size_t GetFileSize() const { return m_nFileSize; }
-
-    /** 
-     * \returns true if this PdfWriter creates an encrypted PDF file
-     */
-    bool GetEncrypted() const { return (m_pEncrypt != NULL); }
-
-    /** 
-     * \returns the parsers encryption object or NULL if the read PDF file was not encrypted
-     */
-    const PdfEncrypt* GetEncrypt() const { return m_pEncrypt; }
-
-    /** 
-     * Takes the encryption object fro mthe parser. The internal handle will be set
-     * to NULL and the ownership of the object is given to the caller.
-     *
-     * Only call this if you need access to the encryption object
-     * before deleting the parser.
-     *
-     * \returns the parsers encryption object or NULL if the read PDF file was not encrypted
-     */
-    inline PdfEncrypt* TakeEncrypt();
-    
-
-    /** If you try to open an encrypted PDF file, which requires
-     *  a password to open, PoDoFo will throw a PdfError( ePdfError_InvalidPassword ) 
-     *  exception. 
-     *  
-     *  If you got such an exception, you have to set a password
-     *  which should be used for opening the PDF.
-     *
-     *  The usual way will be to ask the user for the password
-     *  and set the password using this method.
-     *
-     *  PdfParser will immediately continue to read the PDF file.
-     *
-     *  \param sPassword a user or owner password which can be used to open an encrypted PDF file
-     *                   If the password is invalid, a PdfError( ePdfError_InvalidPassword ) exception is thrown!
-     */
-    void SetPassword( const std::string & sPassword );
-
-    /**
-     * \returns true if strict parsing mode is enabled
-     *
-     * \see SetStringParsing
-     */
-    inline bool IsStrictParsing() const;
-
-    /**
-     * Enable/disable strict parsing mode.
-     * Strict parsing is by default disabled.
-     *
-     * If you enable strict parsing, PoDoFo will fail
-     * on a few more common PDF failures. Please not 
-     * that PoDoFo's parser is by default very strict
-     * already and does not recover from e.g. wrong XREF
-     * tables.
-     *
-     * \param bStrict new setting for strict parsing mode.
-     */
-    inline void SetStrictParsing( bool bStrict );
-
-    /**
-     * \return if broken objects are ignored while parsing
-     */
-    inline bool GetIgnoreBrokenObjects();
-
-    /**
-     * Specify if the parser should ignore broken
-     * objects, i.e. XRef entries that do not point
-     * to valid objects.
-     *
-     * Default is to not ignore broken objects and
-     * throw an exception if one is found.
-     *
-     * \param bBroken if true broken objects will be ignored
-     */
-    inline void SetIgnoreBrokenObjects( bool bBroken );
-
-    /**
-     * \return maximum object count to read (default is LONG_MAX
-     * which means no limit)
-     */
-    inline static long GetMaxObjectCount();
-    
-    /**
-     * Specify the maximum number of objects the parser should
-     * read. An exception is thrown if document contains more
-     * objects than this. Use to avoid problems with very large
-     * documents with millions of objects, which use 500MB of
-     * working set and spend 15 mins in Load() before throwing
-     * an out of memory exception.
-     *
-     * \param nMaxObjects set max number of objects
-     */
-    inline static void SetMaxObjectCount( long nMaxObjects );
-    
- protected:
-    /** Searches backwards from the end of the file
-     *  and tries to find a token.
-     *  The current file is positioned right after the token.
-     * 
-     *  \param pszToken a token to find
-     *  \param lRange range in bytes in which to search
-     *                begining at the end of the file
-     */
-    void FindToken( const char* pszToken, const long lRange );
-
-    // Peter Petrov 23 December 2008
-    /** Searches backwards from the specified position of the file
-     *  and tries to find a token.
-     *  The current file is positioned right after the token.
-     * 
-     *  \param pszToken a token to find
-     *  \param lRange range in bytes in which to search
-     *                begining at the specified position of the file
-     *  \param searchEnd specifies position 
-     */
-    void FindToken2( const char* pszToken, const long lRange, size_t searchEnd );
-
-    /** Reads the xref sections and the trailers of the file
-     *  in the correct order in the memory
-     *  and takes care for linearized pdf files.
-     */
-    void ReadDocumentStructure();
-
-    /** Checks wether this pdf is linearized or not.
-     *  Initializes the linearization directory on sucess.
-     */
-    void HasLinearizationDict();
-
-    /** Merge the information of this trailer object
-     *  in the parsers main trailer object.
-     *  \param pTrailer take the keys to merge from this dictionary.
-     */
-    void MergeTrailer( const PdfObject* pTrailer );
-
-    /** Read the trailer directory at the end of the file.
-     */
-    void ReadTrailer();
-
-    /** Looks for a startxref entry at the current file position
-     *  and saves its byteoffset to pXRefOffset.
-     *  \param pXRefOffset store the byte offset of the xref section into this variable.
-     */
-    void ReadXRef( pdf_long* pXRefOffset );
-
-    /** Reads the xref table from a pdf file.
-     *  If there is no xref table, ReadXRefStreamContents() is called.
-     *  \param lOffset read the table from this offset
-     *  \param bPositionAtEnd if true the xref table is not read, but the 
-     *                        file stream is positioned directly 
-     *                        after the table, which allows reading
-     *                        a following trailer dictionary.
-     */
-    void ReadXRefContents( pdf_long lOffset, bool bPositionAtEnd = false );
-
-    /** Read a xref subsection
-     *  
-     *  Throws ePdfError_NoXref if the number of objects read was not
-     *  the number specified by the subsection header (as passed in
-     *  `nNumObjects').
-     *
-     *  \param nFirstObject object number of the first object
-     *  \param nNumObjects  how many objects should be read from this section
-     */
-    void ReadXRefSubsection( long long & nFirstObject, long long & nNumObjects );
-
-    /** Reads a xref stream contens object
-     *  \param lOffset read the stream from this offset
-     *  \param bReadOnlyTrailer only the trailer is skipped over, the contents
-     *         of the xref stream are not parsed
-     */
-    void ReadXRefStreamContents( pdf_long lOffset, bool bReadOnlyTrailer );
-
-    /** Reads all objects from the pdf into memory
-     *  from the offsets listed in m_vecOffsets.
-     *
-     *  If required an encryption object is setup first.
-     *
-     *  The actual reading happens in ReadObjectsInternal()
-     *  either if no encryption is required or a correct
-     *  encryption object was initialized from SetPassword.
-     */
-    void ReadObjects();
-
-    /** Reads all objects from the pdf into memory
-     *  from the offsets listed in m_vecOffsets.
-     *
-     *  Requires a correctly setup PdfEncrypt object
-     *  with correct password.
-     *
-     *  This method is called from ReadObjects
-     *  or SetPassword.
-     *
-     *  \see ReadObjects
-     *  \see SetPassword
-     */
-    void ReadObjectsInternal();
-
-    /** Read the object with index nIndex from the object stream nObjNo
-     *  and push it on the objects vector m_vecOffsets.
-     *
-     *  All objects are read from this stream and the stream object
-     *  is free'd from memory. Further calls who try to read from the
-     *  same stream simply do nothing.
-     *
-     *  \param nObjNo object number of the stream object
-     *  \param nIndex index of the object which should be parsed
-     *
-     */
-    void ReadObjectFromStream( int nObjNo, int nIndex );
-
-    /** Checks the magic number at the start of the pdf file
-     *  and sets the m_ePdfVersion member to the correct version
-     *  of the pdf file.
-     *
-     *  \returns true if this is a pdf file, otherwise false
-     */
-    bool    IsPdfFile();
-
-    void ReadNextTrailer();
-
-
-    /** Checks for the existence of the %%EOF marker at the end of the file
-     *  When strict mode is off it will also attempt to setup the parser to ignore
-     *  any garbage after the last %%EOF marker
-     *  Simply raises an error if there is a problem with the marker
-     *
-     */
-    void CheckEOFMarker();
-
- private:
-    /** Free all internal data structures
-     */
-    void         Clear();
-
-    /** Initializes all private members
-     *  with their initial values.
-     */
-    void         Init();
-
-    /** Small helper method to retrieve the document id from the trailer
-     *
-     *  \returns the document id of this PDF document
-     */
-    const PdfString & GetDocumentId();
-
-    /** Determines the correct version of the PDF
-     *  from the document catalog (if available).
-     *  as, PDF > 1.4 allows updating the version.
-     *
-     *  If no catalog dictionary is present or no /Version
-     *  key is available, the version from the file header will
-     *  be used.
-     */
-    void         UpdateDocumentVersion();
-
- private:
-    EPdfVersion   m_ePdfVersion;
-
-    bool          m_bLoadOnDemand;
-
-    pdf_long      m_nXRefOffset;
-    long          m_nFirstObject;
-    long          m_nNumObjects;
-    pdf_long      m_nXRefLinearizedOffset;
-    size_t        m_nFileSize;
-    pdf_long      m_lLastEOFOffset;
-
-    TVecOffsets   m_offsets;
-    PdfVecObjects* m_vecObjects;
-
-    PdfObject*    m_pTrailer;
-    PdfObject*    m_pLinearization;
-    PdfEncrypt*   m_pEncrypt;
-
-    bool          m_xrefSizeUnknown;
-
-    std::set<int> m_setObjectStreams;
-
-    bool          m_bStrictParsing;
-    bool          m_bIgnoreBrokenObjects;
-
-    int           m_nIncrementalUpdates;
-    int           m_nReadNextTrailerLevel;
-
-    static long   s_nMaxObjects;
-};
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfParser::GetLoadOnDemand() const
-{
-    return m_bLoadOnDemand;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfVersion PdfParser::GetPdfVersion() const
-{
-    return m_ePdfVersion;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-int PdfParser::GetNumberOfIncrementalUpdates() const
-{
-    return m_nIncrementalUpdates;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfVecObjects* PdfParser::GetObjects() const
-{
-    return m_vecObjects;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfObject* PdfParser::GetTrailer() const
-{
-    return m_pTrailer;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-PdfEncrypt* PdfParser::TakeEncrypt() 
-{ 
-    PdfEncrypt* pEncrypt = m_pEncrypt;
-    m_pEncrypt = NULL; 
-    return pEncrypt; 
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfParser::IsStrictParsing() const
-{
-    return m_bStrictParsing;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfParser::SetStrictParsing( bool bStrict )
-{
-    m_bStrictParsing = bStrict;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfParser::GetIgnoreBrokenObjects()
-{
-    return m_bIgnoreBrokenObjects;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfParser::SetIgnoreBrokenObjects( bool bBroken )
-{
-    m_bIgnoreBrokenObjects = bBroken;
-}
-
-// -----------------------------------------------------
-//
-// -----------------------------------------------------
-long PdfParser::GetMaxObjectCount()
-{
-    return PdfParser::s_nMaxObjects;
-}
-
-// -----------------------------------------------------
-//
-// -----------------------------------------------------
-void PdfParser::SetMaxObjectCount( long nMaxObjects )
-{
-    PdfParser::s_nMaxObjects = nMaxObjects;
-}
-
-};
-
-#endif // _PDF_PARSER_H_
-
--- src/base/PdfParserObject.cpp.orig	2011-03-06 18:15:46.000000000 +0000
+++ src/base/PdfParserObject.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,399 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfParserObject.h"
-
-#include "PdfDictionary.h"
-#include "PdfEncrypt.h"
-#include "PdfInputDevice.h"
-#include "PdfInputStream.h"
-#include "PdfParser.h"
-#include "PdfStream.h"
-#include "PdfVariant.h"
-#include "PdfDefinesPrivate.h"
-
-#include <cassert>
-#include <iostream>
-#include <sstream>
-
-namespace PoDoFo {
-
-using namespace std;
-
-static const int s_nLenEndObj    = 6; // strlen("endobj");
-static const int s_nLenStream    = 6; // strlen("stream");
-static const int s_nLenEndStream = 9; // strlen("endstream");
-
-PdfParserObject::PdfParserObject( PdfVecObjects* pCreator, const PdfRefCountedInputDevice & rDevice, 
-                                  const PdfRefCountedBuffer & rBuffer, pdf_long lOffset )
-    : PdfObject( PdfVariant::NullValue ), PdfTokenizer( rDevice, rBuffer ), m_pEncrypt( NULL )
-{
-    m_pOwner = pCreator;
-
-    InitPdfParserObject();
-
-    m_lOffset = lOffset == -1 ? m_device.Device()->Tell() : lOffset;
-}
-
-PdfParserObject::PdfParserObject( const PdfRefCountedBuffer & rBuffer )
-    : PdfObject( PdfVariant::NullValue ), PdfTokenizer( PdfRefCountedInputDevice(), rBuffer ), 
-      m_pEncrypt( NULL )
-{
-    InitPdfParserObject();
-}
-
-PdfParserObject::~PdfParserObject()
-{
-
-}
-
-void PdfParserObject::InitPdfParserObject()
-{
-    m_bIsTrailer        = false;
-
-    // Whether or not demand loading is disabled we still don't load
-    // anything in the ctor. This just controls whether ::ParseFile(...)
-    // forces an immediate demand load, or lets it genuinely happen
-    // on demand.
-    m_bLoadOnDemand     = false;
-
-    // We rely heavily on the demand loading infrastructure whether or not
-    // we *actually* delay loading.
-    EnableDelayedLoading();
-    EnableDelayedStreamLoading();
-
-    m_lOffset           = -1;
-
-    m_bStream           = false;
-    m_lStreamOffset     = 0;
-}
-
-void PdfParserObject::ReadObjectNumber()
-{
-    try {
-        pdf_long obj = this->GetNextNumber();
-        pdf_long gen = this->GetNextNumber();
-
-        m_reference = PdfReference( static_cast<unsigned int>(obj), static_cast<pdf_uint16>(gen) );
-    } catch( PdfError & e ) {
-        e.AddToCallstack( __FILE__, __LINE__, "Object and generation number cannot be read." );
-        throw e;
-    }
-    
-    if( !this->IsNextToken( "obj" ))
-    {
-        std::ostringstream oss;
-        oss << "Error while reading object " << m_reference.ObjectNumber() << " " 
-            << m_reference.GenerationNumber() << ": Next token is not 'obj'." << std::endl; 
-        PODOFO_RAISE_ERROR_INFO( ePdfError_NoObject, oss.str().c_str() );
-    }
-}
-
-void PdfParserObject::ParseFile( PdfEncrypt* pEncrypt, bool bIsTrailer )
-{
-    if( !m_device.Device() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( m_lOffset > -1 )
-        m_device.Device()->Seek( m_lOffset );
-
-    if( !bIsTrailer )
-        ReadObjectNumber();
-
-#if defined(PODOFO_VERBOSE_DEBUG)
-    std::cerr << "Parsing object number: " << m_reference.ObjectNumber()
-              << " " << m_reference.GenerationNumber() << " obj"
-              << " " << m_lOffset << " offset"
-              << " (DL: " << ( m_bLoadOnDemand ? "on" : "off" ) << ")"
-              << endl;
-#endif // PODOFO_VERBOSE_DEBUG
-
-    m_lOffset    = m_device.Device()->Tell();
-    m_pEncrypt   = pEncrypt;
-    m_bIsTrailer = bIsTrailer;
-
-    if( !m_bLoadOnDemand )
-    {
-        // Force immediate loading of the object.  We need to do this through
-        // the deferred loading machinery to avoid getting the object into an
-        // inconsistent state.
-        // We can't do a full DelayedStreamLoad() because the stream might use
-        // an indirect /Length or /Length1 key that hasn't been read yet.
-        DelayedLoad();
-
-        // TODO: support immediate loading of the stream here too. For that, we need
-        // to be able to trigger the reading of not-yet-parsed indirect objects
-        // such as might appear in a /Length key with an indirect reference.
-
-#if defined(PODOFO_EXTRA_CHECKS)
-        // Sanity check - the variant base must be fully loaded now
-        if (!DelayedLoadDone() )
-        {
-            // We don't know what went wrong, but the internal state is
-            // broken or the API rules aren't being followed and we
-            // can't carry on.
-            PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-        }
-#endif // PODOF_EXTRA_CHECKS
-    }
-}
-
-// Only called via the demand loading mechanism
-// Be very careful to avoid recursive demand loads via PdfVariant
-// or PdfObject method calls here.
-void PdfParserObject::ParseFileComplete( bool bIsTrailer )
-{
-#if defined(PODOFO_EXTRA_CHECKS)
-    assert(DelayedLoadInProgress());
-    assert(!DelayedLoadDone());
-#endif
-    const char* pszToken;
-
-    m_device.Device()->Seek( m_lOffset );
-    if( m_pEncrypt )
-        m_pEncrypt->SetCurrentReference( m_reference );
-
-    // Do not call GetNextVariant directly,
-    // but GetNextToken, to handle empty objects like:
-    // 13 0 obj
-    // endobj
-
-    EPdfTokenType eTokenType;
-    bool gotToken = this->GetNextToken( pszToken, &eTokenType );
-    
-    if (!gotToken)
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_UnexpectedEOF, "Expected variant." );
-    }
-
-    // Check if we have an empty object or data
-    if( strncmp( pszToken, "endobj", s_nLenEndObj ) != 0 )
-    {
-        this->GetNextVariant( pszToken, eTokenType, *this, m_pEncrypt );
-        this->SetDirty( false );
-
-        if( !bIsTrailer )
-        {
-            bool gotToken = this->GetNextToken( pszToken );
-            if (!gotToken)
-            {
-                PODOFO_RAISE_ERROR_INFO( ePdfError_UnexpectedEOF, "Expected 'endobj' or (if dict) 'stream', got EOF." );
-            }
-            if( strncmp( pszToken, "endobj", s_nLenEndObj ) == 0 )
-                ; // nothing to do, just validate that the PDF is correct
-            // If it's a dictionary, it might have a stream, so check for that
-            else if( this->IsDictionary() && strncmp( pszToken, "stream", s_nLenStream ) == 0 )
-            {
-                m_bStream = true;
-                m_lStreamOffset = m_device.Device()->Tell(); // NOTE: whitespace after "stream" handle in stream parser!
-                
-                // Most of the code relies on PdfObjects that are dictionaries
-                // to have the datatype ePdfDataType_Dictionary and not Stream.
-                // Please use PdfObject::HasStream to check wether it has a stream.
-                //
-                // Commenting this out is right now easier than fixing all code to check
-                // either for ePdfDataType_Stream or ePdfDataType_Dictionary
-                //
-                //eDataType = ePdfDataType_Stream;	// reset the object type to stream!
-            }
-            else
-            {
-                PODOFO_RAISE_ERROR_INFO( ePdfError_NoObject, pszToken );
-            }
-        }
-    }
-}
-
-
-// Only called during delayed loading. Must be careful to avoid
-// triggering recursive delay loading due to use of accessors of
-// PdfVariant or PdfObject.
-void PdfParserObject::ParseStream()
-{
-#if defined(PODOFO_EXTRA_CHECKS)
-    assert(DelayedLoadDone());
-    assert(DelayedStreamLoadInProgress());
-    assert(!DelayedStreamLoadDone());
-#endif
-
-    long long         lLen  = -1;
-    int          c;
-
-    if( !m_device.Device() || !m_pOwner )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_device.Device()->Seek( m_lStreamOffset );
-
-    // From the PDF Reference manual
-    // The keyword stream that follows
-    // the stream dictionary should be followed by an end-of-line marker consisting of
-    // either a carriage return and a line feed or just a line feed, and not by a carriage re-
-    // turn alone.
-    c = m_device.Device()->Look();
-    if( PdfTokenizer::IsWhitespace( c ) )
-    {
-        c = m_device.Device()->GetChar();
-
-        if( c == '\r' )
-        {
-            c = m_device.Device()->Look();
-            if( c == '\n' )
-            {
-                c = m_device.Device()->GetChar();
-            }
-        }
-    } 
-    
-    pdf_long fLoc = m_device.Device()->Tell();	// we need to save this, since loading the Length key could disturb it!
-
-    PdfObject* pObj = this->GetDictionary_NoDL().GetKey( PdfName::KeyLength );  
-    if( pObj && pObj->IsNumber() )
-    {
-        lLen = pObj->GetNumber();   
-    }
-    else if( pObj && pObj->IsReference() )
-    {
-        pObj = m_pOwner->GetObject( pObj->GetReference() );
-        if( !pObj )
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "/Length key referenced indirect object that could not be loaded" );
-        }
-
-        PdfError::LogMessage(eLogSeverity_Information,
-                             "Reading object %i 0 R with type: %s\n", 
-                             pObj->Reference().ObjectNumber(), pObj->GetDataTypeString());
-
-        if( !pObj->IsNumber() )
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidStreamLength, "/Length key for stream referenced non-number" );
-        }
-
-        lLen = pObj->GetNumber();
-
-        // DS: This code makes no sense, 
-        //     as empty streams with length 0 are valid, too.
-        //if( !lLen )
-        //{
-        //    PODOFO_RAISE_ERROR( ePdfError_InvalidStreamLength );
-        //}
-
-        // we do not use indirect references for the length of the document
-        // DS: Even though do not remove the length key,
-        //     as 2 or more object might use the same object for key lengths.
-        //     Deleting the length object of the first object will make
-        //     all other objects non readable.
-        //     If you want those length object to be removed,
-        //     run the garbage collection of PdfVecObjects over your PDF.
-        //delete m_pOwner->RemoveObject( pObj->Reference() );
-    }
-    else
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidStreamLength );
-    }
-
-    m_device.Device()->Seek( fLoc );	// reset it before reading!
-    PdfDeviceInputStream reader( m_device.Device() );
-    if( m_pEncrypt )
-    {
-        m_pEncrypt->SetCurrentReference( m_reference );
-        PdfInputStream* pInput = m_pEncrypt->CreateEncryptionInputStream( &reader );
-        this->GetStream_NoDL()->SetRawData( pInput, static_cast<pdf_long>(lLen) );
-        delete pInput;
-    }
-    else
-        this->GetStream_NoDL()->SetRawData( &reader, static_cast<pdf_long>(lLen) );
-
-    this->SetDirty( false );
-    /*
-    SAFE_OP( GetNextStringFromFile( ) );
-    if( strncmp( m_buffer.Buffer(), "endstream", s_nLenEndStream ) != 0 )
-        return ERROR_PDF_MISSING_ENDSTREAM;
-    */
-}
-
-
-void PdfParserObject::DelayedLoadImpl()
-{
-#if defined(PODOFO_EXTRA_CHECKS)
-    // DelayedLoadImpl() should only ever be called via DelayedLoad(),
-    // which ensures that it is never called repeatedly.
-    assert(!DelayedLoadDone());
-    assert(DelayedLoadInProgress());
-#endif
-
-    ParseFileComplete( m_bIsTrailer );
-
-    // If we complete without throwing DelayedLoadDone will be set
-    // for us.
-}
-
-void PdfParserObject::DelayedStreamLoadImpl()
-{
-#if defined(PODOFO_EXTRA_CHECKS)
-    // DelayedLoad() must've been called, either directly earlier
-    // or via DelayedStreamLoad. DelayedLoad() will throw if the load
-    // failed, so if we're being called this condition must be true.
-    assert(DelayedLoadDone());
-
-    // Similarly, we should not be being called unless the stream isn't
-    // already loaded.
-    assert(!DelayedStreamLoadDone());
-    assert(DelayedStreamLoadInProgress());
-#endif
-
-    // Note: we can't use HasStream() here because it'll call DelayedStreamLoad()
-    // causing a nasty loop. test m_pStream directly instead.
-    if( this->HasStreamToParse() && !m_pStream )
-    {
-        try {
-            this->ParseStream();
-        } catch( PdfError & e ) {
-            // TODO: track object ptr in error info so we don't have to do this memory-intensive
-            // formatting here.
-            std::ostringstream s;
-            s << "Unable to parse the stream for object " << Reference().ObjectNumber() << ' '
-              << Reference().GenerationNumber() << " obj .";
-            e.AddToCallstack( __FILE__, __LINE__, s.str().c_str());
-            throw e;
-        }
-    }
-
-    // If we complete without throwing the stream will be flagged as loaded.
-}
-
-void PdfParserObject::FreeObjectMemory( bool bForce )
-{
-    if( this->IsLoadOnDemand() && (bForce || !this->IsDirty()) )
-    {
-        PdfVariant::Clear();
-
-        delete m_pStream;
-        m_pStream = NULL;
-
-        EnableDelayedLoading();
-        EnableDelayedStreamLoading();
-    }
-}
-
-};
--- src/base/PdfStream.cpp.orig	2011-04-19 17:34:25.000000000 +0000
+++ src/base/PdfStream.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,241 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfStream.h"
-
-#include "PdfArray.h"
-#include "PdfFilter.h" 
-#include "PdfInputStream.h"
-#include "PdfOutputStream.h"
-#include "PdfOutputDevice.h"
-#include "PdfDefinesPrivate.h"
-
-#include <iostream>
-
-#include <stdlib.h>
-
-using namespace std;
-
-namespace PoDoFo {
-
-PdfStream::PdfStream( PdfObject* pParent )
-    : m_pParent( pParent ), m_bAppend( false )
-{
-}
-
-PdfStream::~PdfStream()
-{
-}
-
-void PdfStream::GetFilteredCopy( PdfOutputStream* pStream ) const
-{
-    TVecFilters      vecFilters    = PdfFilterFactory::CreateFilterList( m_pParent );
-    if( vecFilters.size() )
-    {
-        PdfOutputStream* pDecodeStream = PdfFilterFactory::CreateDecodeStream( vecFilters, pStream, 
-                                                                               m_pParent ? 
-                                                                               &(m_pParent->GetDictionary()) : NULL  );
-        try {
-            pDecodeStream->Write( const_cast<char*>(this->GetInternalBuffer()), this->GetInternalBufferSize() );
-            pDecodeStream->Close();
-        }
-        catch( const PdfError & e ) 
-        {
-            delete pDecodeStream;
-            throw e;
-        }
-        delete pDecodeStream;
-    }
-    else
-    {
-        // Also work on unencoded streams
-        pStream->Write( const_cast<char*>(this->GetInternalBuffer()), this->GetInternalBufferSize() );
-    }
-}
-
-void PdfStream::GetFilteredCopy( char** ppBuffer, pdf_long* lLen ) const
-{
-    TVecFilters            vecFilters    = PdfFilterFactory::CreateFilterList( m_pParent );
-    PdfMemoryOutputStream  stream;
-    if( vecFilters.size() )
-    {
-        // Use std::auto_ptr so that pDecodeStream is deleted 
-        // even in the case of an exception 
-        std::auto_ptr<PdfOutputStream> pDecodeStream( PdfFilterFactory::CreateDecodeStream( vecFilters, &stream, 
-                                                                                            m_pParent ? 
-                                                                                            &(m_pParent->GetDictionary()) : NULL  ) );
-
-        pDecodeStream->Write( this->GetInternalBuffer(), this->GetInternalBufferSize() );
-        pDecodeStream->Close();
-    }
-    else
-    {
-        // Also work on unencoded streams
-        stream.Write( const_cast<char*>(this->GetInternalBuffer()), this->GetInternalBufferSize() );
-        stream.Close();
-    }
-
-    *lLen     = stream.GetLength();
-    *ppBuffer = stream.TakeBuffer();
-}
-
-const PdfStream & PdfStream::operator=( const PdfStream & rhs )
-{
-    PdfMemoryInputStream stream( rhs.GetInternalBuffer(), rhs.GetInternalBufferSize() );
-    this->SetRawData( &stream );
-
-    if( m_pParent ) 
-        m_pParent->GetDictionary().AddKey( PdfName::KeyLength, 
-                                           PdfVariant(static_cast<pdf_int64>(rhs.GetInternalBufferSize())));
-
-    return (*this);
-}
-
-void PdfStream::Set( const char* szBuffer, pdf_long lLen, const TVecFilters & vecFilters )
-{
-    this->BeginAppend( vecFilters );
-    this->Append( szBuffer, lLen );
-    this->EndAppend();
-}
-
-void PdfStream::Set( const char* szBuffer, pdf_long lLen )
-{
-    this->BeginAppend();
-    this->Append( szBuffer, lLen );
-    this->EndAppend();
-}
-
-void PdfStream::Set( PdfInputStream* pStream )
-{
-    TVecFilters vecFilters;
-    vecFilters.push_back( ePdfFilter_FlateDecode );
-
-    this->Set( pStream, vecFilters );
-}
-
-void PdfStream::Set( PdfInputStream* pStream, const TVecFilters & vecFilters )
-{
-    const int BUFFER_SIZE = 4096;
-    pdf_long      lLen        = 0;
-    char      buffer[BUFFER_SIZE];
-
-    this->BeginAppend( vecFilters );
-
-    do {
-        lLen = pStream->Read( buffer, BUFFER_SIZE );
-        this->Append( buffer, lLen );
-    } while( lLen == BUFFER_SIZE );
-
-    this->EndAppend();
-}
-
-void PdfStream::SetRawData( PdfInputStream* pStream, pdf_long lLen )
-{
-    const pdf_long   BUFFER_SIZE = 4096;
-    char             buffer[BUFFER_SIZE];
-    pdf_long         lRead;
-    TVecFilters      vecEmpty;
-
-    // TODO: DS, give begin append a size hint so that it knows
-    //       how many data has to be allocated
-    this->BeginAppend( vecEmpty, true, false );
-    if( lLen == -1 ) 
-    {
-        do {
-            lRead = pStream->Read( buffer, BUFFER_SIZE );
-            this->Append( buffer, lRead );
-        } while( lRead > 0 );
-    }
-    else
-    {
-        do {
-            lRead = pStream->Read( buffer, PDF_MIN( BUFFER_SIZE, lLen ) );
-            lLen -= lRead;
-            this->Append( buffer, lRead );
-        } while( lLen && lRead > 0 );
-    }
-
-    this->EndAppend();
-}
-
-void PdfStream::BeginAppend( bool bClearExisting )
-{
-    TVecFilters vecFilters;
-    vecFilters.push_back( ePdfFilter_FlateDecode );
-
-    this->BeginAppend( vecFilters, bClearExisting );
-}
-
-void PdfStream::BeginAppend( const TVecFilters & vecFilters, bool bClearExisting, bool bDeleteFilters )
-{
-    char* pBuffer = NULL;
-    pdf_long lLen = 0; //RG: TODO Should this variable be initialised with 0 (line 225 may fall through without initialisation!)
-
-    PODOFO_RAISE_LOGIC_IF( m_bAppend, "BeginAppend() failed because EndAppend() was not yet called!" );
-
-    if( m_pParent && m_pParent->GetOwner() )
-        m_pParent->GetOwner()->BeginAppendStream( this );
-
-    if( !bClearExisting && this->GetLength() ) 
-        this->GetFilteredCopy( &pBuffer, &lLen );
-
-    if( !vecFilters.size() && bDeleteFilters )
-    {
-        m_pParent->GetDictionary().RemoveKey( PdfName::KeyFilter );
-    }
-    if( vecFilters.size() == 1 )
-    {
-        m_pParent->GetDictionary().AddKey( PdfName::KeyFilter, 
-                                           PdfName( PdfFilterFactory::FilterTypeToName( vecFilters.front() ) ) );
-    }
-    else if( vecFilters.size() > 1 )
-    {
-        PdfArray filters;
-        TCIVecFilters it = vecFilters.begin();
-        while( it != vecFilters.end() )
-        {
-            filters.push_back( PdfName( PdfFilterFactory::FilterTypeToName( *it ) ) );
-            ++it;
-        }
-        
-        m_pParent->GetDictionary().AddKey( PdfName::KeyFilter, filters );
-    }
-
-    this->BeginAppendImpl( vecFilters );
-    m_bAppend = true;
-    if( pBuffer ) 
-    {
-        this->Append( pBuffer, lLen );
-        free( pBuffer );
-    }
-}
-
-void PdfStream::EndAppend()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_bAppend, "EndAppend() failed because BeginAppend() was not yet called!" );
-
-    m_bAppend = false;
-    this->EndAppendImpl();
-
-    if( m_pParent && m_pParent->GetOwner() )
-        m_pParent->GetOwner()->EndAppendStream( this );
-}
-
-};
--- src/base/PdfString.cpp.orig	2012-12-12 22:55:46.000000000 +0000
+++ src/base/PdfString.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1067 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfString.h"
-
-#include "PdfEncrypt.h"
-#include "PdfEncoding.h"
-#include "PdfEncodingFactory.h"
-#include "PdfFilter.h"
-#include "PdfTokenizer.h"
-#include "PdfOutputDevice.h"
-#include "PdfDefinesPrivate.h"
-
-#if defined(_AIX) || defined(__sun)
-#include <alloca.h>
-#elif defined(__APPLE__) || defined(__linux)
-#include <cstdlib>
-#elif defined(_WIN32)
-#include <malloc.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <wchar.h>
-
-namespace PoDoFo {
-
-namespace PdfStringNameSpace {
-
-static char g_StrEscMap[256] = { 0 };
-
-// Generate the escape character map at runtime
-static const char* genStrEscMap()
-{
-    const long lAllocLen = 256;
-    char* map = static_cast<char*>(g_StrEscMap);
-    memset( map, 0, sizeof(char) * lAllocLen );
-    map[static_cast<unsigned char>('\n')] = 'n'; // Line feed (LF)
-    map[static_cast<unsigned char>('\r')] = 'r'; // Carriage return (CR)
-    map[static_cast<unsigned char>('\t')] = 't'; // Horizontal tab (HT)
-    map[static_cast<unsigned char>('\b')] = 'b'; // Backspace (BS)
-    map[static_cast<unsigned char>('\f')] = 'f'; // Form feed (FF)
-    map[static_cast<unsigned char>(')')] = ')';  
-    map[static_cast<unsigned char>('(')] = '(';  
-    map[static_cast<unsigned char>('\\')] = '\\';
-
-    return map;
-}
-
-};
-
-const char * const PdfString::m_escMap        = PdfStringNameSpace::genStrEscMap();
-
-const PdfString PdfString::StringNull        = PdfString();
-#ifdef _MSC_VER
-const char  PdfString::s_pszUnicodeMarker[]  = { 0xFE, 0xFF };
-#else
-const char  PdfString::s_pszUnicodeMarker[]  = { static_cast<char>(0xFE), static_cast<char>(0xFF) };
-#endif
-const char* PdfString::s_pszUnicodeMarkerHex = "FEFF"; 
-
-
-
-PdfString::PdfString()
-    : m_bHex( false ), m_bUnicode( false ), m_pEncoding( NULL )
-{
-}
-
-PdfString::PdfString( const std::string& sString, const PdfEncoding * const pEncoding )
-    : m_bHex( false ), m_bUnicode( false ), m_pEncoding( pEncoding )
-{
-    Init( sString.c_str(), sString.length() );
-}
-
-PdfString::PdfString( const char* pszString, const PdfEncoding * const pEncoding )
-    : m_bHex( false ), m_bUnicode( false ), m_pEncoding( pEncoding )
-{
-    if( pszString )
-        Init( pszString, strlen( pszString ) );
-}
-
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200			// nicht f�r Visualstudio 6
-#else
-PdfString::PdfString( const wchar_t* pszString )
-    : m_bHex( false ), m_bUnicode( true ), m_pEncoding( NULL )
-{
-    if( pszString )
-    {
-        pdf_long lLen = wcslen( pszString );
-        if( sizeof(wchar_t) == 2 ) 
-        {
-            // We have UTF16
-            lLen *= sizeof(wchar_t);
-            m_buffer = PdfRefCountedBuffer( lLen + 2 );
-            memcpy( m_buffer.GetBuffer(), pszString, lLen );
-            m_buffer.GetBuffer()[lLen] = '\0';
-            m_buffer.GetBuffer()[lLen+1] = '\0';
-            
-            // if the buffer is a UTF-16LE string
-            // convert it to UTF-16BE
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-            SwapBytes( m_buffer.GetBuffer(), lLen );
-#endif // PODOFO_IS_LITTLE_ENDIA
-        }
-        else
-        {
-            // Try to convert to UTF8
-            pdf_long   lDest = 5 * lLen; // At max 5 bytes per UTF8 char
-            char*  pDest = static_cast<char*>(malloc( lDest ));
-            size_t cnt   = wcstombs(pDest, pszString, lDest);
-            if( cnt != static_cast<size_t>(-1) )
-            {
-                // No error
-                InitFromUtf8( reinterpret_cast<pdf_utf8*>(pDest), cnt );
-                free( pDest );
-	    }
-            else
-            {
-                free( pDest );
-                PdfError e( ePdfError_InternalLogic, __FILE__, __LINE__ );
-                e.SetErrorInformation( pszString );
-                throw e;
-            }
-        }    
-    }
-}
-#endif
-
-PdfString::PdfString( const char* pszString, pdf_long lLen, bool bHex, const PdfEncoding * const pEncoding )
-    : m_bHex( bHex ), m_bUnicode( false ), m_pEncoding( pEncoding )
-{
-    if( pszString )
-        Init( pszString, lLen );
-}
-
-PdfString::PdfString( const pdf_utf8* pszStringUtf8 )
-    : m_bHex( false ), m_bUnicode( true ), m_pEncoding( NULL )
-{
-    InitFromUtf8( pszStringUtf8, strlen( reinterpret_cast<const char*>(pszStringUtf8) ) );
-
-    m_sUtf8 = reinterpret_cast<const char*>(pszStringUtf8);
-}
-
-PdfString::PdfString( const pdf_utf8* pszStringUtf8, pdf_long lLen )
-    : m_bHex( false ), m_bUnicode( true ), m_pEncoding( NULL )
-{
-    InitFromUtf8( pszStringUtf8, lLen );
-
-    m_sUtf8.assign( reinterpret_cast<const char*>(pszStringUtf8), lLen );
-}
-
-PdfString::PdfString( const pdf_utf16be* pszStringUtf16 )
-    : m_bHex( false ), m_bUnicode( true ), m_pEncoding( NULL )
-{
-    pdf_long               lBufLen = 0;
-    const pdf_utf16be* pszCnt  = pszStringUtf16;
-    
-    while( *pszCnt )
-    {
-        ++pszCnt;
-        ++lBufLen;
-    }
-
-    lBufLen *= sizeof(pdf_utf16be);
-
-    m_buffer = PdfRefCountedBuffer( lBufLen + sizeof(pdf_utf16be) );
-    memcpy( m_buffer.GetBuffer(), reinterpret_cast<const char*>(pszStringUtf16), lBufLen );
-    m_buffer.GetBuffer()[lBufLen] = '\0';
-    m_buffer.GetBuffer()[lBufLen+1] = '\0';
-}
-
-PdfString::PdfString( const pdf_utf16be* pszStringUtf16, pdf_long lLen )
-    : m_bHex( false ), m_bUnicode( true ), m_pEncoding( NULL )
-{
-    pdf_long               lBufLen = 0;
-    const pdf_utf16be* pszCnt  = pszStringUtf16;
-    
-    while( lLen-- )
-    {
-        ++pszCnt;
-        ++lBufLen;
-    }
-
-    lBufLen *= sizeof(pdf_utf16be);
-
-    m_buffer = PdfRefCountedBuffer( lBufLen + sizeof(pdf_utf16be) );
-    memcpy( m_buffer.GetBuffer(), reinterpret_cast<const char*>(pszStringUtf16), lBufLen );
-    m_buffer.GetBuffer()[lBufLen] = '\0';
-    m_buffer.GetBuffer()[lBufLen+1] = '\0';
-}
-
-PdfString::PdfString( const PdfString & rhs )
-    : PdfDataType(), m_bHex( false ), m_bUnicode( false ), m_pEncoding( NULL )
-{
-    this->operator=( rhs );
-}
-
-PdfString::~PdfString()
-{
-}
-
-void PdfString::SetHexData( const char* pszHex, pdf_long lLen, PdfEncrypt* pEncrypt )
-{
-    AssertMutable();
-
-    if( !pszHex ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( lLen == -1 )
-        lLen = strlen( pszHex );
-
-    // Allocate a buffer large enough for the hex decoded data
-    // and the 2 terminating zeros
-    m_buffer = PdfRefCountedBuffer( lLen % 2 ? ((lLen + 1) >> 1) + 2 : (lLen >> 1) + 2 );
-    m_bHex   = true;
-    char* pBuffer = m_buffer.GetBuffer();
-    char val;
-    char cDecodedByte = 0;
-    bool bLow = true;
-
-    while( lLen-- ) 
-    {
-        if( PdfTokenizer::IsWhitespace( *pszHex ) )
-        {
-            ++pszHex;
-            continue;
-        }
-
-        val = PdfTokenizer::GetHexValue( *pszHex );
-        if( bLow ) 
-        {
-            cDecodedByte = (val & 0x0F);
-            bLow         = false;
-        }
-        else
-        {
-            cDecodedByte = ((cDecodedByte << 4) | val);
-            bLow         = true;
-
-            *pBuffer++ = cDecodedByte;
-        }
-
-        ++pszHex;
-    }
-
-    if( !bLow ) 
-    {
-        // an odd number of bytes was read,
-        // so the last byte is 0
-        *pBuffer++ = cDecodedByte;
-    }
-
-    *pBuffer++ = '\0';
-    *pBuffer++ = '\0';
-
-    // If the allocated internal buffer is too big (e.g. because of whitespaces in the data)
-    // copy to a smaller buffer so that PdfString::GetLength() will be correct
-    lLen = pBuffer - m_buffer.GetBuffer();
-    if( static_cast<size_t>(lLen) != m_buffer.GetSize() )
-    {
-        PdfRefCountedBuffer temp( lLen );
-        memcpy( temp.GetBuffer(), m_buffer.GetBuffer(), lLen );
-        m_buffer = temp;
-    }
-
-    if( pEncrypt )
-    {
-        pdf_long outBufferLen = m_buffer.GetSize()-2 - pEncrypt->CalculateStreamOffset();
-        PdfRefCountedBuffer outBuffer(outBufferLen);
-        
-        pEncrypt->Decrypt( reinterpret_cast<unsigned char*>(m_buffer.GetBuffer()),
-                           static_cast<unsigned int>(m_buffer.GetSize()-2),
-                          reinterpret_cast<unsigned char*>(outBuffer.GetBuffer()),
-                          static_cast<unsigned int>(outBuffer.GetSize()));
-        
-        // Replace buffer with decrypted value
-        m_buffer = outBuffer;
-    }
-
-    // Now check for the first two bytes, to see if we got a unicode string
-    if( m_buffer.GetSize()-2 > 2 ) 
-    {
-		m_bUnicode = (m_buffer.GetBuffer()[0] == static_cast<char>(0xFE) && m_buffer.GetBuffer()[1] == static_cast<char>(0xFF));
-		
-		if( m_bUnicode ) 
-        {
-            PdfRefCountedBuffer temp( m_buffer.GetSize() - 2 );
-            memcpy( temp.GetBuffer(), m_buffer.GetBuffer() + 2, m_buffer.GetSize() - 2 );
-            m_buffer = temp;           
-        }
-    }
-}
-
-void PdfString::Write ( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt ) const
-{
-    // Strings in PDF documents may contain \0 especially if they are encrypted
-    // this case has to be handled!
-
-    // Peter Petrov: 17 May 2008
-    // Added check - m_buffer.GetSize()
-    // Now we are not encrypting the empty strings (was access violation)!
-    if( pEncrypt && m_buffer.GetSize())
-    {
-        pdf_long nInputBufferLen = m_buffer.GetSize();
-        pdf_long nUnicodeMarkerOffet = sizeof( PdfString::s_pszUnicodeMarker );
-        if( m_bUnicode )
-            nInputBufferLen += nUnicodeMarkerOffet;
-        
-        char * pInputBuffer = new char[nInputBufferLen];
-        
-        if( m_bUnicode )
-        {
-            memcpy(pInputBuffer, PdfString::s_pszUnicodeMarker, nUnicodeMarkerOffet);
-            memcpy(&pInputBuffer[nUnicodeMarkerOffet], m_buffer.GetBuffer(), m_buffer.GetSize());
-        }
-        else
-            memcpy(pInputBuffer, m_buffer.GetBuffer(), m_buffer.GetSize());
-        
-        pdf_long nOutputBufferLen = pEncrypt->CalculateStreamLength(nInputBufferLen);
-        
-        char* pOutputBuffer = new char [nOutputBufferLen];
-        
-        pEncrypt->Encrypt(reinterpret_cast<const unsigned char*>(pInputBuffer), nInputBufferLen, reinterpret_cast<unsigned char*>(pOutputBuffer), nOutputBufferLen);
-
-        PdfString str( pOutputBuffer, nOutputBufferLen, true );
-        str.Write( pDevice, eWriteMode, NULL );
-
-        delete[] pInputBuffer;
-        delete[] pOutputBuffer;
-		
-        return;
-    }
-
-    pDevice->Print( m_bHex ? "<" : "(" );
-    if( m_buffer.GetSize() )
-    {
-        char* pBuf = m_buffer.GetBuffer();
-        pdf_long  lLen = m_buffer.GetSize() - 2;
-
-        if( m_bHex ) 
-        {
-            if( m_bUnicode )
-                pDevice->Write( PdfString::s_pszUnicodeMarkerHex, 4 );
-
-            char data[2];
-            while( lLen-- )
-            {
-                data[0]  = (*pBuf & 0xF0) >> 4;
-                data[0] += (data[0] > 9 ? 'A' - 10 : '0');
-                
-                data[1]  = (*pBuf & 0x0F);
-                data[1] += (data[1] > 9 ? 'A' - 10 : '0');
-                
-                pDevice->Write( data, 2 );
-                
-                ++pBuf;
-            }
-        }
-        else
-        {
-            if( m_bUnicode ) 
-            {
-                pDevice->Write( PdfString::s_pszUnicodeMarker, sizeof( PdfString::s_pszUnicodeMarker ) );
-            }
-
-            while( lLen-- ) 
-            {
-                const char & cEsc = m_escMap[static_cast<unsigned char>(*pBuf)];
-                if( cEsc != 0 ) 
-                {
-                    pDevice->Write( "\\", 1 );
-                    pDevice->Write( &cEsc, 1 );
-                }
-                else 
-                {
-                    pDevice->Write( &*pBuf, 1 );
-                }
-
-                ++pBuf;
-            }
-        }
-    }
-
-    pDevice->Print( m_bHex ? ">" : ")" );
-}
-
-const PdfString & PdfString::operator=( const PdfString & rhs )
-{
-    this->m_bHex      = rhs.m_bHex;
-    this->m_bUnicode  = rhs.m_bUnicode;
-    this->m_buffer    = rhs.m_buffer;
-    this->m_sUtf8     = rhs.m_sUtf8;
-    this->m_pEncoding = rhs.m_pEncoding;
-
-    return *this;
-}
-
-bool PdfString::operator>( const PdfString & rhs ) const
-{
-    const PdfString & str1 = *this;
-    const PdfString & str2 = rhs;
-
-    if( m_bUnicode || rhs.m_bUnicode )
-    {
-#ifdef _WIN32
-        std::wstring sWide_1 = str1.GetStringW();
-        std::wstring sWide_2 = str2.GetStringW();
-
-        return sWide_1 > sWide_2;
-#else
-        std::string sUtf8_1 = str1.GetStringUtf8();
-        std::string sUtf8_2 = str2.GetStringUtf8();
-
-        return sUtf8_1 > sUtf8_2;
-#endif // _WIN32
-    }
-
-    return (strcmp( str1.GetString(), str2.GetString() ) > 0);
-}
-
-bool PdfString::operator<( const PdfString & rhs ) const
-{
-    const PdfString & str1 = *this;
-    const PdfString & str2 = rhs;
-
-    if( m_bUnicode || rhs.m_bUnicode )
-    {
-#ifdef _WIN32
-        std::wstring sWide_1 = str1.GetStringW();
-        std::wstring sWide_2 = str2.GetStringW();
-
-        return sWide_1 < sWide_2;
-#else
-        std::string sUtf8_1 = str1.GetStringUtf8();
-        std::string sUtf8_2 = str2.GetStringUtf8();
-
-        return sUtf8_1 < sUtf8_2;
-#endif // _WIN32
-    }
-
-    return (strcmp( str1.GetString(), str2.GetString() ) < 0);
-}
-
-bool PdfString::operator==( const PdfString & rhs ) const
-{
-    PdfString str1 = *this;
-    PdfString str2 = rhs;
-
-    if( m_bUnicode || rhs.m_bUnicode )
-    {
-        // one or both strings are unicode:
-        // make sure both are unicode so that 
-        // we do not loose information
-        str1 = str1.ToUnicode();
-        str2 = str2.ToUnicode();
-    }
-
-    return str1.m_buffer == str2.m_buffer;
-}
-
-void PdfString::Init( const char* pszString, pdf_long lLen )
-{
-    if( !pszString )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    bool bUft16LE = false;
-    // check if it is a unicode string (UTF-16BE)
-    // UTF-16BE strings have to start with 0xFE 0xFF
-    if( lLen >= 2 ) 
-    {
-        m_bUnicode = (pszString[0] == PdfString::s_pszUnicodeMarker[0] && 
-                      pszString[1] == PdfString::s_pszUnicodeMarker[1]);
-        
-        // Check also for UTF-16LE
-        if( !m_bUnicode && (pszString[0] == PdfString::s_pszUnicodeMarker[1] && 
-                            pszString[1] == PdfString::s_pszUnicodeMarker[0]) )
-        {
-            bUft16LE = true;
-        }
-    }
-    
-    // skip the first two bytes 
-    if( m_bUnicode )
-    {
-        lLen      -= 2;
-        pszString += 2;
-    }
-
-    
-    m_buffer = PdfRefCountedBuffer( lLen + 2 );
-    memcpy( m_buffer.GetBuffer(), pszString, lLen );
-    m_buffer.GetBuffer()[lLen] = '\0';
-    m_buffer.GetBuffer()[lLen+1] = '\0';
-
-    // if the buffer is a UTF-16LE string
-    // convert it to UTF-16BE
-    if( bUft16LE ) 
-    {
-        SwapBytes( m_buffer.GetBuffer(), lLen );
-    }
-}
-
-void PdfString::InitFromUtf8( const pdf_utf8* pszStringUtf8, pdf_long lLen )
-{
-    if( !pszStringUtf8 )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pdf_long        lBufLen = (lLen << 1) + sizeof(wchar_t);
-    // twice as large buffer should always be enough
-    pdf_utf16be *pBuffer = static_cast<pdf_utf16be *>(alloca(lBufLen)); 
-
-    lBufLen = PdfString::ConvertUTF8toUTF16( pszStringUtf8, lLen, pBuffer, lBufLen );
-
-    lBufLen = (lBufLen-1) << 1; // lBufLen is the number of characters, we need the number of bytes now!
-    m_buffer = PdfRefCountedBuffer( lBufLen + sizeof(pdf_utf16be) );
-    memcpy( m_buffer.GetBuffer(), reinterpret_cast<const char*>(pBuffer), lBufLen );
-    m_buffer.GetBuffer()[lBufLen] = '\0';
-    m_buffer.GetBuffer()[lBufLen+1] = '\0';
-}
-
-void PdfString::InitUtf8()
-{
-    if( this->IsUnicode() )
-    {
-        // we can convert UTF16 to UTF8
-        // UTF8 is at maximum 5 * characterlenght.
-
-        pdf_long  lBufferLen = (5*this->GetUnicodeLength())+2;
-        char* pBuffer    = static_cast<char*>(malloc(sizeof(char)*lBufferLen));
-        if( !pBuffer )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-        }
-
-        pdf_long lUtf8 = PdfString::ConvertUTF16toUTF8( reinterpret_cast<const pdf_utf16be*>(m_buffer.GetBuffer()), 
-                                                    this->GetUnicodeLength(), 
-                                                    reinterpret_cast<pdf_utf8*>(pBuffer), lBufferLen, ePdfStringConversion_Lenient );
-
-        pBuffer[lUtf8-1] = '\0';
-        pBuffer[lUtf8] = '\0';
-        m_sUtf8 = pBuffer;
-        free( pBuffer );
-    }
-    else
-    {
-        PdfString sTmp = this->ToUnicode();
-        m_sUtf8 = sTmp.GetStringUtf8();
-    }
-}
-
-#ifdef _WIN32
-const std::wstring PdfString::GetStringW() const
-{
-    if( !this->IsUnicode() )
-    {
-        return this->ToUnicode().GetStringW();
-    }
-
-    PdfRefCountedBuffer buffer( m_buffer.GetSize() );
-    memcpy( buffer.GetBuffer(), m_buffer.GetBuffer(), m_buffer.GetSize() );
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    SwapBytes( buffer.GetBuffer(), buffer.GetSize() );
-#endif // PODOFO_IS_LITTLE_ENDIA
-
-    std::wstring wstr( reinterpret_cast<const wchar_t*>(buffer.GetBuffer()) );
-
-    return wstr;
-}
-
-#endif // _WIN32
-
-/*
-PdfString PdfString::HexEncode() const
-{
-    if( this->IsHex() )
-        return *this;
-    else
-    {
-        std::auto_ptr<PdfFilter> pFilter;
-
-        pdf_long                  lLen  = (m_buffer.GetSize() - 1) << 1;
-        PdfString             str;
-        PdfRefCountedBuffer   buffer( lLen + 1 );
-        PdfMemoryOutputStream stream( buffer.GetBuffer(), lLen );
-
-        pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
-        pFilter->BeginEncode( &stream );
-        pFilter->EncodeBlock( m_buffer.GetBuffer(), (m_buffer.GetSize() - 1) );
-        pFilter->EndEncode();
-
-        buffer.GetBuffer()[buffer.GetSize()-1] = '\0';
-
-        str.m_buffer   = buffer;
-        str.m_bHex     = true;
-        str.m_bUnicode = m_bUnicode;
-
-        return str;
-    }
-} 
-
-// TODO: REMOVE
-PdfString PdfString::HexDecode() const
-{
-    if( !this->IsHex() )
-        return *this;
-    else
-    {
-        std::auto_ptr<PdfFilter> pFilter;
-
-        pdf_long                  lLen = m_buffer.GetSize() >> 1;
-        PdfString             str;
-        PdfRefCountedBuffer   buffer( lLen );
-        PdfMemoryOutputStream stream( buffer.GetBuffer(), lLen );
-
-        pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
-        pFilter->BeginDecode( &stream );
-        pFilter->DecodeBlock( m_buffer.GetBuffer(), m_buffer.GetSize() );
-        pFilter->EndDecode();
-
-        str.m_buffer   = buffer;
-        str.m_bHex     = false;
-        str.m_bUnicode = m_bUnicode;
-
-        return str;
-    }
-} 
-*/
-
-PdfString PdfString::ToUnicode() const
-{
-    if( this->IsUnicode() )
-        return *this;
-    else
-    {
-        const PdfEncoding* const pEncoding = (m_pEncoding ? 
-                                              m_pEncoding : 
-                                              PdfEncodingFactory::GlobalPdfDocEncodingInstance());
-        return pEncoding->ConvertToUnicode( *this, NULL );
-    }
-}
-
-void PdfString::SwapBytes( char* pBuf, pdf_long lLen ) 
-{
-    char  cSwap;
-    while( lLen > 1 )
-    {
-        cSwap     = *pBuf;
-        *pBuf     = *(pBuf+1);
-        *(++pBuf) = cSwap;
-        
-        ++pBuf;
-        lLen -= 2;
-    }
-}
-/*
- * The disclaimer below applies to the Unicode conversion
- * functions below. The functions where adapted for use in PoDoFo.
- *
- * The original can be found at:
- * http://www.unicode.org/Public/PROGRAMS/CVTUTF/
- */
-
-/*
- * Copyright 2001-2004 Unicode, Inc.
- * 
- * Disclaimer
- * 
- * This source code is provided as is by Unicode, Inc. No claims are
- * made as to fitness for any particular purpose. No warranties of any
- * kind are expressed or implied. The recipient agrees to determine
- * applicability of information provided. If this file has been
- * purchased on magnetic or optical media from Unicode, Inc., the
- * sole remedy for any claim will be exchange of defective media
- * within 90 days of receipt.
- * 
- * Limitations on Rights to Redistribute This Code
- * 
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form
- * for internal or external distribution as long as this notice
- * remains attached.
- */
-
-/* ---------------------------------------------------------------------
-
-    Conversions between UTF32, UTF-16, and UTF-8. Source code file.
-    Author: Mark E. Davis, 1994.
-    Rev History: Rick McGowan, fixes & updates May 2001.
-    Sept 2001: fixed const & error conditions per
-	mods suggested by S. Parent & A. Lillich.
-    June 2002: Tim Dodd added detection and handling of incomplete
-	source sequences, enhanced error detection, added casts
-	to eliminate compiler warnings.
-    July 2003: slight mods to back out aggressive FFFE detection.
-    Jan 2004: updated switches in from-UTF8 conversions.
-    Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
-
-    See the header file "ConvertUTF.h" for complete documentation.
-
------------------------------------------------------------------------- */
-
-/* --------------------------------------------------------------------- */
-/* Some fundamental constants */
-#define UNI_REPLACEMENT_CHAR static_cast<unsigned long>(0x0000FFFD)
-#define UNI_MAX_BMP          static_cast<unsigned long>(0x0000FFFF)
-#define UNI_MAX_UTF16        static_cast<unsigned long>(0x0010FFFF)
-
-#define UNI_SUR_HIGH_START   static_cast<unsigned long>(0xD800)
-#define UNI_SUR_HIGH_END     static_cast<unsigned long>(0xDBFF)
-#define UNI_SUR_LOW_START    static_cast<unsigned long>(0xDC00)
-#define UNI_SUR_LOW_END      static_cast<unsigned long>(0xDFFF)
-
-static const int halfShift  = 10; /* used for shifting by 10 bits */
-
-static const unsigned long halfBase = 0x0010000UL;
-static const unsigned long halfMask = 0x3FFUL;
-
-/* --------------------------------------------------------------------- */
-/*
- * Index into the table below with the first byte of a UTF-8 sequence to
- * get the number of trailing bytes that are supposed to follow it.
- * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
- * left as-is for anyone who may want to do such conversion, which was
- * allowed in earlier algorithms.
- */
-static const char trailingBytesForUTF8[256] = {
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
-    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
-};
-
-/*
- * Magic values subtracted from a buffer value during UTF8 conversion.
- * This table contains as many values as there might be trailing bytes
- * in a UTF-8 sequence.
- */
-static const unsigned long offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 
-                                                  0x03C82080UL, 0xFA082080UL, 0x82082080UL };
-
-/*
- * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
- * into the first byte, depending on how many bytes follow.  There are
- * as many entries in this table as there are UTF-8 sequence types.
- * (I.e., one byte sequence, two byte... etc.). Remember that sequencs
- * for *legal* UTF-8 will be 4 or fewer bytes total.
- */
-static const pdf_utf8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Utility routine to tell whether a sequence of bytes is legal UTF-8.
- * This must be called with the length pre-determined by the first byte.
- * If not calling this from ConvertUTF8to*, then the length can be set by:
- *  length = trailingBytesForUTF8[*source]+1;
- * and the sequence is illegal right away if there aren't that many bytes
- * available.
- * If presented with a length > 4, this returns false.  The Unicode
- * definition of UTF-8 goes up to 4-byte sequences.
- */
-
-static bool isLegalUTF8(const pdf_utf8 *source, int length) {
-    pdf_utf8 a;
-    const pdf_utf8 *srcptr = source+length;
-    switch (length) {
-    default: return false;
-	/* Everything else falls through when "true"... */
-    case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
-    case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
-    case 2: if ((a = (*--srcptr)) > 0xBF) return false;
-
-	switch (*source) {
-	    /* no fall-through in this inner switch */
-	    case 0xE0: if (a < 0xA0) return false; break;
-	    case 0xED: if (a > 0x9F) return false; break;
-	    case 0xF0: if (a < 0x90) return false; break;
-	    case 0xF4: if (a > 0x8F) return false; break;
-	    default:   if (a < 0x80) return false;
-	}
-
-    case 1: if (*source >= 0x80 && *source < 0xC2) return false;
-    }
-    if (*source > 0xF4) return false;
-    return true;
-}
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Exported function to return whether a UTF-8 sequence is legal or not.
- * This is not used here; it's just exported.
- */
-bool isLegalUTF8Sequence(const pdf_utf8 *source, const pdf_utf8 *sourceEnd) {
-    int length = trailingBytesForUTF8[*source]+1;
-    if (source+length > sourceEnd) {
-	return false;
-    }
-    return isLegalUTF8(source, length);
-}
-
-
-pdf_long PdfString::ConvertUTF8toUTF16( const pdf_utf8* pszUtf8, pdf_utf16be* pszUtf16, pdf_long lLenUtf16 )
-{
-    return pszUtf8 ? 
-        PdfString::ConvertUTF8toUTF16( pszUtf8, strlen( reinterpret_cast<const char*>(pszUtf8) ), pszUtf16, lLenUtf16 ) : 0;
-}
-
-pdf_long PdfString::ConvertUTF8toUTF16( const pdf_utf8* pszUtf8, pdf_long lLenUtf8, 
-                                    pdf_utf16be* pszUtf16, pdf_long lLenUtf16,
-                                    EPdfStringConversion eConversion )
-{
-    const pdf_utf8* source    = pszUtf8;
-    const pdf_utf8* sourceEnd = pszUtf8 + lLenUtf8 + 1; // point after the last element
-    pdf_utf16be*    target    = pszUtf16;
-    pdf_utf16be*    targetEnd = pszUtf16 + lLenUtf16;
-
-    while (source < sourceEnd) 
-    {
-	unsigned long ch = 0;
-	unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
-	if (source + extraBytesToRead >= sourceEnd) {
-	    PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "The UTF8 string was to short while converting from UTF8 to UTF16." );
-	}
-
-	// Do this check whether lenient or strict
-	if (! isLegalUTF8(source, extraBytesToRead+1)) {
-	    PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "The UTF8 string was invalid while from UTF8 to UTF16." );
-	}
-
-	/*
-	 * The cases all fall through. See "Note A" below.
-	 */
-	switch (extraBytesToRead) {
-	    case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
-	    case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
-	    case 3: ch += *source++; ch <<= 6;
-	    case 2: ch += *source++; ch <<= 6;
-	    case 1: ch += *source++; ch <<= 6;
-	    case 0: ch += *source++;
-	}
-	ch -= offsetsFromUTF8[extraBytesToRead];
-
-	if (target >= targetEnd) {
-	    source -= (extraBytesToRead+1); /* Back up source pointer! */
-	    PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-	}
-
-	if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
-	    /* UTF-16 surrogate values are illegal in UTF-32 */
-	    if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
-		if (eConversion == ePdfStringConversion_Strict) {
-		    source -= (extraBytesToRead+1); /* return to the illegal value itself */
-                    PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-		    break;
-		} else {
-		    *target++ = UNI_REPLACEMENT_CHAR;
-		}
-	    } else {
-		*target++ = static_cast<pdf_utf16be>(ch); /* normal case */
-	    }
-	} else if (ch > UNI_MAX_UTF16) {
-	    if (eConversion == ePdfStringConversion_Strict) {
-                PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-
-        //RG: TODO My compiler says that this is unreachable code!
-
-		source -= (extraBytesToRead+1); /* return to the start */
-		break; /* Bail out; shouldn't continue */
-	    } else {
-		*target++ = UNI_REPLACEMENT_CHAR;
-	    }
-	} else {
-	    /* target is a character in range 0xFFFF - 0x10FFFF. */
-	    if (target + 1 >= targetEnd) {
-		source -= (extraBytesToRead+1); /* Back up source pointer! */
-                PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-	    }
-            
-	    ch -= halfBase;
-	    *target++ = static_cast<pdf_utf16be>((ch >> halfShift) + UNI_SUR_HIGH_START);
-	    *target++ = static_cast<pdf_utf16be>((ch & halfMask) + UNI_SUR_LOW_START);
-	}
-    }
-
-    // swap to UTF-16be on LE systems
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    PdfString::SwapBytes( reinterpret_cast<char*>(pszUtf16), static_cast<pdf_long>(target - pszUtf16) << 1 );
-#endif // PODOFO_IS_LITTLE_ENDIAN
-
-    // return characters written
-    return target - pszUtf16;
-}
-
-pdf_long PdfString::ConvertUTF16toUTF8( const pdf_utf16be* pszUtf16, pdf_utf8* pszUtf8, pdf_long lLenUtf8 )
-{
-    pdf_long               lLen      = 0;
-    const pdf_utf16be* pszStart = pszUtf16;
-
-    while( *pszStart )
-        ++lLen;
-
-    return ConvertUTF16toUTF8( pszUtf16, lLen, pszUtf8, lLenUtf8 );
-}
-
-pdf_long PdfString::ConvertUTF16toUTF8( const pdf_utf16be* pszUtf16, pdf_long lLenUtf16, 
-                                    pdf_utf8* pszUtf8, pdf_long lLenUtf8, 
-                                    EPdfStringConversion eConversion  )
-{
-    bool               bOwnBuf   = false;
-    const pdf_utf16be* source    = pszUtf16;
-    const pdf_utf16be* sourceEnd = pszUtf16 + lLenUtf16 + 1; // point after the last element
-    
-    pdf_utf8* target    = pszUtf8;
-    pdf_utf8* targetEnd = pszUtf8 + lLenUtf8;
-
-    // swap to UTF-16be on LE systems
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    bOwnBuf = true;
-    source  = new pdf_utf16be[lLenUtf16+1];
-    if( !source )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-    
-    memcpy( const_cast<pdf_utf16be*>(source), pszUtf16, lLenUtf16 * sizeof(pdf_utf16be) );
-    
-    PdfString::SwapBytes( reinterpret_cast<char*>(const_cast<pdf_utf16be*>(source)), lLenUtf16 * sizeof(pdf_utf16be) );
-    pszUtf16  = source;
-    const_cast<pdf_utf16be*>(source)[lLenUtf16] = 0;
-    sourceEnd = pszUtf16 + lLenUtf16 + 1; // point after the last element
-#endif // PODOFO_IS_LITTLE_ENDIAN
-
-    try {
-        while (source < sourceEnd) {
-            unsigned long  ch;
-            unsigned short bytesToWrite = 0;
-            const unsigned long byteMask = 0xBF;
-            const unsigned long byteMark = 0x80; 
-            const pdf_utf16be* oldSource = source; /* In case we have to back up because of target overflow. */
-            ch = *source++;
-
-            /* If we have a surrogate pair, convert to UTF32 first. */
-            if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
-                /* If the 16 bits following the high surrogate are in the source buffer... */
-                if (source < sourceEnd) {
-                    unsigned long ch2 = *source;
-                    /* If it's a low surrogate, convert to UTF32. */
-                    if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
-                        ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
-                            + (ch2 - UNI_SUR_LOW_START) + halfBase;
-                        ++source;
-                    } else if (eConversion == ePdfStringConversion_Strict) { /* it's an unpaired high surrogate */
-                        --source; /* return to the illegal value itself */
-                        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-                        break;
-                    }
-                } else { /* We don't have the 16 bits following the high surrogate. */
-                    --source; /* return to the high surrogate */
-                    PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-                    break;
-                }
-            } else if (eConversion == ePdfStringConversion_Strict) {
-                /* UTF-16 surrogate values are illegal in UTF-32 */
-                if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
-                    --source; /* return to the illegal value itself */
-                    PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-                    break;
-                }
-            }
-            /* Figure out how many bytes the result will require */
-            if (ch < static_cast<unsigned long>(0x80)) {	     
-                bytesToWrite = 1;
-            } else if (ch < static_cast<unsigned long>(0x800)) {     
-                bytesToWrite = 2;
-            } else if (ch < static_cast<unsigned long>(0x10000)) {   
-                bytesToWrite = 3;
-            } else if (ch < static_cast<unsigned long>(0x110000)) {  
-                bytesToWrite = 4;
-            } else {			    
-                bytesToWrite = 3;
-                ch = UNI_REPLACEMENT_CHAR;
-            }
-
-            target += bytesToWrite;
-            if (target > targetEnd) {
-                source = oldSource; /* Back up source pointer! */
-                target -= bytesToWrite; 
-                PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-                break;
-            }
-        
-            switch (bytesToWrite) { /* note: everything falls through. */
-                case 4: *--target = static_cast<pdf_utf8>((ch | byteMark) & byteMask); ch >>= 6;
-                case 3: *--target = static_cast<pdf_utf8>((ch | byteMark) & byteMask); ch >>= 6;
-                case 2: *--target = static_cast<pdf_utf8>((ch | byteMark) & byteMask); ch >>= 6;
-                case 1: *--target = static_cast<pdf_utf8>(ch | firstByteMark[bytesToWrite]);
-            }
-            target += bytesToWrite;
-        }
-    }
-    catch( const PdfError & e ) 
-    {
-        if( bOwnBuf )
-            delete[] const_cast<pdf_utf16be *>(pszUtf16);
-
-        throw e;
-    }
-
-    if( bOwnBuf )
-        delete[] const_cast<pdf_utf16be *>(pszUtf16);
-
-    // return bytes written
-    return target - pszUtf8;
-}
-
-/* ---------------------------------------------------------------------
-
-    Note A.
-    The fall-through switches in UTF-8 reading code save a
-    temp variable, some decrements & conditionals.  The switches
-    are equivalent to the following loop:
-	{
-	    int tmpBytesToRead = extraBytesToRead+1;
-	    do {
-		ch += *source++;
-		--tmpBytesToRead;
-		if (tmpBytesToRead) ch <<= 6;
-	    } while (tmpBytesToRead > 0);
-	}
-    In UTF-8 writing code, the switches on "bytesToWrite" are
-    similarly unrolled loops.
-
-   --------------------------------------------------------------------- */
-
-
-};
-
-
--- src/base/PdfTokenizer.cpp.orig	2012-12-12 22:55:46.000000000 +0000
+++ src/base/PdfTokenizer.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,806 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfTokenizer.h"
-
-#include "PdfArray.h"
-#include "PdfDictionary.h"
-#include "PdfEncrypt.h"
-#include "PdfInputDevice.h"
-#include "PdfName.h"
-#include "PdfString.h"
-#include "PdfReference.h"
-#include "PdfVariant.h"
-#include "PdfDefinesPrivate.h"
-
-#include <limits>
-#include <sstream>
-
-#include <stdlib.h>
-#include <string.h>
-
-#define PDF_BUFFER 4096
-
-#define DICT_SEP_LENGTH 2
-#define NULL_LENGTH     4
-#define TRUE_LENGTH     4
-#define FALSE_LENGTH    5
-
-namespace PoDoFo {
-
-namespace PdfTokenizerNameSpace{
-
-static const int g_MapAllocLen = 256;
-static char g_DelMap[g_MapAllocLen] = { 0 };
-static char g_WsMap[g_MapAllocLen] = { 0 };
-static char g_EscMap[g_MapAllocLen] = { 0 };
-static char g_hexMap[g_MapAllocLen] = { 0 };
-
-// Generate the delimiter character map at runtime
-// so that it can be derived from the more easily
-// maintainable structures in PdfDefines.h
-const char * genDelMap()
-{
-    char* map = static_cast<char*>(g_DelMap);
-    memset( map, 0, sizeof(char) * g_MapAllocLen );
-    for (int i = 0; i < PoDoFo::s_nNumDelimiters; ++i)
-    {
-        map[static_cast<int>(PoDoFo::s_cDelimiters[i])] = 1;
-    }
-
-    return map;
-}
-
-// Generate the whitespace character map at runtime
-// so that it can be derived from the more easily
-// maintainable structures in PdfDefines.h
-const char * genWsMap()
-{
-    char* map = static_cast<char*>(g_WsMap);
-    memset( map, 0, sizeof(char) * g_MapAllocLen );
-    for (int i = 0; i < PoDoFo::s_nNumWhiteSpaces; ++i)
-    {
-        map[static_cast<int>(PoDoFo::s_cWhiteSpaces[i])] = 1;
-    }
-    return map;
-}
-
-// Generate the escape character map at runtime
-const char* genEscMap()
-{
-    char* map = static_cast<char*>(g_EscMap);
-    memset( map, 0, sizeof(char) * g_MapAllocLen );
-
-    map[static_cast<unsigned char>('n')] = '\n'; // Line feed (LF)
-    map[static_cast<unsigned char>('r')] = '\r'; // Carriage return (CR)
-    map[static_cast<unsigned char>('t')] = '\t'; // Horizontal tab (HT)
-    map[static_cast<unsigned char>('b')] = '\b'; // Backspace (BS)
-    map[static_cast<unsigned char>('f')] = '\f'; // Form feed (FF)
-    map[static_cast<unsigned char>(')')] = ')';  
-    map[static_cast<unsigned char>('(')] = '(';  
-    map[static_cast<unsigned char>('\\')] = '\\';
-
-    return map;
-}
-
-// Generate the hex character map at runtime
-const char* genHexMap()
-{
-    char* map = static_cast<char*>(g_hexMap);
-    memset( map, PdfTokenizer::HEX_NOT_FOUND, sizeof(char) * g_MapAllocLen );
-    
-    map[static_cast<unsigned char>('0')] = 0x0;
-    map[static_cast<unsigned char>('1')] = 0x1;
-    map[static_cast<unsigned char>('2')] = 0x2;
-    map[static_cast<unsigned char>('3')] = 0x3;
-    map[static_cast<unsigned char>('4')] = 0x4;
-    map[static_cast<unsigned char>('5')] = 0x5;
-    map[static_cast<unsigned char>('6')] = 0x6;
-    map[static_cast<unsigned char>('7')] = 0x7;
-    map[static_cast<unsigned char>('8')] = 0x8;
-    map[static_cast<unsigned char>('9')] = 0x9;
-    map[static_cast<unsigned char>('a')] = 0xA;
-    map[static_cast<unsigned char>('b')] = 0xB;
-    map[static_cast<unsigned char>('c')] = 0xC;
-    map[static_cast<unsigned char>('d')] = 0xD;
-    map[static_cast<unsigned char>('e')] = 0xE;
-    map[static_cast<unsigned char>('f')] = 0xF;
-    map[static_cast<unsigned char>('A')] = 0xA;
-    map[static_cast<unsigned char>('B')] = 0xB;
-    map[static_cast<unsigned char>('C')] = 0xC;
-    map[static_cast<unsigned char>('D')] = 0xD;
-    map[static_cast<unsigned char>('E')] = 0xE;
-    map[static_cast<unsigned char>('F')] = 0xF;
-    
-    return map;
-}
-
-};
-
-const unsigned int PdfTokenizer::HEX_NOT_FOUND   = std::numeric_limits<unsigned int>::max();
-const char * const PdfTokenizer::s_delimiterMap  = PdfTokenizerNameSpace::genDelMap();
-const char * const PdfTokenizer::s_whitespaceMap = PdfTokenizerNameSpace::genWsMap();
-const char * const PdfTokenizer::s_escMap        = PdfTokenizerNameSpace::genEscMap();
-const char * const PdfTokenizer::s_hexMap        = PdfTokenizerNameSpace::genHexMap();
-
-const char PdfTokenizer::s_octMap[]        = {
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
-    1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0
-};
-
-PdfTokenizer::PdfTokenizer()
-    : m_buffer( PDF_BUFFER )
-{
-    PdfLocaleImbue(m_doubleParser);
-}
-
-PdfTokenizer::PdfTokenizer( const char* pBuffer, size_t lLen )
-    : m_device( pBuffer, lLen ), m_buffer( PDF_BUFFER )
-{
-    PdfLocaleImbue(m_doubleParser);
-}
-
-PdfTokenizer::PdfTokenizer( const PdfRefCountedInputDevice & rDevice, const PdfRefCountedBuffer & rBuffer )
-    : m_device( rDevice ), m_buffer( rBuffer )
-{
-    PdfLocaleImbue(m_doubleParser);
-}
-
-PdfTokenizer::~PdfTokenizer()
-{
-}
-
-bool PdfTokenizer::GetNextToken( const char*& pszToken , EPdfTokenType* peType )
-{
-    int  c; 
-    long long  counter  = 0;
-
-    // check first if there are quequed tokens and return them first
-    if( m_deqQueque.size() )
-    {
-        TTokenizerPair pair = m_deqQueque.front();
-        m_deqQueque.pop_front();
-
-        if( peType )
-            *peType = pair.second;
-
-        strcpy( m_buffer.GetBuffer(), pair.first.c_str() );
-        pszToken = m_buffer.GetBuffer();
-        return true;
-    }
-    
-    if( !m_device.Device() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( peType )
-        *peType = ePdfTokenType_Token;
-
-    while( (c = m_device.Device()->Look()) != EOF
-           && counter < static_cast<long long>(m_buffer.GetSize()) )
-    {
-        // ignore leading whitespaces
-        if( !counter && IsWhitespace( c ) )
-        {
-            // Consume the whitespace character
-            c = m_device.Device()->GetChar();
-            continue;
-        }
-        // ignore comments
-        else if( c == '%' ) 
-        {
-            // Consume all characters before the next line break
-			// 2011-04-19 Ulrich Arnold: accept 0x0D, 0x0A and oX0D 0x0A as one EOL
-            do {
-                c = m_device.Device()->GetChar();
-            } while( c != EOF && c != 0x0D  && c != 0x0A );
-			
-            if ( c == 0x0D )
-			{
-                if ( m_device.Device()->Look() == 0x0A )
-	                c = m_device.Device()->GetChar();
-			}
-            // If we've already read one or more chars of a token, return them, since
-            // comments are treated as token-delimiting whitespace. Otherwise keep reading
-            // at the start of the next line.
-            if (counter)
-                break;
-        }
-        // special handling for << and >> tokens
-        else if( !counter && (c == '<' || c == '>' ) )
-        {
-            if( peType )
-                *peType = ePdfTokenType_Delimiter;
-
-            // retrieve c really from stream
-            c = m_device.Device()->GetChar();
-            m_buffer.GetBuffer()[counter] = c;
-            ++counter;
-
-            char n = m_device.Device()->Look();
-            // Is n another < or > , ie are we opening/closing a dictionary?
-            // If so, consume that character too.
-            if( n == c )
-            {
-                n = m_device.Device()->GetChar();
-                m_buffer.GetBuffer()[counter] = n;
-                ++counter;
-            }
-            // `m_buffer' contains one of < , > , << or >> ; we're done .
-            break;
-        }
-        else if( counter && (IsWhitespace( c ) || IsDelimiter( c )) )
-        {
-            // Next (unconsumed) character is a token-terminating char, so
-            // we have a complete token and can return it.
-            break;
-        }
-        else
-        {
-            // Consume the next character and add it to the token we're building.
-            c = m_device.Device()->GetChar();
-            m_buffer.GetBuffer()[counter] = c;
-            ++counter;
-
-            if( IsDelimiter( c ) )
-            {
-                // All delimeters except << and >> (handled above) are
-                // one-character tokens, so if we hit one we can just return it
-                // immediately.
-                if( peType )
-                    *peType = ePdfTokenType_Delimiter;
-                break;
-            }
-        }
-    }
-
-    m_buffer.GetBuffer()[counter] = '\0';
-
-
-    if( c == EOF && !counter )
-    {
-        // No characters were read before EOF, so we're out of data.
-        // Ensure the buffer points to NULL in case someone fails to check the return value.
-        pszToken = 0;
-        return false;
-    }
-
-    pszToken = m_buffer.GetBuffer();
-    return true;
-}
-
-bool PdfTokenizer::IsNextToken( const char* pszToken )
-{
-    if( !pszToken )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    const char* pszRead;
-    bool gotToken = this->GetNextToken( pszRead, NULL );
-
-    if (!gotToken)
-    {
-        PODOFO_RAISE_ERROR( ePdfError_UnexpectedEOF );
-    }
-
-    return (strcmp( pszToken, pszRead ) == 0);
-}
-
-pdf_long PdfTokenizer::GetNextNumber()
-{
-    EPdfTokenType eType;
-    const char* pszRead;
-    bool gotToken = this->GetNextToken( pszRead, &eType );
-
-    if( !gotToken )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_UnexpectedEOF, "Expected number" );
-    }
-
-    char* end;
-#ifdef _WIN64
-    pdf_long l = _strtoui64( pszRead, &end, 10 );
-#else
-    pdf_long l = strtol( pszRead, &end, 10 );
-#endif
-    if( end == pszRead )
-    {
-        // Don't consume the token
-        this->QuequeToken( pszRead, eType );
-        PODOFO_RAISE_ERROR_INFO( ePdfError_NoNumber, pszRead );
-    }
-
-    return l;
-}
-
-void PdfTokenizer::GetNextVariant( PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-   EPdfTokenType eTokenType;
-   const char*   pszRead;
-   bool gotToken = this->GetNextToken( pszRead, &eTokenType );
-
-   if (!gotToken)
-   {
-       PODOFO_RAISE_ERROR_INFO( ePdfError_UnexpectedEOF, "Expected variant." );
-   }
-
-   this->GetNextVariant( pszRead, eTokenType, rVariant, pEncrypt );
-}
-
-void PdfTokenizer::GetNextVariant( const char* pszToken, EPdfTokenType eType, PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-    EPdfDataType eDataType = this->DetermineDataType( pszToken, eType, rVariant );
-    
-    if( eDataType == ePdfDataType_Null ||
-        eDataType == ePdfDataType_Bool ||
-        eDataType == ePdfDataType_Number ||
-        eDataType == ePdfDataType_Real ||
-        eDataType == ePdfDataType_Reference )
-    {
-        // the data was already read into rVariant by the DetermineDataType function
-        return;
-    }
-
-    this->ReadDataType( eDataType, rVariant, pEncrypt );
-}
-
-EPdfDataType PdfTokenizer::DetermineDataType( const char* pszToken, EPdfTokenType eTokenType, PdfVariant& rVariant )
-{
-    if( eTokenType == ePdfTokenType_Token ) 
-    {
-        // check for the two special datatypes
-        // null and boolean.
-        // check for numbers
-        if( strncmp( "null", pszToken, NULL_LENGTH ) == 0 )
-        {
-            rVariant = PdfVariant();
-            return ePdfDataType_Null;
-        }
-        else if( strncmp( "true", pszToken, TRUE_LENGTH ) == 0 )
-        {
-            rVariant = PdfVariant( true );
-            return ePdfDataType_Bool;
-        }
-        else if( strncmp( "false", pszToken, FALSE_LENGTH ) == 0 )
-        {
-            rVariant = PdfVariant( false );
-            return ePdfDataType_Bool;
-        }
-
-        EPdfDataType eDataType = ePdfDataType_Number;
-        const char*  pszStart  = pszToken;
-
-        while( *pszStart )
-        {
-            if( *pszStart == '.' )
-                eDataType = ePdfDataType_Real;
-            else if( !(isdigit( static_cast<const unsigned char>(*pszStart) ) || *pszStart == '-' || *pszStart == '+' ) )
-            {
-                eDataType = ePdfDataType_Unknown;
-                break;
-            }
-            
-            ++pszStart;
-        }
-
-        if( eDataType == ePdfDataType_Real ) 
-        {
-            // DOM: strtod is locale dependend,
-            //      do not use it
-            //double dVal = strtod( pszToken, NULL );
-            double dVal;
-
-            m_doubleParser.clear(); // clear error state
-            m_doubleParser.str( pszToken );
-            if( !(m_doubleParser >> dVal) )
-            {
-                m_doubleParser.clear(); // clear error state
-                PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, pszToken );
-            }
-
-            rVariant = PdfVariant( dVal );
-            return ePdfDataType_Real;
-        }
-        else if( eDataType == ePdfDataType_Number ) 
-        {
-#ifdef _WIN64
-            rVariant = PdfVariant( static_cast<pdf_int64>(_strtoui64( pszToken, NULL, 10 )) );
-#else
-            rVariant = PdfVariant( static_cast<pdf_int64>(strtol( pszToken, NULL, 10 )) );
-#endif
-            // read another two tokens to see if it is a reference
-            // we cannot be sure that there is another token
-            // on the input device, so if we hit EOF just return
-            // ePdfDataType_Number .
-            EPdfTokenType eSecondTokenType;
-            bool gotToken = this->GetNextToken( pszToken, &eSecondTokenType );
-            if (!gotToken)
-                // No next token, so it can't be a reference
-                return eDataType;
-            if( eSecondTokenType != ePdfTokenType_Token ) 
-            {
-                this->QuequeToken( pszToken, eSecondTokenType );
-                return eDataType;
-            }
-            
-            
-            pszStart = pszToken;
-#ifdef _WIN64            
-            pdf_long  l   = _strtoui64( pszStart, const_cast<char**>(&pszToken), 10 );
-#else
-            long  l   = strtol( pszStart, const_cast<char**>(&pszToken), 10 );
-#endif
-            if( pszToken == pszStart ) 
-            {
-                this->QuequeToken( pszStart, eSecondTokenType );
-                return eDataType;
-            }
-
-            std::string backup( pszStart );
-            EPdfTokenType eThirdTokenType;
-            gotToken = this->GetNextToken( pszToken, &eThirdTokenType );
-            if (!gotToken)
-                // No third token, so it can't be a reference
-                return eDataType;
-            if( eThirdTokenType == ePdfTokenType_Token &&
-                pszToken[0] == 'R' && pszToken[1] == '\0' )
-            {
-                rVariant = PdfReference( static_cast<unsigned int>(rVariant.GetNumber()), 
-                                         static_cast<const pdf_uint16>(l) );
-                return ePdfDataType_Reference;
-            }
-            else
-            {
-                this->QuequeToken( backup.c_str(), eSecondTokenType );
-                this->QuequeToken( pszToken, eThirdTokenType );
-                return eDataType;
-            }
-        } 
-    }
-    else if( eTokenType == ePdfTokenType_Delimiter ) 
-    {
-        if( strncmp( "<<", pszToken, DICT_SEP_LENGTH ) == 0 )
-            return ePdfDataType_Dictionary;
-        else if( pszToken[0] == '[' )
-            return ePdfDataType_Array;
-        else if( pszToken[0] == '(' )
-            return ePdfDataType_String;
-        else if( pszToken[0] == '<' ) 
-            return ePdfDataType_HexString;
-        else if( pszToken[0] == '/' )
-            return ePdfDataType_Name;
-    }
-
-    if( false ) 
-    {
-        std::ostringstream ss;
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200
-        ss << "Got unexpected PDF data in" << __FILE__ << ", line " << __LINE__
-#else
-        ss << "Got unexpected PDF data in" << PODOFO__FUNCTION__
-#endif
-           << ": \""
-           << pszToken
-           << "\". Current read offset is "
-           << m_device.Device()->Tell()
-           << " which should be around the problem.\n";
-        PdfError::DebugMessage(ss.str().c_str());
-    }
-
-    return ePdfDataType_Unknown;
-}
-
-void PdfTokenizer::ReadDataType( EPdfDataType eDataType, PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-    switch( eDataType ) 
-    {
-        case ePdfDataType_Dictionary:
-            this->ReadDictionary( rVariant, pEncrypt );
-            break;
-        case ePdfDataType_Array:
-            this->ReadArray( rVariant, pEncrypt );
-            break;
-        case ePdfDataType_String:
-            this->ReadString( rVariant, pEncrypt );
-            break;
-        case ePdfDataType_HexString:
-            this->ReadHexString( rVariant, pEncrypt );
-            break;
-        case ePdfDataType_Name:
-            this->ReadName( rVariant );
-            break;
-
-        // The following datatypes are not handled by read datatype
-        // but are already parsed by DetermineDatatype
-        case ePdfDataType_Null:
-        case ePdfDataType_Bool:
-        case ePdfDataType_Number:
-        case ePdfDataType_Real:
-        case ePdfDataType_Reference:
-        case ePdfDataType_Unknown:
-        case ePdfDataType_RawData:
-
-        default:
-        {
-            PdfError::LogMessage( eLogSeverity_Debug, "Got Datatype: %i\n", eDataType );
-            PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-        }
-    }
-}
-
-void PdfTokenizer::ReadDictionary( PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-    PdfVariant    val;
-    PdfName       key;
-    PdfDictionary dict;
-    EPdfTokenType eType;
-    const char *  pszToken;
-
-    for( ;; ) 
-    {
-        bool gotToken = this->GetNextToken( pszToken, &eType );
-        if (!gotToken)
-        {
-            PODOFO_RAISE_ERROR_INFO(ePdfError_UnexpectedEOF, "Expected dictionary key name or >> delim.");
-        }
-        if( eType == ePdfTokenType_Delimiter && strncmp( ">>", pszToken, DICT_SEP_LENGTH ) == 0 )
-            break;
-
-        this->GetNextVariant( pszToken, eType, val, pEncrypt );
-        // Convert the read variant to a name; throws InvalidDataType if not a name.
-        key = val.GetName();
-        // Get the next variant. If there isn't one, it'll throw UnexpectedEOF.
-        this->GetNextVariant( val, pEncrypt );
-
-        dict.AddKey( key, val );
-    }
-
-    rVariant = dict;
-}
-
-void PdfTokenizer::ReadArray( PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-    const char*   pszToken;
-    EPdfTokenType eType;
-    PdfVariant    var;
-    PdfArray      array;
-
-    for( ;; ) 
-    {
-        bool gotToken = this->GetNextToken( pszToken, &eType );
-        if (!gotToken)
-        {
-            PODOFO_RAISE_ERROR_INFO(ePdfError_UnexpectedEOF, "Expected array item or ] delim.");
-        }
-        if( eType == ePdfTokenType_Delimiter && pszToken[0] == ']' )
-            break;
-
-        this->GetNextVariant( pszToken, eType, var, pEncrypt );
-        array.push_back( var );
-    }
-
-    rVariant = array;
-}
-
-void PdfTokenizer::ReadString( PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-    int               c;
-
-    bool              bEscape       = false;
-    bool              bOctEscape    = false;
-    int               nOctCount     = 0;
-    char              cOctValue     = 0;
-    int               nBalanceCount = 0; // Balanced parathesis do not have to be escaped in strings
-
-    m_vecBuffer.clear();
-
-    while( (c = m_device.Device()->Look()) != EOF )
-    {
-        // end of stream reached
-        if( !bEscape ) 
-        {
-            // Handle raw characters
-            c = m_device.Device()->GetChar();
-            if( !nBalanceCount && c == ')' )
-                break;
-            
-            if( c == '(' )
-                ++nBalanceCount;
-            else if( c == ')' )
-                --nBalanceCount;
-        
-            bEscape = (c == '\\');
-            if( !bEscape )
-                m_vecBuffer.push_back( static_cast<char>(c) );
-        }
-        else
-        {
-            // Handle escape sequences
-            if( bOctEscape || s_octMap[c & 0xff] )
-                // The last character we have read was a '\\',
-                // so we check now for a digit to find stuff like \005
-                bOctEscape = true;
-            
-            if( bOctEscape ) 
-            {
-                // Handle octal escape sequences
-                ++nOctCount;
-                
-                if( !s_octMap[c & 0xff] )
-                {
-                    // No octal character anymore,
-                    // so the octal sequence must be ended
-                    // and the character has to be treated as normal character!
-                    m_vecBuffer.push_back ( cOctValue );
-                    bEscape    = false;
-                    bOctEscape = false;
-                    nOctCount  = 0;
-                    cOctValue  = 0;
-                    continue;
-                }
-                
-                c = m_device.Device()->GetChar();
-                cOctValue <<= 3;
-                cOctValue  |= ((c-'0') & 0x07);
-                
-                if( nOctCount > 2 )
-                {
-                    m_vecBuffer.push_back ( cOctValue );
-                    bEscape    = false;
-                    bOctEscape = false;
-                    nOctCount  = 0;
-                    cOctValue  = 0;
-                }
-            }
-            else
-            {
-                // Handle plain escape sequences
-                const char & code = s_escMap[m_device.Device()->GetChar() & 0xff];
-                if( code )
-                    m_vecBuffer.push_back( code );
-                
-                bEscape = false;
-            }
-        }
-    }
-
-    // In case the string ends with a octal escape sequence
-    if( bOctEscape )
-        m_vecBuffer.push_back ( cOctValue );
-
-    if( m_vecBuffer.size() )
-    {
-        if( pEncrypt )
-        {
-            pdf_long outLen = m_vecBuffer.size() - pEncrypt->CalculateStreamOffset();
-            char * outBuffer = new char[outLen];
-            pEncrypt->Decrypt( reinterpret_cast<unsigned char*>(&(m_vecBuffer[0])),
-                              static_cast<unsigned int>(m_vecBuffer.size()),
-                              reinterpret_cast<unsigned char*>(outBuffer), outLen);
-            
-            rVariant = PdfString( outBuffer, outLen );
-            
-            delete[] outBuffer;
-        }
-        else
-        {
-            rVariant = PdfString( &(m_vecBuffer[0]), m_vecBuffer.size() );
-        }
-    }
-    else
-    {
-        rVariant = PdfString("");
-    }
-}
-
-void PdfTokenizer::ReadHexString( PdfVariant& rVariant, PdfEncrypt* pEncrypt )
-{
-    int        c;
-
-    m_vecBuffer.clear();
-
-    while( (c = m_device.Device()->GetChar()) != EOF )
-    {
-        // end of stream reached
-        if( c == '>' )
-            break;
-
-        // only a hex digits
-        if( isdigit( c ) || 
-            ( c >= 'A' && c <= 'F') ||
-            ( c >= 'a' && c <= 'f'))
-            m_vecBuffer.push_back( c );
-    }
-
-    // pad to an even length if necessary
-    if( m_vecBuffer.size() % 2 )
-        m_vecBuffer.push_back( '0' );
-
-    PdfString string;
-    string.SetHexData( m_vecBuffer.size() ? &(m_vecBuffer[0]) : "", m_vecBuffer.size(), pEncrypt );
-
-    rVariant = string;
-}
-
-void PdfTokenizer::ReadName( PdfVariant& rVariant )
-{
-    EPdfTokenType eType;
-    const char*   pszToken;
-
-    // Do special checking for empty names
-    // as GetNextToken will ignore white spaces 
-    // and we have to take care for stuff like:
-    // 10 0 obj / endobj
-    // which stupid but legal PDF
-    int c = m_device.Device()->Look();
-    if( IsWhitespace( c ) ) // Delimeters are handled correctly by GetNextToken
-    {
-        // We are an empty PdfName
-        rVariant = PdfName();
-        return;
-    }
-
-    bool gotToken = this->GetNextToken( pszToken, &eType );
-    if( !gotToken || eType != ePdfTokenType_Token )
-    {
-        // We got an empty name which is legal according to the PDF specification
-        // Some weird PDFs even use them.
-        rVariant = PdfName();
-
-        // Queque the token again
-        if( gotToken )
-            QuequeToken( pszToken, eType );
-    }
-    else
-        rVariant = PdfName::FromEscaped( pszToken );
-}
-
-void PdfTokenizer::QuequeToken( const char* pszToken, EPdfTokenType eType )
-{
-    m_deqQueque.push_back( TTokenizerPair( std::string( pszToken ), eType ) );
-}
-
-};
--- src/base/PdfVariant.h.orig	2012-05-05 08:54:25.000000000 +0000
+++ src/base/PdfVariant.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1031 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_VARIANT_H_
-#define _PDF_VARIANT_H_
-
-#include <cmath>
-
-#include "PdfDefines.h"
-#include "PdfRefCountedBuffer.h"
-#include "PdfString.h"
-
-namespace PoDoFo {
-
-class PdfArray;
-class PdfData;
-class PdfDataType;
-class PdfDictionary;
-class PdfEncrypt;
-class PdfName;
-class PdfOutputDevice;
-class PdfString;
-class PdfReference;
-
-/**
- * A variant data type which supports all data types supported by the PDF standard.
- * The data can be parsed directly from a string or set by one of the members.
- * One can also convert the variant back to a string after setting the values.
- *
- * \warning All methods not marked otherwise may trigger a deferred load. This means
- *          that they are unsafe to call while a deferred load is already in progress
- *          (as recursion will occurr).
- *
- * TODO: domseichter: Make this class implicitly shared
- */
-class PODOFO_API PdfVariant {
-    friend class PdfArray;
-    friend class PdfDictionary;
-
- public:
-
-    static PdfVariant NullValue;
-
-    /** Construct an empty variant type
-     *  IsNull() will return true.
-     */
-    PdfVariant();
-
-    /** Construct a PdfVariant that is a bool.
-     *  \param b the boolean value of this PdfVariant
-     */
-    PdfVariant( bool b );
-
-    /** Construct a PdfVariant that is a number.
-     *  \param l the value of the number.
-     */
-    PdfVariant( pdf_int64 l );
-
-    /** Construct a PdfVariant that is a real number.
-     *  \param d the value of the real number.
-     */    
-    PdfVariant( double d );
-
-    /** Construct a PdfVariant that is a string. The argument
-     * string will be escaped where necessary, so it should be
-     * passed in unescaped form.
-     *
-     *  \param rsString the value of the string
-     */        
-    PdfVariant( const PdfString & rsString );
-
-    /** Construct a PdfVariant that is a name.
-     *  \param rName the value of the name
-     */        
-    PdfVariant( const PdfName & rName );
-
-    /** Construct a PdfVariant that is a name.
-     *  \param rRef the value of the name
-     */        
-    PdfVariant( const PdfReference & rRef );
-
-    /** Initalize a PdfVariant object with array data.
-     *  The variant will automatically get the datatype
-     *  ePdfDataType_Array. This Init call is the fastest
-     *  way to create a new PdfVariant that is an array.
-     *
-     *  \param tList a list of variants
-     *
-     *  \returns ErrOk on sucess
-     */
-    PdfVariant( const PdfArray & tList );
-
-    /** Construct a PdfVariant that is a dictionary.
-     *  \param rDict the value of the dictionary.
-     */        
-    PdfVariant( const PdfDictionary & rDict );
-
-    /** Construct a PdfVariant that contains raw PDF data.
-     *  \param rData raw and valid PDF data.
-     */        
-    PdfVariant( const PdfData & rData );
-
-    /** Constructs a new PdfVariant which has the same 
-     *  contents as rhs.
-     *  \param rhs an existing variant which is copied.
-     */
-    PdfVariant( const PdfVariant & rhs );
-
-    virtual ~PdfVariant();
-    
-    /** \returns true if this PdfVariant is empty.
-     *           i.e. m_eDataType == ePdfDataType_Null
-     */
-    inline bool IsEmpty() const;
-
-    /** Clear all internal member variables and free the memory
-     *  they have allocated.
-     *  Sets the datatype to ePdfDataType_Null
-     *
-     *  This will reset the dirty flag of this object to be clean.
-     *  \see IsDirty
-     */
-    void Clear();
-
-    /** \returns the datatype of this object or ePdfDataType_Unknown
-     *  if it does not have a value.
-     */
-    inline EPdfDataType GetDataType() const;
-
-    /** \returns a human readable string representation of GetDataType()
-     *  The returned string must not be free'd.
-     */
-    const char * GetDataTypeString() const;
-
-    /** \returns true if this variant is a bool (i.e. GetDataType() == ePdfDataType_Bool)
-     */
-    inline bool IsBool() const { return GetDataType() == ePdfDataType_Bool; }
-
-    /** \returns true if this variant is a number (i.e. GetDataType() == ePdfDataType_Number)
-     */
-    inline bool IsNumber() const { return GetDataType() == ePdfDataType_Number; }
-
-    /** \returns true if this variant is a real (i.e. GetDataType() == ePdfDataType_Real)
-     */
-    inline bool IsReal() const { return GetDataType() == ePdfDataType_Real; }
-
-    /** \returns true if this variant is a string (i.e. GetDataType() == ePdfDataType_String)
-     */
-    inline bool IsString() const { return GetDataType() == ePdfDataType_String; }
-
-    /** \returns true if this variant is a hex-string (i.e. GetDataType() == ePdfDataType_HexString)
-     */
-    inline bool IsHexString() const { return GetDataType() == ePdfDataType_HexString; }
-
-    /** \returns true if this variant is a name (i.e. GetDataType() == ePdfDataType_Name)
-     */
-    inline bool IsName() const { return GetDataType() == ePdfDataType_Name; }
-
-    /** \returns true if this variant is an array (i.e. GetDataType() == ePdfDataType_Array)
-     */
-    inline bool IsArray() const { return GetDataType() == ePdfDataType_Array; }
-
-    /** \returns true if this variant is a dictionary (i.e. GetDataType() == ePdfDataType_Dictionary)
-     */
-    inline bool IsDictionary() const { return GetDataType() == ePdfDataType_Dictionary; }
-
-    /** \returns true if this variant is raw data (i.e. GetDataType() == ePdfDataType_RawData
-     */
-    inline bool IsRawData() const { return GetDataType() == ePdfDataType_RawData; }
-
-    /** \returns true if this variant is null (i.e. GetDataType() == ePdfDataType_Null)
-     */
-    inline bool IsNull() const { return GetDataType() == ePdfDataType_Null; }
-
-    /** \returns true if this variant is a reference (i.e. GetDataType() == ePdfDataType_Reference)
-     */
-    inline bool IsReference() const { return GetDataType() == ePdfDataType_Reference; }
-       
-    /** Write the complete variant to an output device.
-     *  This is an overloaded member function.
-     *
-     *  \param pDevice write the object to this device
-     *  \param eWriteMode additional options for writing this object
-     *  \param pEncrypt an encryption object which is used to encrypt this object
-     *                  or NULL to not encrypt this object
-     */
-    void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, 
-                const PdfEncrypt* pEncrypt = NULL ) const;
-
-    /** Write the complete variant to an output device.
-     *  \param pDevice write the object to this device
-     *  \param eWriteMode additional options for writing this object
-     *  \param pEncrypt an encryption object which is used to encrypt this object
-     *                  or NULL to not encrypt this object
-     *  \param keyStop if not KeyNull and a key == keyStop is found
-     *                 writing will stop right before this key!
-     *                 if IsDictionary returns true.
-     */
-    virtual void Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt, const PdfName & keyStop ) const;
-
-    /** Converts the current object into a string representation
-     *  which can be written directly to a PDF file on disc.
-     *  \param rsData the object string is returned in this object.
-     *  \param eWriteMode additional options for writing to a string
-     */
-    void ToString( std::string & rsData, EPdfWriteMode eWriteMode = ePdfWriteMode_Clean ) const;
-
-    /** Set the value of this object as bool
-     *  \param b the value as bool.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    inline void SetBool( bool b );
-
-    /** Get the value if this object is a bool.
-     *  \returns the bool value.
-     */
-    inline bool GetBool() const;
-
-    /** Set the value of this object as long
-     *  \param l the value as long.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    inline void SetNumber( long l );
-
-    /** Get the value of the object as long.
-     *  \return the value of the number
-     */
-    inline pdf_int64 GetNumber() const;
-
-    /** Set the value of this object as double
-     *  \param d the value as double.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    inline void SetReal( double d );
-
-    /** Get the value of the object as double.
-     *  \return the value of the number
-     */
-    inline double GetReal() const;
-
-    /** \returns the value of the object as string.
-     */
-    inline const PdfString & GetString() const;
-
-    /** \returns the value of the object as name
-     */
-    inline const PdfName & GetName() const;
-
-    /** Returns the value of the object as array
-     *  \returns a array
-     */
-    inline const PdfArray & GetArray() const;
-
-    /** Returns the value of the object as array
-     *  \returns a array
-     */
-    inline PdfArray & GetArray();
-
-    /** Returns the dictionary value of this object
-     *  \returns a PdfDictionary
-     */
-    inline const PdfDictionary & GetDictionary() const; 
-
-    /** Returns the dictionary value of this object
-     *  \returns a PdfDictionary
-     */
-    inline PdfDictionary & GetDictionary(); 
-
-    /** Get the reference values of this object.
-     *  \returns a PdfReference
-     */
-    inline const PdfReference & GetReference() const;
-
-    /** Get the reference values of this object.
-     *  \returns a reference to the PdfData instance.
-     */
-    inline const PdfData & GetRawData() const;
-
-    /** Get the reference values of this object.
-     *  \returns a reference to the PdfData instance.
-     */
-    inline PdfData & GetRawData();
-
-    /** Assign the values of another PdfVariant to this one.
-     *  \param rhs an existing variant which is copied.
-     *
-     *  This will set the dirty flag of this object.
-     *  \see IsDirty
-     */
-    const PdfVariant & operator=( const PdfVariant & rhs );
-
-    /**
-     * Test to see if the value contained by this variant is the same
-     * as the value of the other variant.
-     */
-    bool operator==( const PdfVariant & rhs ) const;
-
-    /**
-     * \see operator==
-     */
-    inline bool operator!=( const PdfVariant & rhs) const;
-
-    /** The dirty flag is set if this variant
-     *  has been modified after construction.
-     *  
-     *  Usually the dirty flag is also set
-     *  if you call any non-const member function
-     *  (e.g. GetDictionary()) as PdfVariant cannot
-     *  determine if you actually changed the dictionary
-     *  or not.
-     *
-     *  \returns true if the value is dirty and has been 
-     *                modified since construction
-     */
-    inline bool IsDirty() const;
-
-    /**
-     * Sets this object to immutable,
-     * so that no keys can be edited or changed.
-     *
-     * @param bImmutable if true set the object to be immutable
-     *
-     * This is used by PdfImmediateWriter and PdfStreamedDocument so 
-     * that no keys can be added to an object after setting stream data on it.
-     *
-     */
-    inline void SetImmutable(bool bImmutable);
-
-    /**
-     * Retrieve if an object is immutable.
-     *
-     * This is used by PdfImmediateWriter and PdfStreamedDocument so 
-     * that no keys can be added to an object after setting stream data on it.
-     *
-     * @returns true if the object is immutable
-     */
-    inline bool GetImmutable() const;
-
- protected:
-
-    /**
-     *  Will throw an exception if called on an immutable object,
-     *  so this should be called before actually changing a value!
-     * 
-     */
-    inline void AssertMutable() const;
-
-    /** Sets the dirty flag of this PdfVariant
-     *
-     *  \param bDirty true if this PdfVariant has been
-     *                modified from the outside
-     *
-     *  \see IsDirty
-     */
-    inline void SetDirty( bool bDirty );
-
-    /**
-     * Dynamically load the contents of this object from a PDF file by calling
-     * the virtual method DelayedLoadImpl() if the object is not already loaded.
-     *
-     * For objects complete created in memory and those that do not support
-     * deferred loading this function does nothing, since deferred loading
-     * will not be enabled.
-     */
-    inline void DelayedLoad() const;
-
-    /** Flag the object  incompletely loaded.  DelayedLoad() will be called
-     *  when any method that requires more information than is currently
-     *  available is loaded.
-     *
-     *  All constructors initialize a PdfVariant with delayed loading disabled .
-     *  If you want delayed loading you must ask for it. If you do so, call
-     *  this method early in your ctor and be sure to override DelayedLoadImpl().
-     */
-    inline void EnableDelayedLoading();
-
-    /** Load all data of the object if delayed loading is enabled.
-     *
-     * Never call this method directly; use DelayedLoad() instead.
-     *
-     * You should override this to control deferred loading in your subclass.
-     * Note that this method should not load any associated streams, just the
-     * base object.
-     *
-     * The default implementation throws. It should never be called, since
-     * objects that do not support delayed loading should not enable it.
-     *
-     * While this method is not `const' it may be called from a const context,
-     * so be careful what you mess with.
-     */
-    inline virtual void DelayedLoadImpl();
-
-    /**
-     * Returns true if delayed loading is disabled, or if it is enabled
-     * and loading has completed. External callers should never need to
-     * see this, it's an internal state flag only.
-     */
-    PODOFO_NOTHROW inline bool DelayedLoadDone() const;
-
-    // Rather than having deferred load triggering disabled while deferred
-    // loading is in progress, causing public methods to potentially return
-    // invalid data, we provide special methods that won't trigger a deferred
-    // load for use during deferred loading. They're not for general use and
-    // not available for use except by subclasses.
-    //
-    /** Version of GetDictionary() that doesn't trigger a delayed load
-     *  \returns a PdfDictionary
-     */
-    inline const PdfDictionary & GetDictionary_NoDL() const; 
-
-    /** Version of GetDictionary() that doesn't trigger a delayed load
-     *  \returns a PdfDictionary
-     */
-    inline PdfDictionary & GetDictionary_NoDL(); 
-
-    /** Version of GetArray() that doesn't trigger a delayed load
-     *  \returns a array
-     */
-    inline const PdfArray & GetArray_NoDL() const;
-
-    /** Version of GetArray() that doesn't trigger a delayed load.
-     *  \returns a array
-     */
-    inline PdfArray & GetArray_NoDL();
-
- private:
-    /**
-     * It's an easy mistake to pass a pointer to a PdfVariant when trying to
-     * copy a PdfVariant, especially with heap allocators like `new'. This can
-     * produce confusing and unexpected results like getting a PdfVariant(bool).
-     *
-     * A similar issue can arise when the user passes a `char*' and expects a PdfName
-     * or PdfString based variant to be created. We can't know which they wanted, so
-     * we should fail, especially since the compiler tends to convert pointers to bool
-     * for extra confusion value.
-     *
-     * We provide this overload so that such attempts will fail with an error about
-     * a private ctor. If you're reading this, you wrote:
-     *
-     *  PdfVariant( my_ptr_to_something )
-     *
-     *... not ...
-     * 
-     *  PdfVariant( *my_ptr_to_something )
-     *
-     * If you need to modify PdfVariant to legitimately take a pointer in the future,
-     * you can do so by providing a template specialization, or by removing this check
-     * and replacing it with a couple of overloads specific to PdfObject*, PdfVariant*,
-     * and char* (at least).
-     */
-    template<typename T> PdfVariant(T*);
-
-    /** To reduce memory usage of this very often used class,
-     *  we use a union here, as there is always only
-     *  one of those members used.
-     */
-    typedef union { 
-        /** Holds references, strings, 
-         *  names, dictionaries and arrays
-         */
-        PdfDataType* pData;
-
-        bool       bBoolValue;
-        double     dNumber;
-        pdf_int64      nNumber;
-    } UVariant;
-
-    UVariant     m_Data;
-
-    bool         m_bDirty; ///< Indicates if this object was modified after construction
-    bool         m_bImmutable; ///< Indicates if this object maybe modified
-
-
-    /** Datatype of the variant.
-     *  required to access the correct member of 
-     *  the union UVariant.
-     */
-    EPdfDataType m_eDataType;
-
-    // No touchy. Only for use by PdfVariant's internal tracking of the delayed
-    // loading state. Use DelayedLoadDone() to test this if you need to.
-    mutable bool m_bDelayedLoadDone;
-
-    // Helper for ctor
-    PODOFO_NOTHROW void Init();
-
-#if defined(PODOFO_EXTRA_CHECKS)
-protected:
-    PODOFO_NOTHROW bool DelayedLoadInProgress() const { return m_bDelayedLoadInProgress; }
-private:
-    mutable bool m_bDelayedLoadInProgress;
-#endif
-};
-
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVariant::DelayedLoad() const
-{
-#if defined(PODOFO_EXTRA_CHECKS)
-    // Whoops! Delayed loading triggered during delayed loading. Someone probably
-    // used a public method that calls DelayedLoad() from a delayed load.
-    if (m_bDelayedLoadInProgress)
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InternalLogic, "Recursive DelayedLoad() detected" );
-#endif
-    if( !m_bDelayedLoadDone)
-    {
-#if defined(PODOFO_EXTRA_CHECKS)
-        m_bDelayedLoadInProgress = true;
-#endif
-        const_cast<PdfVariant*>(this)->DelayedLoadImpl();
-        // Nothing was thrown, so if the implementer of DelayedLoadImpl()
-        // following the rules we're done.
-        m_bDelayedLoadDone = true;
-#if defined(PODOFO_EXTRA_CHECKS)
-        m_bDelayedLoadInProgress = false;
-#endif
-    }
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfVariant::IsEmpty() const
-{
-    DelayedLoad();
-
-    return (m_eDataType == ePdfDataType_Null);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-EPdfDataType PdfVariant::GetDataType() const
-{
-    DelayedLoad();
-
-    return m_eDataType;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfVariant::SetBool( bool b )
-{
-    DelayedLoad();
-
-    if( !IsBool() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    AssertMutable();
-    m_Data.bBoolValue = b;
-    SetDirty( true );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfVariant::GetBool() const
-{
-    DelayedLoad();
-
-    if( !IsBool() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    return m_Data.bBoolValue;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfVariant::SetNumber( long l ) 
-{
-    DelayedLoad();
-
-    if( !IsReal() && !IsNumber() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    AssertMutable();
-    if ( IsReal() )
-        m_Data.dNumber = static_cast<double>(l);
-    else
-        m_Data.nNumber = l;
-    SetDirty( true );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-pdf_int64 PdfVariant::GetNumber() const
-{
-    DelayedLoad();
-
-    if( !IsReal() && !IsNumber() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    if ( IsReal() )
-        return static_cast<long>(floor( m_Data.dNumber ));
-    else
-        return m_Data.nNumber;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfVariant::SetReal( double d ) 
-{
-    DelayedLoad();
-
-    if( !IsReal() && !IsNumber() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    AssertMutable();
-    if ( IsReal() )
-        m_Data.dNumber = d;
-    else
-        m_Data.nNumber = static_cast<long>(floor( d ));
-    SetDirty( true );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfVariant::GetReal() const
-{
-    DelayedLoad();
-
-    if( !IsReal() && !IsNumber() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    if ( IsReal() )
-        return m_Data.dNumber;
-    else
-        return static_cast<double>(m_Data.nNumber);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-#ifdef __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif // __GNUC__
-const PdfData & PdfVariant::GetRawData() const
-{
-    DelayedLoad();
-
-    if( !IsRawData() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfData*)m_Data.pData);
-}
-#ifdef __GNUC__
-#pragma GCC diagnostic pop
-#endif // __GNUC__
-
-
-PdfData & PdfVariant::GetRawData()
-{
-    DelayedLoad();
-
-    if( !IsRawData() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfData*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfString & PdfVariant::GetString() const
-{
-    DelayedLoad();
-
-    if( !IsString() && !IsHexString() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfString*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfName & PdfVariant::GetName() const
-{
-    DelayedLoad();
-
-    if( !IsName() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfName*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfArray & PdfVariant::GetArray() const
-{
-    DelayedLoad();
-    return GetArray_NoDL();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfArray & PdfVariant::GetArray_NoDL() const
-{
-    // Test against eDataType directly not GetDataType() since
-    // we don't want to trigger a delayed load (and if required one has
-    // already been triggered).
-    if( m_eDataType != ePdfDataType_Array )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfArray*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-PdfArray & PdfVariant::GetArray()
-{
-    DelayedLoad();
-    return GetArray_NoDL();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-PdfArray & PdfVariant::GetArray_NoDL()
-{
-    // Test against eDataType directly not GetDataType() since
-    // we don't want to trigger a delayed load (and if required one has
-    // already been triggered).
-    if( m_eDataType != ePdfDataType_Array )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfArray*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfDictionary & PdfVariant::GetDictionary() const
-{
-    DelayedLoad();
-    return GetDictionary_NoDL();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfDictionary & PdfVariant::GetDictionary_NoDL() const
-{
-    // Test against eDataType directly not GetDataType() since
-    // we don't want to trigger a delayed load (and if required one has
-    // already been triggered).
-    if( m_eDataType != ePdfDataType_Dictionary )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfDictionary*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-PdfDictionary & PdfVariant::GetDictionary()
-{
-    DelayedLoad();
-    return GetDictionary_NoDL();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-PdfDictionary & PdfVariant::GetDictionary_NoDL()
-{
-    // Test against eDataType directly not GetDataType() since
-    // we don't want to trigger a delayed load (and if required one has
-    // already been triggered).
-    if( m_eDataType != ePdfDataType_Dictionary )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfDictionary*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const PdfReference & PdfVariant::GetReference() const
-{
-    DelayedLoad();
-
-    if( !IsReference() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Do not change this to an reinterpret_cast
-    // We need a c-style casts here to avoid crashes
-    // because a reinterpret_cast might point to a different position.
-    return *((PdfReference*)m_Data.pData);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfVariant::DelayedLoadDone() const
-{
-    return m_bDelayedLoadDone;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfVariant::EnableDelayedLoading()
-{
-    m_bDelayedLoadDone = false;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfVariant::DelayedLoadImpl()
-{
-    // Default implementation of virtual void DelayedLoadImpl() throws, since delayed
-    // loading should not be enabled except by types that support it.
-    PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfVariant::operator!=( const PdfVariant & rhs) const
-{
-    return !(*this == rhs);
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfVariant::IsDirty() const
-{
-    // If this is a object with
-    // stream, the streams dirty
-    // flag might be set.
-    if( m_bDirty )
-        return m_bDirty;
-
-    switch( m_eDataType ) 
-    {
-        case ePdfDataType_Array:
-        case ePdfDataType_Dictionary:
-            // Arrays and Dictionaries
-            // handle dirty status by themselfes
-            return m_Data.pData->IsDirty();
-
-        case ePdfDataType_Bool:
-        case ePdfDataType_Number:
-        case ePdfDataType_Real:
-        case ePdfDataType_HexString:
-        case ePdfDataType_String:
-        case ePdfDataType_Name:
-        case ePdfDataType_RawData:
-        case ePdfDataType_Reference:
-        case ePdfDataType_Null:
-        case ePdfDataType_Unknown:
-        default:
-            return m_bDirty;
-    };
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-void PdfVariant::SetDirty( bool bDirty ) 
-{
-    m_bDirty = bDirty;
-
-    if( !m_bDirty ) 
-    {
-        // Propogate new dirty state to subclasses
-        switch( m_eDataType ) 
-        {
-            case ePdfDataType_Array:
-            case ePdfDataType_Dictionary:
-                // Arrays and Dictionaries
-                // handle dirty status by themselfes
-                m_Data.pData->SetDirty( m_bDirty );
-
-            case ePdfDataType_Bool:
-            case ePdfDataType_Number:
-            case ePdfDataType_Real:
-            case ePdfDataType_HexString:
-            case ePdfDataType_String:
-            case ePdfDataType_Name:
-            case ePdfDataType_RawData:
-            case ePdfDataType_Reference:
-            case ePdfDataType_Null:
-            case ePdfDataType_Unknown:
-            default:
-                break;
-        };    
-    }
-}
-
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVariant::SetImmutable(bool bImmutable)
-{
-    m_bImmutable = bImmutable;
-
-    switch( m_eDataType ) 
-    {
-        case ePdfDataType_Array:
-        case ePdfDataType_Dictionary:
-            // Arrays and Dictionaries
-            // handle dirty status by themselfes
-            m_Data.pData->SetImmutable( m_bImmutable );
-            
-        case ePdfDataType_Bool:
-        case ePdfDataType_Number:
-        case ePdfDataType_Real:
-        case ePdfDataType_HexString:
-        case ePdfDataType_String:
-        case ePdfDataType_Name:
-        case ePdfDataType_RawData:
-        case ePdfDataType_Reference:
-        case ePdfDataType_Null:
-        case ePdfDataType_Unknown:
-        default:
-            break;
-    };    
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline bool PdfVariant::GetImmutable() const 
-{
-    return m_bImmutable;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVariant::AssertMutable() const
-{
-    if(m_bImmutable) 
-    {
-        throw new PdfError( ePdfError_ChangeOnImmutable );
-    }
-}
-
-};
-
-#endif // _PDF_VARIANT_H_
--- src/base/PdfVecObjects.h.orig	2011-09-07 11:54:49.000000000 +0000
+++ src/base/PdfVecObjects.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,598 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_VEC_OBJECTS_H_
-#define _PDF_VEC_OBJECTS_H_
-
-#include "PdfDefines.h"
-#include "PdfReference.h"
-
-#include <list>
-
-namespace PoDoFo {
-
-class PdfDocument;
-class PdfObject;
-class PdfStream;
-class PdfVariant;
-
-// Use deque as many insertions are here way faster than with using std::list
-// This is especially useful for PDFs like PDFReference17.pdf with
-// lot's of free objects.
-typedef std::deque<PdfReference>                 TPdfReferenceList;
-typedef TPdfReferenceList::iterator              TIPdfReferenceList;
-typedef TPdfReferenceList::const_iterator        TCIPdfReferenceList;
-
-typedef std::set<PdfReference>                   TPdfReferenceSet;
-typedef TPdfReferenceSet::iterator               TIPdfReferenceSet;
-typedef TPdfReferenceSet::const_iterator         TCIPdfReferenceSet;
-
-typedef std::list<PdfReference*>                 TReferencePointerList;
-typedef TReferencePointerList::iterator          TIReferencePointerList;
-typedef TReferencePointerList::const_iterator    TCIReferencePointerList;
-
-typedef std::vector<TReferencePointerList  >     TVecReferencePointerList;
-typedef TVecReferencePointerList::iterator       TIVecReferencePointerList;
-typedef TVecReferencePointerList::const_iterator TCIVecReferencePointerList;
-
-/*
-typedef std::vector<PdfObject*>      TVecObjects;
-typedef TVecObjects::iterator        TIVecObjects;
-typedef TVecObjects::const_iterator  TCIVecObjects;
-*/
-
-typedef std::vector<PdfObject*>      TVecObjects;
-typedef TVecObjects::iterator        TIVecObjects;
-typedef TVecObjects::const_iterator  TCIVecObjects;
-
-
-
-/** A STL vector of PdfObjects. I.e. a list of PdfObject classes.
- *  The PdfParser will read the PdfFile into memory and create 
- *  a PdfVecObjects of all dictionaries found in the PDF file.
- * 
- *  The PdfWriter class contrary creates a PdfVecObjects internally
- *  and writes it to a PDF file later with an appropriate table of 
- *  contents.
- *
- *  These class contains also advanced funtions for searching of PdfObject's
- *  in a PdfVecObject. 
- */
-class PODOFO_API PdfVecObjects {
-    friend class PdfWriter;
-
- public:
-    // An incomplete set of container typedefs, just enough to handle
-    // the begin() and end() methods we wrap from the internal vector.
-    // TODO: proper wrapper iterator class.
-    typedef TVecObjects::iterator iterator;
-    typedef TVecObjects::const_iterator const_iterator;
-
-    /** Every observer of PdfVecObjects has to implement this interface.
-     */
-    class PODOFO_API Observer {
-        friend class PdfVecObjects;
-
-    public:
-        virtual ~Observer()
-            {
-            }
-
-        virtual void WriteObject( const PdfObject* pObject ) = 0;
-            
-        /**
-         * This method is called when the observed PdfVecObjects is delted. 
-         *
-         * No more method may be called on the observable
-         * after this method was called on the observer.
-         */
-        virtual void ParentDestructed() = 0;
-        
-        /** Called whenever appending to a stream is started.
-         *  \param pStream the stream object the user currently writes to.
-         */
-        virtual void BeginAppendStream( const PdfStream* pStream ) = 0;
-
-        /** Called whenever appending to a stream has ended.
-         *  \param pStream the stream object the user currently writes to.
-         */
-        virtual void EndAppendStream( const PdfStream* pStream ) = 0;
-
-        virtual void Finish() = 0;
-    };
-
-    /** This class is used to implement stream factories in PoDoFo.
-     */
-    class PODOFO_API StreamFactory {
-    public:
-        virtual ~StreamFactory()
-            {
-            }
-        
-        /** Creates a stream object
-         *
-         *  \param pParent parent object
-         *
-         *  \returns a new stream object 
-         */
-        virtual PdfStream* CreateStream( PdfObject* pParent ) = 0;
-    };
-
- private:
-    typedef std::vector<Observer*>        TVecObservers;
-    typedef TVecObservers::iterator       TIVecObservers;
-    typedef TVecObservers::const_iterator TCIVecObservers;
-
- public:
-    /** Default constuctor 
-     */
-    PdfVecObjects();
-
-    virtual ~PdfVecObjects();
-
-    /** \returns a pointer to a PdfDocument that is the 
-     *           parent of this vector.
-     *           Might be NULL if the vector has no parent.
-     */
-    inline PdfDocument* GetParentDocument() const;
-
-    /** Sets a parent document of this vector
-     *  \param pDocument the parent of this vector
-     */
-    inline void SetParentDocument( PdfDocument* pDocument );
-
-    /** Enable/disable auto deletion.
-     *  By default auto deletion is disabled.
-     *
-     *  \param bAutoDelete if true all objects will be deleted when the PdfVecObjects is 
-     *         deleted.
-     */
-    inline void SetAutoDelete( bool bAutoDelete );
-
-    /** 
-     *  \returns if autodeletion is enabled and all objects will be deleted when the PdfVecObjects is 
-     *           deleted.
-     */
-    inline bool AutoDelete() const;
-
-    /** Removes all objects from the vector
-     *  and resets it to the default state.
-     *
-     *  If SetAutoDelete is true all objects are deleted.
-     *  All observers are removed from the vector.
-     *
-     *  \see SetAutoDelete
-     *  \see AutoDelete
-     */
-    void Clear();
-
-    /** 
-     *  \returns the size of the internal vector
-     */
-    inline size_t GetSize() const;
-
-    /**
-     *  \returns the highest object number in the vector 
-     */
-    size_t GetObjectCount() const { return m_nObjectCount; }
-
-    /** Finds the object with the given reference in m_vecOffsets 
-     *  and returns a pointer to it if it is found.
-     *  \param ref the object to be found
-     *  \returns the found object or NULL if no object was found.
-     */
-    PdfObject* GetObject( const PdfReference & ref ) const;
-
-    /** Finds the object with the given reference in m_vecOffsets 
-     *  and returns the index to it.
-     *  \param ref the object to be found
-     *  \returns the found object or NULL if no object was found.
-     */
-    size_t GetIndex( const PdfReference & ref ) const;
-
-    /** Remove the object with the given object and generation number from the list
-     *  of objects.
-     *  The object is returned if it was found. Otherwise NULL is returned.
-     *  The caller has to delete the object by hisself.
-     *
-     *  \param ref the object to be found
-     *  \param bMarkAsFree if true the removed object reference is marked as free object
-     *                     you will always want to have this true
-     *                     as invalid PDF files can be generated otherwise
-     *  \returns The removed object.
-     */
-    PdfObject* RemoveObject( const PdfReference & ref, bool bMarkAsFree = true );
-
-    /** Remove the object with the iterator it from the vector and return it
-     *  \param it the object to remove
-     *  \returns the removed object
-     */
-    PdfObject* RemoveObject( const TIVecObjects & it );
-
-    /** Creates a new object and inserts it into the vector.
-     *  This function assigns the next free object number to the PdfObject.
-     *
-     *  \param pszType optionall value of the /Type key of the object
-     *  \returns PdfObject pointer to the new PdfObject
-     */
-    PdfObject* CreateObject( const char* pszType = NULL );
-
-    /** Creates a new object (of type rVariants) and inserts it into the vector.
-     *  This function assigns the next free object number to the PdfObject.
-     *
-     *  \param rVariant value of the PdfObject
-     *  \returns PdfObject pointer to the new PdfObject
-     */
-    PdfObject* CreateObject( const PdfVariant & rVariant );
-
-    /** Mark a reference as unused so that it can be reused for new objects.
-     *  \param rReference the reference to reuse
-     */
-    void AddFreeObject( const PdfReference & rReference );
-
-    /** \returns a list of free references in this vector
-     */
-    inline const TPdfReferenceList & GetFreeObjects() const;
-
-    /** 
-     *  Renumbers all objects according to there current position in the vector.
-     *  All references remain intact.
-     *  Warning! This function is _very_ calculation intensive.
-     *
-     *  \param pTrailer the trailer object
-     *  \param pNotDelete a list of object which must not be deleted
-     *  \param bDoGarbageCollection enable garbage collection, which deletes
-     *         all objects that are not reachable from the trailer. This might be slow!
-     *
-     *  \see CollectGarbage
-     */
-    void RenumberObjects( PdfObject* pTrailer, TPdfReferenceSet* pNotDelete = NULL, bool bDoGarbageCollection = false );
-
-    /** 
-     * \see insert_sorted
-     *
-     * Simple forward to insert sorted, as PdfVecObjects is always sorted.
-     */
-    void push_back( PdfObject* pObj );
-
-    /** Insert an object into this vector so that
-     *  the vector remains sorted w.r.t. 
-     *  the ordering based on object and generation numbers
-     *  m_bObjectCount will be increased for the object.
-     * 
-     *  \param pObj pointer to the object you want to insert
-     */
-    void insert_sorted( PdfObject *pObj );
-    
-
-    /** 
-     * Sort the objects in the vector based on their object and generation numbers
-     */
-    void Sort();
-
-    /** 
-     * Causes the internal vector to reserve space for size elements.
-     * \param size reserve space for that much elements in the internal vector
-     */
-    inline void Reserve( size_t size );
-
-    /** Get a set with all references of objects that the passed object
-     *  depends on.
-     *  \param pObj the object to calculate all dependencies for
-     *  \param pList write the list of dependencies to this list
-     *     
-     */
-    void GetObjectDependencies( const PdfObject* pObj, TPdfReferenceList* pList ) const;
-
-
-    /** Attach a new observer
-     *  \param pObserver to attach
-     */
-    inline void Attach( Observer* pObserver );
-    
-    /** Detach an observer.
-     *
-     *  \param pObserver observer to detach
-     */
-    void Detach( Observer* pObserver );
-
-    /** Sets a StreamFactory which is used whenever CreateStream is called.
-     *  
-     *  \param pFactory a stream factory or NULL to reset to the default factory
-     */
-    inline void SetStreamFactory( StreamFactory* pFactory );
-
-    /** Creates a stream object
-     *  This method is a factory for PdfStream objects.
-     *
-     *  \param pParent parent object
-     *
-     *  \returns a new stream object 
-     */
-    PdfStream* CreateStream( PdfObject* pParent );
-
-    /** Creates a stream object by copying an existing stream
-     *
-     *  \param rhs copy this stream
-     *
-     *  \returns a new stream object 
-     */
-    PdfStream* CreateStream( const PdfStream & rhs );
-
-    /** Can be called to force objects to be written to disk.
-     * 
-     *  \param pObject a PdfObject that should be written to disk.
-     */
-    void WriteObject( PdfObject* pObject );
-
-    /** Call whenever a document is finished
-     */
-    void Finish();
-
-    /** Every stream implementation has to call this in BeginAppend
-     *  \param pStream the stream object that is calling
-     */
-    void BeginAppendStream( const PdfStream* pStream );
-    
-    /** Every stream implementation has to call this in EndAppend
-     *  \param pStream the stream object that is calling
-     */
-    void EndAppendStream( const PdfStream* pStream );
-
-    /** Iterator pointing at the begining of the vector
-     *  \returns beginning iterator
-     */
-    inline TIVecObjects begin();
-
-    /** Iterator pointing at the begining of the vector
-     *  \returns beginning iterator
-     */
-    inline TCIVecObjects begin() const;
-
-    /** Iterator pointing at the end of the vector
-     *  \returns ending iterator
-     */
-    inline TIVecObjects end();
-
-    /** Iterator pointing at the end of the vector
-     *  \returns ending iterator
-     */
-    inline TCIVecObjects end() const;
-
-    inline PdfObject*& operator[](size_t index);
-
-    /** Get the last object in the vector
-     *  \returns the last object in the vector or NULL 
-     *           if the vector is emtpy.
-     */
-    inline PdfObject* GetBack();
-
-    /**
-     * Deletes all objects that are not references by other objects
-     * besides the trailer (which references the root dictionary, which in 
-     * turn should reference all other objects).
-     *
-     * \param pTrailer trailer object of the PDF
-     *
-     * Warning this might be slow!
-     */
-    void CollectGarbage( PdfObject* pTrailer );
-
-	/** Get next unique subset-prefix
-     *
-     *  \returns a string to use as subset-prefix.
-     */
-	std::string GetNextSubsetPrefix();
-
-
- private:    
-    /** 
-     * \returns the next free object reference
-     */
-    PdfReference GetNextFreeObject();
-
-    /** 
-     * Create a list of all references that point to the object
-     * for each object in this vector.
-     * \param pList write all references to this list
-     */
-    void BuildReferenceCountVector( TVecReferencePointerList* pList );
-    void InsertReferencesIntoVector( const PdfObject* pObj, TVecReferencePointerList* pList );
-
-    /** Assumes that the PdfVecObjects is sorted
-     */
-    void InsertOneReferenceIntoVector( const PdfObject* pObj, TVecReferencePointerList* pList );
-
-    /** Delete all objects from the vector which do not have references to them selves
-     *  \param pList must be a list created by BuildReferenceCountVector
-     *  \param pTrailer must be the trailer object so that it is not deleted
-     *  \param pNotDelete a list of object which must not be deleted
-     *  \see BuildReferenceCountVector
-     */
-    void GarbageCollection( TVecReferencePointerList* pList, PdfObject* pTrailer, TPdfReferenceSet* pNotDelete = NULL );
-
-    /**
-     * Set the object count so that the object described this reference
-     * is contained in the object count.
-     *
-     * \param rRef reference of newly added object
-     */
-    void SetObjectCount( const PdfReference & rRef );
-
- private:
-    bool                m_bAutoDelete;
-    size_t              m_nObjectCount;
-    bool                m_bSorted;
-    TVecObjects         m_vector;
-
-
-    TVecObservers       m_vecObservers;
-    TPdfReferenceList   m_lstFreeObjects;
-
-    PdfDocument*        m_pDocument;
-
-    StreamFactory*      m_pStreamFactory;
-
-	std::string			m_sSubsetPrefix;		 ///< Prefix for BaseFont and FontName of subsetted font
-};
-
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline size_t PdfVecObjects::GetSize() const
-{
-    return m_vector.size();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVecObjects::Reserve( size_t size )
-{
-    m_vector.reserve( size );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline PdfDocument* PdfVecObjects::GetParentDocument() const
-{
-    return m_pDocument;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVecObjects::SetParentDocument( PdfDocument* pDocument )
-{
-    m_pDocument = pDocument;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVecObjects::SetAutoDelete( bool bAutoDelete ) 
-{
-    m_bAutoDelete = bAutoDelete;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline bool PdfVecObjects::AutoDelete() const
-{
-    return m_bAutoDelete;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline const TPdfReferenceList & PdfVecObjects::GetFreeObjects() const
-{
-    return m_lstFreeObjects;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVecObjects::Attach( Observer* pObserver )
-{
-    m_vecObservers.push_back( pObserver );
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVecObjects::SetStreamFactory( StreamFactory* pFactory )
-{
-    m_pStreamFactory = pFactory;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline TIVecObjects PdfVecObjects::begin()
-{
-    return m_vector.begin();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline TCIVecObjects PdfVecObjects::begin() const
-{
-    return m_vector.begin();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline TIVecObjects PdfVecObjects::end()
-{
-    return m_vector.end();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline TCIVecObjects PdfVecObjects::end() const
-{
-    return m_vector.end();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline PdfObject* PdfVecObjects::GetBack() 
-{ 
-    return m_vector.back(); 
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline void PdfVecObjects::SetObjectCount( const PdfReference & rRef ) 
-{
-    if( rRef.ObjectNumber() >= m_nObjectCount )
-    // Peter Petrov 18 September 2008
-    {
-        // This was a bug.
-        //++m_nObjectCount;
-
-        // In fact "m_bObjectCount" is used for the next free object number.
-        // We need to use the greatest object number + 1 for the next free object number.
-        // Otherwise, object number overlap would have occurred.
-        m_nObjectCount = rRef.ObjectNumber() + 1;
-    }
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-inline PdfObject*& PdfVecObjects::operator[](size_t index) { return m_vector[index]; }
-
-//inline PdfObject const * & PdfVecObjects::operator[](int index) const { return m_vector[index]; }
-
-
-
-};
-
-#endif // _PDF_VEC_OBJECTS_H_
--- src/base/PdfXRef.cpp.orig	2011-01-21 14:36:59.000000000 +0000
+++ src/base/PdfXRef.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,339 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfXRef.h"
-
-#include "PdfOutputDevice.h"
-#include "PdfDefinesPrivate.h"
-
-#include <algorithm>
-
-namespace PoDoFo {
-
-
-bool PdfXRef::PdfXRefBlock::InsertItem( const TXRefItem & rItem, bool bUsed )
-{
-    if( rItem.reference.ObjectNumber() == m_nFirst + m_nCount ) 
-    {
-        // Insert at back
-        m_nCount++;
-
-        if( bUsed ) 
-            items.push_back( rItem );
-        else
-            freeItems.push_back( rItem.reference );
-
-        return true; // no sorting required
-    }
-    else if( rItem.reference.ObjectNumber() ==  m_nFirst - 1 )
-    {
-        // Insert at front 
-        m_nFirst--;
-        m_nCount++;
-        
-        // This is known to be slow, but should not occur actually
-        if( bUsed ) 
-            items.insert( items.begin(), rItem );
-        else
-            freeItems.insert( freeItems.begin(), rItem.reference );
-
-        return true; // no sorting required
-    }
-    else if( rItem.reference.ObjectNumber() > m_nFirst - 1 &&
-             rItem.reference.ObjectNumber() < m_nFirst + m_nCount ) 
-    {
-        // Insert at back
-        m_nCount++;
-
-        if( bUsed ) 
-        {
-            items.push_back( rItem );
-            std::sort( items.begin(), items.end() );
-        }
-        else
-        {
-            freeItems.push_back( rItem.reference );
-            std::sort( freeItems.begin(), freeItems.end() );
-        }
-
-        return true;
-    }
-
-    return false;
-}
-
-PdfXRef::PdfXRef() 
-{
-
-}
-
-PdfXRef::~PdfXRef() 
-{
-
-}
-
-void PdfXRef::AddObject( const PdfReference & rRef, pdf_uint64 offset, bool bUsed )
-{
-    TIVecXRefBlock     it = m_vecBlocks.begin();
-    PdfXRef::TXRefItem item( rRef, offset );
-    bool               bInsertDone = false;
-
-    while( it != m_vecBlocks.end() )
-    {
-        if( (*it).InsertItem( item, bUsed ) )
-        {
-            bInsertDone = true;
-            break;
-        }
-
-        ++it;
-    }
-
-    if( !bInsertDone ) 
-    {
-        PdfXRefBlock block;
-        block.m_nFirst = rRef.ObjectNumber();
-        block.m_nCount = 1;
-        if( bUsed )
-            block.items.push_back( item );
-        else
-            block.freeItems.push_back( rRef );
-
-        m_vecBlocks.push_back( block );
-        std::sort( m_vecBlocks.begin(), m_vecBlocks.end() );
-    }
-}
-
-void PdfXRef::Write( PdfOutputDevice* pDevice )
-{
-    PdfXRef::TCIVecXRefBlock  it         = m_vecBlocks.begin();
-    PdfXRef::TCIVecXRefItems  itItems;
-    PdfXRef::TCIVecReferences itFree;
-    const PdfReference*       pNextFree  = NULL;
-
-    pdf_objnum nFirst = 0;
-    pdf_uint32 nCount = 0;
-
-    MergeBlocks();
-
-    m_offset = pDevice->Tell();
-    this->BeginWrite( pDevice );
-    while( it != m_vecBlocks.end() )
-    {
-        nCount       = (*it).m_nCount;
-        nFirst       = (*it).m_nFirst;
-        itFree       = (*it).freeItems.begin();
-        itItems      = (*it).items.begin();
-
-        if( nFirst == 1 )
-        {
-            --nFirst;
-            ++nCount;
-        }
-
-        // when there is only one, then we need to start with 0 and the bogus object...
-        this->WriteSubSection( pDevice, nFirst, nCount );
-
-        if( !nFirst ) 
-        {
-            const PdfReference* pFirstFree = this->GetFirstFreeObject( it, itFree );
-            this->WriteXRefEntry( pDevice, pFirstFree ? pFirstFree->ObjectNumber() : 0, EMPTY_OBJECT_OFFSET, 'f' );
-        }
-
-        while( itItems != (*it).items.end() )
-        {
-            // check if there is a free object at the current position
-            while( itFree != (*it).freeItems.end() &&
-                   *itFree < (*itItems).reference )
-            {
-                pdf_gennum nGen  = (*itFree).GenerationNumber();
-
-                // get a pointer to the next free object
-                pNextFree = this->GetNextFreeObject( it, itFree );
-                
-                // write free object
-                this->WriteXRefEntry( pDevice, pNextFree ? pNextFree->ObjectNumber() : 0, nGen, 'f' );
-                ++itFree;
-            }
-
-            this->WriteXRefEntry( pDevice, (*itItems).offset, (*itItems).reference.GenerationNumber(), 'n', 
-                                  (*itItems).reference.ObjectNumber()  );
-            ++itItems;
-        }
-
-        // Check if there are any free objects left!
-        while( itFree != (*it).freeItems.end() )
-        {
-            pdf_gennum nGen  = (*itFree).GenerationNumber();
-            
-            // get a pointer to the next free object
-            pNextFree = this->GetNextFreeObject( it, itFree );
-            
-            // write free object
-            this->WriteXRefEntry( pDevice, pNextFree ? pNextFree->ObjectNumber() : 0, nGen, 'f' );
-            ++itFree;
-        }
-
-        ++it;
-    }
-
-    this->EndWrite( pDevice );
-}
-
-const PdfReference* PdfXRef::GetFirstFreeObject( PdfXRef::TCIVecXRefBlock itBlock, PdfXRef::TCIVecReferences itFree ) const 
-{
-    const PdfReference* pRef      = NULL;
-
-    // find the next free object
-    while( itBlock != m_vecBlocks.end() )
-    {
-        if( itFree != (*itBlock).freeItems.end() )
-            break; // got a free object
-        
-        ++itBlock;
-        if(itBlock != m_vecBlocks.end())
-            itFree = (*itBlock).freeItems.begin();
-    }
-
-    // if there is another free object, return it
-    if( itBlock != m_vecBlocks.end() &&
-        itFree != (*itBlock).freeItems.end() )
-    {
-        pRef = &(*itFree);
-                
-        return pRef;
-    }
-
-    return pRef;
-}
-
-const PdfReference* PdfXRef::GetNextFreeObject( PdfXRef::TCIVecXRefBlock itBlock, PdfXRef::TCIVecReferences itFree ) const 
-{
-    const PdfReference* pRef      = NULL;
-
-    // check if itFree points to a valid free object at the moment
-    if( itFree != (*itBlock).freeItems.end() )
-        ++itFree; // we currently have a free object, so go to the next one
-
-    // find the next free object
-    while( itBlock != m_vecBlocks.end() )
-    {
-        if( itFree != (*itBlock).freeItems.end() )
-            break; // got a free object
-        
-        ++itBlock;
-        if( itBlock != m_vecBlocks.end() )
-            itFree = (*itBlock).freeItems.begin();
-    }
-
-    // if there is another free object, return it
-    if( itBlock != m_vecBlocks.end() &&
-        itFree != (*itBlock).freeItems.end() )
-    {
-        pRef = &(*itFree);
-                
-        return pRef;
-    }
-
-    return pRef;
-}
-
-pdf_uint32 PdfXRef::GetSize() const
-{
-
-    pdf_uint32 nCount = 0;
-    PdfXRef::TCIVecXRefBlock  it = m_vecBlocks.begin();
-
-    while( it != m_vecBlocks.end() )
-    {
-        nCount += (*it).m_nCount;
-        ++it;
-    }
-    
-    //return nCount;
-    if( !m_vecBlocks.size() )
-        return 0;
-
-    const PdfXRefBlock& lastBlock = m_vecBlocks.back();
-    pdf_objnum highObj  = lastBlock.items.size() ? lastBlock.items.back().reference.ObjectNumber() : 0;
-    pdf_objnum highFree = lastBlock.freeItems.size() ? lastBlock.freeItems.back().ObjectNumber() : 0;
-
-    pdf_uint32 max = PDF_MAX( highObj, highFree );
-
-    // From the PdfReference: /Size's value is 1 greater than the highes object number used in the file.
-    return max+1;
-}
-
-void PdfXRef::MergeBlocks() 
-{
-    PdfXRef::TIVecXRefBlock  it     = m_vecBlocks.begin();
-    PdfXRef::TIVecXRefBlock  itNext = it+1;
-
-    // Do not crash in case we have no blocks at all
-    if( it == m_vecBlocks.end() )
-    {
-	PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-    while( itNext != m_vecBlocks.end() )
-    {
-        if( (*itNext).m_nFirst == (*it).m_nFirst + (*it).m_nCount ) 
-        {
-            // merge the two 
-            (*it).m_nCount += (*itNext).m_nCount;
-
-            (*it).items.reserve( (*it).items.size() + (*itNext).items.size() );
-            (*it).items.insert( (*it).items.end(), (*itNext).items.begin(), (*itNext).items.end() );
-
-            (*it).freeItems.reserve( (*it).freeItems.size() + (*itNext).freeItems.size() );
-            (*it).freeItems.insert( (*it).freeItems.end(), (*itNext).freeItems.begin(), (*itNext).freeItems.end() );
-
-            itNext = m_vecBlocks.erase( itNext );
-            it     = itNext - 1;
-        }
-        else
-            it = itNext++;
-    }
-}
-
-void PdfXRef::BeginWrite( PdfOutputDevice* pDevice ) 
-{
-    pDevice->Print( "xref\n" );
-}
-
-void PdfXRef::WriteSubSection( PdfOutputDevice* pDevice, pdf_objnum nFirst, pdf_uint32 nCount )
-{
-#ifdef DEBUG
-    PdfError::DebugMessage("Writing XRef section: %u %u\n", nFirst, nCount );
-#endif // DEBUG
-    pDevice->Print( "%u %u\n", nFirst, nCount );
-}
-
-void PdfXRef::WriteXRefEntry( PdfOutputDevice* pDevice, pdf_uint64 offset, 
-                              pdf_gennum generation, char cMode, pdf_objnum ) 
-{
-    pDevice->Print( "%0.10" PDF_FORMAT_UINT64 " %0.5hu %c \n", offset, generation, cMode );
-}
-
-void PdfXRef::EndWrite( PdfOutputDevice* ) 
-{
-}
-
-};
--- src/base/PdfXRefStreamParserObject.cpp.orig	2024-06-29 17:32:05.093339773 +0000
+++ src/base/PdfXRefStreamParserObject.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,251 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2009 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfXRefStreamParserObject.h"
-
-#include "PdfArray.h"
-#include "PdfDictionary.h"
-#include "PdfStream.h"
-#include "PdfVariant.h"
-
-#include <stdio.h>
-
-namespace PoDoFo {
-
-PdfXRefStreamParserObject::PdfXRefStreamParserObject(PdfVecObjects* pCreator, const PdfRefCountedInputDevice & rDevice, 
-                                                     const PdfRefCountedBuffer & rBuffer, PdfParser::TVecOffsets* pOffsets )
-    : PdfParserObject( pCreator, rDevice, rBuffer ), m_lNextOffset(-1L), m_pOffsets( pOffsets )
-{
-
-}
-
-PdfXRefStreamParserObject::~PdfXRefStreamParserObject() 
-{
-
-}
-
-void PdfXRefStreamParserObject::Parse()
-{
-    // Ignore the encryption in the XREF as the XREF stream must no be encrypted (see PDF Reference 3.4.7)
-    this->ParseFile( NULL );
-
-    // Do some very basic error checking
-    if( !this->GetDictionary().HasKey( PdfName::KeyType ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    } 
-
-    PdfObject* pObj = this->GetDictionary().GetKey( PdfName::KeyType );
-    if( !pObj->IsName() || ( pObj->GetName() != "XRef" ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-    if( !this->GetDictionary().HasKey( PdfName::KeySize ) 
-        || !this->GetDictionary().HasKey( "W" ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    } 
-
-    if( !this->HasStreamToParse() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-    if( this->GetDictionary().HasKey("Prev") )
-    {
-        m_lNextOffset = static_cast<pdf_long>(this->GetDictionary().GetKeyAsLong( "Prev", 0 ));
-    }
-}
-
-void PdfXRefStreamParserObject::ReadXRefTable() 
-{
-    long long  lSize   = this->GetDictionary().GetKeyAsLong( PdfName::KeySize, 0 );
-    PdfVariant vWArray = *(this->GetDictionary().GetKey( "W" ));
-
-    // The pdf reference states that W is always an array with 3 entries
-    // all of them have to be integers
-    if( !vWArray.IsArray() || vWArray.GetArray().size() != 3 )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-
-
-    pdf_int64 nW[W_ARRAY_SIZE] = { 0, 0, 0 };
-    for( int i=0;i<W_ARRAY_SIZE;i++ )
-    {
-        if( !vWArray.GetArray()[i].IsNumber() )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-        }
-
-        nW[i] = static_cast<pdf_int64>(vWArray.GetArray()[i].GetNumber());
-    }
-
-    std::vector<pdf_int64> vecIndeces;
-    GetIndeces( vecIndeces, static_cast<pdf_int64>(lSize) );
-
-    ParseStream( nW, vecIndeces );
-}
-
-void PdfXRefStreamParserObject::ParseStream( const pdf_int64 nW[W_ARRAY_SIZE], const std::vector<pdf_int64> & rvecIndeces )
-{
-    char*        pBuffer;
-    pdf_long     lBufferLen;
-    const size_t entryLen  = static_cast<size_t>(nW[0] + nW[1] + nW[2]);
-
-    if( nW[0] + nW[1] + nW[2] < 0 )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_NoXRef, "Invalid entry length in XRef stream" );
-    }
-
-    this->GetStream()->GetFilteredCopy( &pBuffer, &lBufferLen );
-
-    
-    std::vector<pdf_int64>::const_iterator it = rvecIndeces.begin();
-    char* const pStart = pBuffer;
-    while( it != rvecIndeces.end() )
-    {
-        pdf_int64 nFirstObj = *it; ++it;
-        pdf_int64 nCount    = *it; ++it;
-
-        //pdf_int64 nFirstObjOrg = nFirstObj;
-        //pdf_int64 nCountOrg = nCount;
-        
-        //printf("\n");
-        //printf("nFirstObj=%i\n", static_cast<int>(nFirstObj));
-        //printf("nCount=%i\n", static_cast<int>(nCount));
-        while( nCount > 0 )
-        {
-            if( (pBuffer - pStart) >= lBufferLen ) 
-            {
-                PODOFO_RAISE_ERROR_INFO( ePdfError_NoXRef, "Invalid count in XRef stream" );
-            }
-
-            //printf("nCount=%i ", static_cast<int>(nCount));
-            //printf("pBuffer=%li ", (long)(pBuffer - pStart));
-            //printf("pEnd=%li ", lBufferLen);
-            if ( nFirstObj >= 0 && nFirstObj < m_pOffsets->size() 
-                 && ! (*m_pOffsets)[static_cast<int>(nFirstObj)].bParsed)
-            {
-				ReadXRefStreamEntry( pBuffer, lBufferLen, nW, static_cast<int>(nFirstObj) );
-            }
-
-			nFirstObj++ ;
-            pBuffer += entryLen;
-            --nCount;
-        }
-        //printf("Exp: nFirstObj=%i nFirstObjOrg + nCount=%i\n", nFirstObj - 1, nFirstObjOrg + nCountOrg - 1 );
-        //printf("===\n");
-    }
-    podofo_free( pStart );
-
-}
-
-void PdfXRefStreamParserObject::GetIndeces( std::vector<pdf_int64> & rvecIndeces, pdf_int64 size ) 
-{
-    // get the first object number in this crossref stream.
-    // it is not required to have an index key though.
-    if( this->GetDictionary().HasKey( "Index" ) )
-    {
-        PdfVariant array = *(this->GetDictionary().GetKey( "Index" ));
-        if( !array.IsArray() )
-        {
-            PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-        }
-
-        TCIVariantList it = array.GetArray().begin();
-        while ( it != array.GetArray().end() )
-        {
-            rvecIndeces.push_back( (*it).GetNumber() );
-            ++it;
-        }
-    }
-    else
-    {
-        // Default
-        rvecIndeces.push_back( static_cast<pdf_int64>(0) );
-        rvecIndeces.push_back( size );
-    }
-
-    // vecIndeces must be a multiple of 2
-    if( rvecIndeces.size() % 2 != 0)
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoXRef );
-    }
-}
-
-void PdfXRefStreamParserObject::ReadXRefStreamEntry( char* pBuffer, pdf_long, const pdf_int64 lW[W_ARRAY_SIZE], int nObjNo )
-{
-    int              i;
-    pdf_int64        z;
-    unsigned long    nData[W_ARRAY_SIZE];
-
-    for( i=0;i<W_ARRAY_SIZE;i++ )
-    {
-        if( lW[i] > W_MAX_BYTES )
-        {
-            PdfError::LogMessage( eLogSeverity_Error, 
-                                  "The XRef stream dictionary has an entry in /W of size %i.\nThe maximum supported value is %i.\n", 
-                                  lW[i], W_MAX_BYTES );
-
-            PODOFO_RAISE_ERROR( ePdfError_InvalidXRefStream );
-        }
-        
-        nData[i] = 0;
-        for( z=W_MAX_BYTES-lW[i];z<W_MAX_BYTES;z++ )
-        {
-            nData[i] = (nData[i] << 8) + static_cast<unsigned char>(*pBuffer);
-            ++pBuffer;
-        }
-    }
-
-
-    //printf("OBJ=%i nData = [ %i %i %i ]\n", nObjNo, static_cast<int>(nData[0]), static_cast<int>(nData[1]), static_cast<int>(nData[2]) );
-    (*m_pOffsets)[nObjNo].bParsed = true;
-    switch( nData[0] ) // nData[0] contains the type information of this entry
-    {
-        case 0:
-            // a free object
-            (*m_pOffsets)[nObjNo].lOffset     = nData[1];
-            (*m_pOffsets)[nObjNo].lGeneration = nData[2];
-            (*m_pOffsets)[nObjNo].cUsed       = 'f';
-            break;
-        case 1:
-            // normal uncompressed object
-            (*m_pOffsets)[nObjNo].lOffset     = nData[1];
-            (*m_pOffsets)[nObjNo].lGeneration = nData[2];
-            (*m_pOffsets)[nObjNo].cUsed       = 'n';
-            break;
-        case 2:
-            // object that is part of an object stream
-            (*m_pOffsets)[nObjNo].lOffset     = nData[2]; // index in the object stream
-            (*m_pOffsets)[nObjNo].lGeneration = nData[1]; // object number of the stream
-            (*m_pOffsets)[nObjNo].cUsed       = 's';      // mark as stream
-            break;
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidXRefType );
-        }
-    }
-    //printf("m_offsets = [ %i %i %c ]\n", (*m_pOffsets)[nObjNo].lOffset, (*m_pOffsets)[nObjNo].lGeneration, (*m_pOffsets)[nObjNo].cUsed );
-}
-
-};
--- src/base/util/PdfMutexWrapper.h.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/base/util/PdfMutexWrapper.h.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,92 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#ifndef _PDF_MUTEX_WRAPPER_H_
-#define _PDF_MUTEX_WRAPPER_H_
-
-#include "../PdfDefines.h"
-#include "PdfMutex.h"
-
-namespace PoDoFo {
-namespace Util {
-
-/** 
- * A wrapper around PdfMutex.
- * The mutex is locked in the constructor
- * and unlocked in the destructor.
- * 
- * In debug builds all exceptions thrown by the mutex implementation
- * are caught and logged before being rethrown.
- *  
- * Note that PdfMutexWrapper is *not* part of PoDoFo's public API.
- */
-class PdfMutexWrapper {
-  public:
-    /** Lock a mutex.
-     * 
-     *  \param rMutex the mutex to be locked.
-     */
-    PODOFO_NOTHROW inline PdfMutexWrapper( PdfMutex & rMutex );
-
-    /** Unlocks the mutex on destruction
-     */
-    inline ~PdfMutexWrapper();
-
-  private:
-    /** default constructor, not implemented
-     */
-    PdfMutexWrapper(void);
-    /** copy constructor, not implemented
-     */
-    PdfMutexWrapper(const PdfMutexWrapper& rhs);
-    /** assignment operator, not implemented
-     */
-    PdfMutexWrapper& operator=(const PdfMutexWrapper& rhs);
-
-    PdfMutex& m_rMutex;
-};
-
-PdfMutexWrapper::PdfMutexWrapper( PdfMutex & rMutex )
-    : m_rMutex( rMutex )
-{
-    m_rMutex.Lock();
-}
-
-
-PdfMutexWrapper::~PdfMutexWrapper()
-{
-#if defined(DEBUG)
-    try {
-	m_rMutex.UnLock();
-    }
-    catch( const PdfError & rError ) 
-    {
-	rError.PrintErrorMsg();
-        throw rError;
-    }
-#else
-    m_rMutex.UnLock();
-#endif
-}
-
-}; // Util
-}; // PoDoFo
-
-#endif // _PDF_MUTEX_H_
--- src/doc/PdfDocument.cpp.orig	2024-06-29 17:32:05.023340090 +0000
+++ src/doc/PdfDocument.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,788 +0,0 @@
-/***************************************************************************
-*   Copyright (C) 2006 by Dominik Seichter                                *
-*   domseichter@web.de                                                    *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License as       *
-*   published by the Free Software Foundation; either version 2 of the    *
-*   License, or (at your option) any later version.                       *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200
-#pragma warning(disable: 4786)
-#endif
-
-#include <algorithm>
-#include <deque>
-#include <iostream>
-
-
-#include "PdfDocument.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfImmediateWriter.h"
-#include "base/PdfObject.h"
-#include "base/PdfStream.h"
-#include "base/PdfVecObjects.h"
-
-#include "PdfDestination.h"
-#include "PdfFileSpec.h"
-#include "PdfFont.h"
-#include "PdfFontMetrics.h"
-#include "PdfInfo.h"
-#include "PdfMemDocument.h"
-#include "PdfNamesTree.h"
-#include "PdfOutlines.h"
-#include "PdfPage.h"
-#include "PdfPagesTree.h"
-#include "PdfXObject.h"
-
-
-using namespace std;
-
-namespace PoDoFo {
-
-PdfDocument::PdfDocument()
-    : m_fontCache( &m_vecObjects ), m_pOutlines( NULL ), 
-      m_pNamesTree( NULL ), m_pPagesTree( NULL ), 
-      m_pAcroForms( NULL )
-{
-    m_vecObjects.SetParentDocument( this );
-
-    m_pTrailer = new PdfObject(); // The trailer is NO part of the vector of objects
-    m_pTrailer->SetOwner( &m_vecObjects );
-    m_pCatalog = m_vecObjects.CreateObject( "Catalog" );
-
-    m_pInfo = new PdfInfo( &m_vecObjects );
-
-    m_pTrailer->GetDictionary().AddKey( "Root", m_pCatalog->Reference() );
-    m_pTrailer->GetDictionary().AddKey( "Info", m_pInfo->GetObject()->Reference() );
-
-    InitPagesTree();
-}
-
-PdfDocument::~PdfDocument()
-{
-    this->Clear();
-}
-
-void PdfDocument::Clear() 
-{
-    TIVecObjects     it     = m_vecObjects.begin();
-
-    m_fontCache.EmptyCache();
-
-    while( it != m_vecObjects.end() )
-    {
-        delete (*it);
-        ++it;
-    }
-
-    m_vecObjects.Clear();
-    m_vecObjects.SetParentDocument( this );
-
-    if( m_pInfo ) 
-    {
-        delete m_pInfo;
-        m_pInfo = NULL;
-    }
-
-    if( m_pNamesTree ) 
-    {
-        delete m_pNamesTree;
-        m_pNamesTree = NULL;
-    }
-
-    if( m_pPagesTree ) 
-    {
-        delete m_pPagesTree;
-        m_pPagesTree = NULL;
-    }
-
-    if( m_pOutlines ) 
-    {
-        delete m_pOutlines;
-        m_pOutlines = NULL;
-    }
-
-    if( m_pAcroForms ) 
-    {
-        delete m_pAcroForms;
-        m_pAcroForms = NULL;
-    }
-
-    if( m_pTrailer ) 
-    {
-        delete m_pTrailer;
-        m_pTrailer = NULL;
-    }
-
-    m_pCatalog = NULL;
-}
-
-void PdfDocument::InitPagesTree()
-{
-    PdfObject* pagesRootObj = this->GetCatalog()->GetIndirectKey( PdfName( "Pages" ) );
-    if ( pagesRootObj ) 
-    {
-        m_pPagesTree = new PdfPagesTree( pagesRootObj );
-    }
-    else
-    {
-        m_pPagesTree = new PdfPagesTree( &m_vecObjects );
-        m_pCatalog->GetDictionary().AddKey( "Pages", m_pPagesTree->GetObject()->Reference() );
-    }
-}
-
-PdfObject* PdfDocument::GetNamedObjectFromCatalog( const char* pszName ) const 
-{
-    return m_pCatalog->GetIndirectKey( PdfName( pszName ) );
-}
-
-int PdfDocument::GetPageCount() const
-{
-    return m_pPagesTree->GetTotalNumberOfPages();
-}
-
-PdfPage* PdfDocument::GetPage( int nIndex ) const
-{
-    if( nIndex < 0 || nIndex >= m_pPagesTree->GetTotalNumberOfPages() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_PageNotFound );
-    }
-
-    return m_pPagesTree->GetPage( nIndex );
-}
-
-PdfFont* PdfDocument::CreateFont( const char* pszFontName,                                   
-                                  const PdfEncoding * const pEncoding, 
-                                  PdfFontCache::EFontCreationFlags eFontCreationFlags, 
-                                  bool bEmbedd )
-{
-    return m_fontCache.GetFont( pszFontName, false, false, bEmbedd, eFontCreationFlags, pEncoding );
-}
-
-PdfFont* PdfDocument::CreateFont( const char* pszFontName, bool bBold, bool bItalic, 
-                                  const PdfEncoding * const pEncoding, 
-                                  PdfFontCache::EFontCreationFlags eFontCreationFlags,
-                                  bool bEmbedd, const char* pszFileName )
-{
-    return m_fontCache.GetFont( pszFontName, bBold, bItalic, bEmbedd, eFontCreationFlags, pEncoding, pszFileName );
-}
-
-#ifdef _WIN32
-PdfFont* PdfDocument::CreateFont( const wchar_t* pszFontName, const PdfEncoding * const pEncoding, 
-                                  bool bEmbedd )
-{
-    return m_fontCache.GetFont( pszFontName, false, false, bEmbedd, pEncoding );
-}
-
-PdfFont* PdfDocument::CreateFont( const wchar_t* pszFontName, bool bBold, bool bItalic, 
-                                  const PdfEncoding * const pEncoding, bool bEmbedd )
-{
-    return m_fontCache.GetFont( pszFontName, bBold, bItalic, bEmbedd, pEncoding );
-}
-#endif // _WIN32
-
-PdfFont* PdfDocument::CreateFontSubset( const char* pszFontName, bool bBold, bool bItalic, 
-					                    const PdfEncoding * const pEncoding, const char* pszFileName )
-{
-    return m_fontCache.GetFontSubset( pszFontName, bBold, bItalic, pEncoding, pszFileName );
-}
-
-#ifdef _WIN32
-PdfFont* PdfDocument::CreateFontSubset( const wchar_t* pszFontName, bool bBold, bool bItalic, 
-					                    const PdfEncoding * const pEncoding)
-{
-    PODOFO_RAISE_ERROR_INFO( ePdfError_Unknown, "Subsets are not yet implemented for unicode on windows." );
-}
-#endif // _WIN32
-
-PdfFont* PdfDocument::CreateFont( FT_Face face, const PdfEncoding * const pEncoding, bool bEmbedd )
-{
-    return m_fontCache.GetFont( face, bEmbedd, pEncoding );
-}
-
-PdfFont* PdfDocument::CreateDuplicateFontType1( PdfFont * pFont, const char * pszSuffix )
-{
-	return m_fontCache.GetDuplicateFontType1( pFont, pszSuffix );
-}
-
-PdfPage* PdfDocument::CreatePage( const PdfRect & rSize )
-{
-    return m_pPagesTree->CreatePage( rSize );
-}
-
-void PdfDocument::CreatePages( const std::vector<PdfRect>& vecSizes )
-{
-    m_pPagesTree->CreatePages( vecSizes );
-}
-
-void PdfDocument::EmbedSubsetFonts()
-{
-	m_fontCache.EmbedSubsetFonts();
-}
-
-const PdfDocument & PdfDocument::Append( const PdfMemDocument & rDoc, bool bAppendAll )
-{
-    unsigned int difference = static_cast<unsigned int>(m_vecObjects.GetSize() + m_vecObjects.GetFreeObjects().size());
-
-
-    // Ulrich Arnold 30.7.2009: Because GetNextObject uses m_nObjectCount instead 
-    //                          of m_vecObjects.GetSize()+m_vecObjects.GetFreeObjects().size()+1
-    //                          make sure the free objects are already present before appending to
-	//                          prevent overlapping obj-numbers
-
-    // create all free objects again, to have a clean free object list
-    TCIPdfReferenceList itFree = rDoc.GetObjects().GetFreeObjects().begin();
-    while( itFree != rDoc.GetObjects().GetFreeObjects().end() )
-    {
-        m_vecObjects.AddFreeObject( PdfReference( (*itFree).ObjectNumber() + difference, (*itFree).GenerationNumber() ) );
-
-        ++itFree;
-    }
-
-	// append all objects first and fix their references
-    TCIVecObjects it           = rDoc.GetObjects().begin();
-    while( it != rDoc.GetObjects().end() )
-    {
-        PdfObject* pObj = new PdfObject( PdfReference( 
-                                             static_cast<unsigned int>((*it)->Reference().ObjectNumber() + difference), (*it)->Reference().GenerationNumber() ), *(*it) );
-        m_vecObjects.push_back( pObj );
-
-        if( (*it)->IsDictionary() && (*it)->HasStream() )
-            *(pObj->GetStream()) = *((*it)->GetStream());
-
-        PdfError::LogMessage( eLogSeverity_Information,
-                              "Fixing references in %i %i R by %i\n", pObj->Reference().ObjectNumber(), pObj->Reference().GenerationNumber(), difference );
-        FixObjectReferences( pObj, difference );
-
-        ++it;
-    }
-
-    if( bAppendAll )
-    {
-        const PdfName inheritableAttributes[] = {
-            PdfName("Resources"),
-            PdfName("MediaBox"),
-            PdfName("CropBox"),
-            PdfName("Rotate"),
-            PdfName::KeyNull
-        };
-
-        // append all pages now to our page tree
-        for(int i=0;i<rDoc.GetPageCount();i++ )
-        {
-            PdfPage*      pPage = rDoc.GetPage( i );
-            PdfObject*    pObj  = m_vecObjects.GetObject( PdfReference( pPage->GetObject()->Reference().ObjectNumber() + difference, pPage->GetObject()->Reference().GenerationNumber() ) );
-            if( pObj->IsDictionary() && pObj->GetDictionary().HasKey( "Parent" ) )
-                pObj->GetDictionary().RemoveKey( "Parent" );
-
-            // Deal with inherited attributes
-            const PdfName* pInherited = inheritableAttributes;
-            while( pInherited->GetLength() != 0 ) 
-            {
-                const PdfObject* pAttribute = pPage->GetInheritedKey( *pInherited ); 
-                if( pAttribute )
-                {
-                    PdfObject attribute( *pAttribute );
-                    FixObjectReferences( &attribute, difference );
-                    pObj->GetDictionary().AddKey( *pInherited, attribute );
-                }
-
-                ++pInherited;
-            }
-
-            m_pPagesTree->InsertPage( this->GetPageCount()-1, pObj );
-        }
-        
-        // append all outlines
-        PdfOutlineItem* pRoot       = this->GetOutlines();
-        PdfOutlines*    pAppendRoot = const_cast<PdfMemDocument&>(rDoc).GetOutlines( PoDoFo::ePdfDontCreateObject );
-        if( pAppendRoot && pAppendRoot->First() ) 
-        {
-            // only append outlines if appended document has outlines
-            while( pRoot && pRoot->Next() ) 
-                pRoot = pRoot->Next();
-            
-            PdfReference ref( pAppendRoot->First()->GetObject()->Reference().ObjectNumber() + difference, pAppendRoot->First()->GetObject()->Reference().GenerationNumber() );
-            pRoot->InsertChild( new PdfOutlines( m_vecObjects.GetObject( ref ) ) );
-        }
-    }
-    
-    // TODO: merge name trees
-    // ToDictionary -> then iteratate over all keys and add them to the new one
-    return *this;
-}
-
-PdfRect PdfDocument::FillXObjectFromDocumentPage( PdfXObject * pXObj, const PdfMemDocument & rDoc, int nPage, bool bUseTrimBox )
-{
-    unsigned int difference = static_cast<unsigned int>(m_vecObjects.GetSize() + m_vecObjects.GetFreeObjects().size());
-    Append( rDoc, false );
-    PdfPage* pPage = rDoc.GetPage( nPage );
-
-    return FillXObjectFromPage( pXObj, pPage, bUseTrimBox, difference );
-}
-
-PdfRect PdfDocument::FillXObjectFromExistingPage( PdfXObject * pXObj, int nPage, bool bUseTrimBox )
-{
-    PdfPage* pPage = GetPage( nPage );
-
-    return FillXObjectFromPage( pXObj, pPage, bUseTrimBox, 0 );
-}
-
-PdfRect PdfDocument::FillXObjectFromPage( PdfXObject * pXObj, const PdfPage * pPage, bool bUseTrimBox, unsigned int difference )
-{
-    // TODO: remove unused objects: page, ...
-
-    PdfObject*    pObj  = m_vecObjects.GetObject( PdfReference( pPage->GetObject()->Reference().ObjectNumber() + difference, pPage->GetObject()->Reference().GenerationNumber() ) );
-    PdfRect       box  = pPage->GetMediaBox();
-
-    // intersect with crop-box
-    box.Intersect( pPage->GetCropBox() );
-
-    // intersect with trim-box according to parameter
-    if ( bUseTrimBox )
-        box.Intersect( pPage->GetTrimBox() );
-
-    // link resources from external doc to x-object
-    if( pObj->IsDictionary() && pObj->GetDictionary().HasKey( "Resources" ) )
-        pXObj->GetContentsForAppending()->GetDictionary().AddKey( "Resources" , pObj->GetDictionary().GetKey( "Resources" ) );
-
-    // copy top-level content from external doc to x-object
-    if( pObj->IsDictionary() && pObj->GetDictionary().HasKey( "Contents" ) )
-    {
-        // get direct pointer to contents
-        PdfObject* pContents;
-        if( pObj->GetDictionary().GetKey( "Contents" )->IsReference() )
-            pContents = m_vecObjects.GetObject( pObj->GetDictionary().GetKey( "Contents" )->GetReference() );
-        else
-            pContents = pObj->GetDictionary().GetKey( "Contents" );
-
-        if( pContents->IsArray() )
-        {
-            // copy array as one stream to xobject
-            PdfArray pArray = pContents->GetArray();
-
-            PdfObject*  pObj = pXObj->GetContentsForAppending();
-            PdfStream*  pObjStream = pObj->GetStream();
-
-            TVecFilters vFilters;
-            vFilters.push_back( ePdfFilter_FlateDecode );
-            pObjStream->BeginAppend( vFilters );
-
-            TIVariantList it;
-            for(it = pArray.begin(); it != pArray.end(); it++)
-            {
-                if ( it->IsReference() )
-                {
-                    // TODO: not very efficient !!
-                    PdfObject*  pObj = GetObjects()->GetObject( it->GetReference() );
-
-                    while (pObj!=NULL)
-                    {
-                        if (pObj->IsReference())    // Recursively look for the stream
-                        {
-                            pObj = GetObjects()->GetObject( pObj->GetReference() );
-                        }
-                        else if (pObj->HasStream())
-                        {
-                            PdfStream*  pcontStream = pObj->GetStream();
-
-                            char*       pcontStreamBuffer;
-                            pdf_long    pcontStreamLength;
-                            pcontStream->GetFilteredCopy( &pcontStreamBuffer, &pcontStreamLength );
-    
-                            pObjStream->Append( pcontStreamBuffer, pcontStreamLength );
-                            free( pcontStreamBuffer );
-                            break;
-                        }
-                        else
-                        {
-                            PODOFO_RAISE_ERROR( ePdfError_InvalidStream );
-                            break;
-                        }
-                    }
-                }
-                else
-                {
-                    string str;
-                    it->ToString( str );
-                    pObjStream->Append( str );
-                    pObjStream->Append( " " );
-                }
-            }
-            pObjStream->EndAppend();
-        }
-        else if( pContents->HasStream() )
-        {
-            // copy stream to xobject
-            PdfObject*  pObj = pXObj->GetContentsForAppending();
-            PdfStream*  pObjStream = pObj->GetStream();
-            PdfStream*  pcontStream = pContents->GetStream();
-            char*       pcontStreamBuffer;
-            pdf_long    pcontStreamLength;
-
-            TVecFilters vFilters;
-            vFilters.push_back( ePdfFilter_FlateDecode );
-            pObjStream->BeginAppend( vFilters );
-            pcontStream->GetFilteredCopy( &pcontStreamBuffer, &pcontStreamLength );
-            pObjStream->Append( pcontStreamBuffer, pcontStreamLength );
-            free( pcontStreamBuffer );
-            pObjStream->EndAppend();
-        }
-        else
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-        }
-    }
-
-    return box;
-}
-
-void PdfDocument::FixObjectReferences( PdfObject* pObject, int difference )
-{
-    if( !pObject ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( pObject->IsDictionary() )
-    {
-        TKeyMap::iterator it = pObject->GetDictionary().GetKeys().begin();
-
-        while( it != pObject->GetDictionary().GetKeys().end() )
-        {
-            if( (*it).second->IsReference() )
-            {
-                *(*it).second = PdfReference( (*it).second->GetReference().ObjectNumber() + difference,
-                                              (*it).second->GetReference().GenerationNumber() );
-            }
-            else if( (*it).second->IsDictionary() || 
-                     (*it).second->IsArray() )
-            {
-                FixObjectReferences( (*it).second, difference );
-            }
-
-            ++it;
-        }
-    }
-    else if( pObject->IsArray() )
-    {
-        PdfArray::iterator it = pObject->GetArray().begin();
-
-        while( it != pObject->GetArray().end() )
-        {
-            if( (*it).IsReference() )
-            {
-                (*it) = PdfReference( (*it).GetReference().ObjectNumber() + difference,
-                                      (*it).GetReference().GenerationNumber() );
-
-            }
-            else if( (*it).IsDictionary() || 
-                     (*it).IsArray() )
-                FixObjectReferences( &(*it), difference );
-
-            ++it;
-        }
-    }
-    else if( pObject->IsReference() )
-    {
-        *pObject = PdfReference( pObject->GetReference().ObjectNumber() + difference,
-                                 pObject->GetReference().GenerationNumber() );
-    }
-}
-
-EPdfPageMode PdfDocument::GetPageMode( void ) const
-{
-    // PageMode is optional; the default value is UseNone
-    EPdfPageMode thePageMode = ePdfPageModeUseNone;
-    
-    PdfObject* pageModeObj = GetCatalog()->GetIndirectKey( PdfName( "PageMode" ) );
-    if ( pageModeObj != NULL ) {
-        PdfName pmName = pageModeObj->GetName();
-        
-        if( PdfName( "UseNone" ) == pmName )
-            thePageMode = ePdfPageModeUseNone ;
-        else if( PdfName( "UseThumbs" ) == pmName )
-            thePageMode = ePdfPageModeUseThumbs ;
-        else if( PdfName( "UseOutlines" ) == pmName )
-            thePageMode = ePdfPageModeUseBookmarks ;
-        else if( PdfName( "FullScreen" ) == pmName )
-            thePageMode = ePdfPageModeFullScreen ;
-        else if( PdfName( "UseOC" ) == pmName )
-            thePageMode = ePdfPageModeUseOC ;
-        else if( PdfName( "UseAttachments" ) == pmName )
-            thePageMode = ePdfPageModeUseAttachments ;
-        else
-            PODOFO_RAISE_ERROR( ePdfError_InvalidName );
-    }
-    
-    return thePageMode ;
-}
-
-void PdfDocument::SetPageMode( EPdfPageMode inMode )
-{
-    switch ( inMode ) {
-        default:
-        case ePdfPageModeDontCare:	
-            // GetCatalog()->RemoveKey( PdfName( "PageMode" ) );
-            // this value means leave it alone!
-            break;
-            
-        case ePdfPageModeUseNone:
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageMode" ), PdfName( "UseNone" ) );
-            break;
-            
-        case ePdfPageModeUseThumbs:
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageMode" ), PdfName( "UseThumbs" ) );
-            break;
-            
-        case ePdfPageModeUseBookmarks:
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageMode" ), PdfName( "UseOutlines" ) );
-            break;
-            
-        case ePdfPageModeFullScreen:
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageMode" ), PdfName( "FullScreen" ) );
-            break;
-            
-        case ePdfPageModeUseOC:
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageMode" ), PdfName( "UseOC" ) );
-            break;
-            
-        case ePdfPageModeUseAttachments:
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageMode" ), PdfName( "UseAttachments" ) );
-            break;
-    }
-}
-
-void PdfDocument::SetUseFullScreen( void )
-{
-    // first, we get the current mode
-    EPdfPageMode	curMode = GetPageMode();
-    
-    // if current mode is anything but "don't care", we need to move that to non-full-screen
-    if ( curMode != ePdfPageModeDontCare )
-        SetViewerPreference( PdfName( "NonFullScreenPageMode" ), PdfObject( *(GetCatalog()->GetIndirectKey( PdfName( "PageMode" ) )) ) );
-    
-    SetPageMode( ePdfPageModeFullScreen );
-}
-
-void PdfDocument::SetViewerPreference( const PdfName& whichPref, const PdfObject & valueObj )
-{
-    PdfObject* prefsObj = GetCatalog()->GetIndirectKey( PdfName( "ViewerPreferences" ) );
-    if ( prefsObj == NULL ) {
-        // make me a new one and add it
-        PdfDictionary	vpDict;
-        vpDict.AddKey( whichPref, valueObj );
-        
-        GetCatalog()->GetDictionary().AddKey( PdfName( "ViewerPreferences" ), PdfObject( vpDict ) );
-    } else {
-        // modify the existing one
-        prefsObj->GetDictionary().AddKey( whichPref, valueObj );
-    }
-}
-
-void PdfDocument::SetViewerPreference( const PdfName& whichPref, bool inValue )
-{
-    SetViewerPreference( whichPref, PdfObject( inValue ) );
-}
-
-void PdfDocument::SetHideToolbar( void )
-{
-    SetViewerPreference( PdfName( "HideToolbar" ), true );
-}
-
-void PdfDocument::SetHideMenubar( void )
-{
-    SetViewerPreference( PdfName( "HideMenubar" ), true );
-}
-
-void PdfDocument::SetHideWindowUI( void )
-{
-    SetViewerPreference( PdfName( "HideWindowUI" ), true );
-}
-
-void PdfDocument::SetFitWindow( void )
-{
-    SetViewerPreference( PdfName( "FitWindow" ), true );
-}
-
-void PdfDocument::SetCenterWindow( void )
-{
-    SetViewerPreference( PdfName( "CenterWindow" ), true );
-}
-
-void PdfDocument::SetDisplayDocTitle( void )
-{
-    SetViewerPreference( PdfName( "DisplayDocTitle" ), true );
-}
-
-void PdfDocument::SetPrintScaling( PdfName& inScalingType )
-{
-    SetViewerPreference( PdfName( "PrintScaling" ), inScalingType );
-}
-
-void PdfDocument::SetBaseURI( const std::string& inBaseURI )
-{
-    PdfDictionary	uriDict;
-    uriDict.AddKey( PdfName( "Base" ), new PdfObject( PdfString( inBaseURI ) ) );
-    GetCatalog()->GetDictionary().AddKey( PdfName( "URI" ), new PdfObject( uriDict ) );
-}
-
-void PdfDocument::SetLanguage( const std::string& inLanguage )
-{
-    GetCatalog()->GetDictionary().AddKey( PdfName( "Lang" ), new PdfObject( PdfString( inLanguage ) ) );
-}
-
-void PdfDocument::SetBindingDirection( PdfName& inDirection )
-{
-    SetViewerPreference( PdfName( "Direction" ), inDirection );
-}
-
-void PdfDocument::SetPageLayout( EPdfPageLayout inLayout )
-{
-    switch ( inLayout ) {
-        default:
-        case ePdfPageLayoutIgnore:
-            break;	// means do nothing
-        case ePdfPageLayoutDefault:			
-            GetCatalog()->GetDictionary().RemoveKey( PdfName( "PageLayout" ) );
-            break;
-        case ePdfPageLayoutSinglePage:		
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageLayout" ), PdfName( "SinglePage" ) );
-            break;
-        case ePdfPageLayoutOneColumn:		
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageLayout" ), PdfName( "OneColumn" ) );
-            break;
-        case ePdfPageLayoutTwoColumnLeft:	
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageLayout" ), PdfName( "TwoColumnLeft" ) );
-            break;
-        case ePdfPageLayoutTwoColumnRight: 	
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageLayout" ), PdfName( "TwoColumnRight" ) );
-            break;
-        case ePdfPageLayoutTwoPageLeft: 	
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageLayout" ), PdfName( "TwoPageLeft" ) );
-            break;
-        case ePdfPageLayoutTwoPageRight: 	
-            GetCatalog()->GetDictionary().AddKey( PdfName( "PageLayout" ), PdfName( "TwoPageRight" ) );
-            break;
-    }
-}
-
-PdfOutlines* PdfDocument::GetOutlines( bool bCreate )
-{
-    PdfObject* pObj;
-
-    if( !m_pOutlines )
-    {
-        pObj = GetNamedObjectFromCatalog( "Outlines" );
-        if( !pObj ) 
-        {
-            if ( !bCreate )	return NULL;
-            
-            m_pOutlines = new PdfOutlines( &m_vecObjects );
-            this->GetCatalog()->GetDictionary().AddKey( "Outlines", m_pOutlines->GetObject()->Reference() );
-        } else if ( pObj->GetDataType() != ePdfDataType_Dictionary ) {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-        } else
-            m_pOutlines = new PdfOutlines( pObj );
-    }        
-    
-    return m_pOutlines;
-}
-
-PdfNamesTree* PdfDocument::GetNamesTree( bool bCreate )
-{
-    PdfObject* pObj;
-
-    if( !m_pNamesTree )
-    {
-        pObj = GetNamedObjectFromCatalog( "Names" );
-        if( !pObj ) 
-        {
-            if ( !bCreate )
-                return NULL;
-
-            PdfNamesTree tmpTree ( &m_vecObjects );
-            pObj = tmpTree.GetObject();
-            this->GetCatalog()->GetDictionary().AddKey( "Names", pObj->Reference() );
-            m_pNamesTree = new PdfNamesTree( pObj, this->GetCatalog() );
-        } else if ( pObj->GetDataType() != ePdfDataType_Dictionary ) {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-        } else
-            m_pNamesTree = new PdfNamesTree( pObj, this->GetCatalog() );
-    }        
-    
-    return m_pNamesTree;
-}
-
-PdfAcroForm* PdfDocument::GetAcroForm( bool bCreate, PdfAcroForm::EPdfAcroFormDefaulAppearance eDefaultAppearance )
-{
-    PdfObject* pObj;
-
-    if( !m_pAcroForms )
-    {
-        pObj = GetNamedObjectFromCatalog( "AcroForm" );
-        if( !pObj ) 
-        {
-            if ( !bCreate )	return NULL;
-            
-            m_pAcroForms = new PdfAcroForm( this, eDefaultAppearance );
-            this->GetCatalog()->GetDictionary().AddKey( "AcroForm", m_pAcroForms->GetObject()->Reference() );
-        } else if ( pObj->GetDataType() != ePdfDataType_Dictionary ) {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-        } else
-            m_pAcroForms = new PdfAcroForm( this, pObj, eDefaultAppearance );
-    }        
-    
-    return m_pAcroForms;
-}
-
-void PdfDocument::AddNamedDestination( const PdfDestination& rDest, const PdfString & rName )
-{
-    PdfNamesTree* nameTree = GetNamesTree();
-    nameTree->AddValue( PdfName("Dests"), rName, rDest.GetObject()->Reference() );
-}
-
-void PdfDocument::AttachFile( const PdfFileSpec & rFileSpec )
-{
-    PdfNamesTree* pNames = this->GetNamesTree( true );
-
-    if( !pNames ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pNames->AddValue( "EmbeddedFiles", rFileSpec.GetFilename(), rFileSpec.GetObject()->Reference() );
-}
-
-void PdfDocument::SetInfo( PdfInfo* pInfo )
-{
-    delete m_pInfo;
-    m_pInfo = pInfo;
-}
-
-void PdfDocument::SetTrailer( PdfObject* pObject ) 
-{
-    delete m_pTrailer;
-    m_pTrailer = pObject;
-    // Set owner so that GetIndirectKey will work
-    m_pTrailer->SetOwner( &m_vecObjects );
-}
-
-};
-
--- src/doc/PdfFontCID.cpp.orig	2012-03-07 09:22:07.000000000 +0000
+++ src/doc/PdfFontCID.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,492 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontCID.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfEncoding.h"
-#include "base/PdfLocale.h"
-#include "base/PdfName.h"
-#include "base/PdfStream.h"
-
-#include "PdfFontMetricsFreetype.h"
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#include <sstream>
-
-namespace PoDoFo {
-
-struct TBFRange {
-    int srcCode;
-    std::vector<int> vecDest;
-};
-
-PdfFontCID::PdfFontCID( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, 
-                        PdfVecObjects* pParent, bool bEmbed )
-    : PdfFont( pMetrics, pEncoding, pParent )
-{
-    this->Init( bEmbed );
-}
-
-PdfFontCID::PdfFontCID( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, PdfObject* pObject, bool )
-    : PdfFont( pMetrics, pEncoding, pObject )
-{
-    /* this->Init( bEmbed ); */
-}
-
-void PdfFontCID::Init( bool bEmbed )
-{
-    PdfObject* pDescriptor;
-    PdfObject* pDescendantFonts;
-    PdfObject* pCIDSystemInfo;
-    PdfObject* pUnicode;
-
-    PdfVariant var;
-    PdfArray   array;
-
-    // The descendant font is a CIDFont:
-    pDescendantFonts = this->GetObject()->GetOwner()->CreateObject("Font");
-    pCIDSystemInfo   = this->GetObject()->GetOwner()->CreateObject();
-    pDescriptor      = this->GetObject()->GetOwner()->CreateObject("FontDescriptor");
-    pUnicode         = this->GetObject()->GetOwner()->CreateObject(); // The ToUnicode CMap
-
-    // Now setting each of the entries of the font
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, PdfName("Type0") );
-    this->GetObject()->GetDictionary().AddKey( "BaseFont", this->GetBaseFont() );
-    this->GetObject()->GetDictionary().AddKey( "ToUnicode", pUnicode->Reference() );
-
-    // The encoding is here usually a (Predefined) CMap from PdfIdentityEncoding:
-    m_pEncoding->AddToDictionary( this->GetObject()->GetDictionary() );
-
-    // The DecendantFonts, should be an indirect object:
-    array.push_back( pDescendantFonts->Reference() );
-    this->GetObject()->GetDictionary().AddKey( "DescendantFonts", array );
-
-    // Setting the DescendantFonts paras
-    // This is a type2 CIDFont, which is also known as TrueType:
-    pDescendantFonts->GetDictionary().AddKey( PdfName::KeySubtype, PdfName("CIDFontType2") );
-
-    // Same base font as the owner font:
-    pDescendantFonts->GetDictionary().AddKey( "BaseFont", this->GetBaseFont() );
-
-    // The CIDSystemInfo, should be an indirect object:
-    pDescendantFonts->GetDictionary().AddKey( "CIDSystemInfo", pCIDSystemInfo->Reference() );
-
-    // The FontDescriptor, should be an indirect object:
-    pDescendantFonts->GetDictionary().AddKey( "FontDescriptor", pDescriptor->Reference() );
-    pDescendantFonts->GetDictionary().AddKey( "CIDToGIDMap", PdfName("Identity") );
-
-    // Add the width keys
-    this->CreateWidth( pDescendantFonts );
-
-    // Create the ToUnicode CMap
-    this->CreateCMap( pUnicode );
-
-    // Setting the CIDSystemInfo paras:
-    pCIDSystemInfo->GetDictionary().AddKey( "Registry", PdfString("Adobe") );
-    pCIDSystemInfo->GetDictionary().AddKey( "Ordering", PdfString("Identity") );
-    pCIDSystemInfo->GetDictionary().AddKey( "Supplement", PdfVariant(static_cast<pdf_int64>(0LL)) );
-
-
-    // Setting the FontDescriptor paras:
-    array.Clear();
-    m_pMetrics->GetBoundingBox( array );
-
-    pDescriptor->GetDictionary().AddKey( "FontName", this->GetBaseFont() );
-    pDescriptor->GetDictionary().AddKey( PdfName::KeyFlags, PdfVariant( static_cast<pdf_int64>(32LL) ) ); // TODO: 0 ????
-    pDescriptor->GetDictionary().AddKey( "FontBBox", array );
-    pDescriptor->GetDictionary().AddKey( "ItalicAngle", PdfVariant( static_cast<pdf_int64>(m_pMetrics->GetItalicAngle()) ) );
-    pDescriptor->GetDictionary().AddKey( "Ascent", m_pMetrics->GetPdfAscent() );
-    pDescriptor->GetDictionary().AddKey( "Descent", m_pMetrics->GetPdfDescent() );
-    pDescriptor->GetDictionary().AddKey( "CapHeight", m_pMetrics->GetPdfAscent() ); // m_pMetrics->CapHeight() );
-    pDescriptor->GetDictionary().AddKey( "StemV", PdfVariant( static_cast<pdf_int64>(1LL) ) );               // m_pMetrics->StemV() );
-
-    // Peter Petrov 24 September 2008
-    m_pDescriptor = pDescriptor;
-    
-    if( bEmbed )
-    {
-        this->EmbedFont( pDescriptor );
-        m_bWasEmbedded = true;
-    }
-}
-
-void PdfFontCID::EmbedFont()
-{
-    if (!m_bWasEmbedded)
-    {
-        this->EmbedFont( m_pDescriptor );
-        m_bWasEmbedded = true;
-    }
-}
-
-void PdfFontCID::EmbedFont( PdfObject* pDescriptor )
-{
-    PdfObject* pContents;
-    pdf_long       lSize = 0;
-    
-    m_bWasEmbedded = true;    
-        
-    pContents = this->GetObject()->GetOwner()->CreateObject();
-    if( !pContents )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-        
-    pDescriptor->GetDictionary().AddKey( "FontFile2", pContents->Reference() );
-        
-    // if the data was loaded from memory - use it from there
-    // otherwise, load from disk
-    if ( m_pMetrics->GetFontDataLen() && m_pMetrics->GetFontData() ) 
-    {
-        // FIXME const_cast<char*> is dangerous if string literals may ever be passed
-        char* pBuffer = const_cast<char*>( m_pMetrics->GetFontData() );
-        lSize = m_pMetrics->GetFontDataLen();
-        // Set Length1 before creating the stream
-        // as PdfStreamedDocument does not allow 
-        // adding keys to an object after a stream was written
-        pContents->GetDictionary().AddKey( "Length1", PdfVariant( static_cast<pdf_int64>(lSize) ) );
-            
-        pContents->GetStream()->Set( pBuffer, lSize );
-    } 
-    else 
-    {
-        PdfFileInputStream stream( m_pMetrics->GetFilename() );
-        lSize = stream.GetFileLength();
-
-        // Set Length1 before creating the stream
-        // as PdfStreamedDocument does not allow 
-        // adding keys to an object after a stream was written
-        pContents->GetDictionary().AddKey( "Length1", PdfVariant( static_cast<pdf_int64>(lSize) ) );
-        pContents->GetStream()->Set( &stream );
-    }
-}
-
-void PdfFontCID::CreateWidth( PdfObject* pFontDict ) const
-{
-    const int cAbsoluteMax = 0xffff;
-    int nFirstChar = m_pEncoding->GetFirstChar();
-    int nLastChar  = m_pEncoding->GetLastChar();
-
-    int  i;
-
-    // Allocate an initialize an array, large enough to 
-    // hold a width value for every possible glyph index
-    double* pdWidth = static_cast<double*>(malloc( sizeof(double) * cAbsoluteMax ) );
-    if( !pdWidth )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-
-    for( i=0;i<cAbsoluteMax;i++ )
-        pdWidth[i] = 0.0;
-
-    // Load the width of all requested glyph indeces
-    int nMin       = 0xffff;
-    int nMax       = 0;
-
-    long    lGlyph = 0;
-
-    for( i=nFirstChar;i<=nLastChar;i++ )
-    {
-        lGlyph = m_pMetrics->GetGlyphId( i );
-        if( lGlyph )
-        {
-            nMin = PDF_MIN( static_cast<long>(nMin), lGlyph );
-            nMax = PDF_MAX( static_cast<long>(nMax), lGlyph );
-            nMax = PDF_MIN( nMax, cAbsoluteMax );
-
-            if( lGlyph < cAbsoluteMax )
-                pdWidth[lGlyph] = m_pMetrics->GetGlyphWidth( lGlyph );
-
-        }
-    }
-
-	if (nMax >= nMin) {
-        // Now compact the array
-        std::ostringstream oss;
-        PdfArray array;
-        array.reserve( nMax - nMin + 1 );
-
-        i = nMin;
-        double    dCurWidth  = pdWidth[i];
-        pdf_int64 lCurIndex  = i++;
-        pdf_int64 lCurLength = 1L;
-        
-        for( ;i<=nMax;i++ )
-        {
-            if( static_cast<int>(pdWidth[i] - dCurWidth) == 0 )
-                ++lCurLength;
-            else
-            {
-                if( lCurLength > 1 ) 
-                {
-                    array.push_back( lCurIndex );
-                    pdf_int64 temp = lCurIndex + lCurLength - 1;
-                    array.push_back( temp ); 
-                    array.push_back( dCurWidth ); 
-                }
-                else
-                {
-                    if( array.size() && array.back().IsArray() ) 
-                    {
-                        array.back().GetArray().push_back( dCurWidth );
-                    }
-                    else
-                    {
-                        PdfArray tmp;
-                        tmp.push_back( dCurWidth );
-                        
-                        array.push_back( lCurIndex );
-                        array.push_back( tmp );
-                    }
-                }
-                
-                lCurIndex  = i;
-                lCurLength = 1L;
-                dCurWidth  = pdWidth[i];
-            }
-        }
-
-        if (array.size() == 0) 
-        {
-            array.push_back( lCurIndex = nMin );
-            array.push_back( lCurIndex = nMax );
-            array.push_back( dCurWidth ); 
-        }
-        
-        pFontDict->GetDictionary().AddKey( PdfName("W"), array ); 
-    }
-
-    free( pdWidth );
-}
-
-void PdfFontCID::CreateCMap( PdfObject* pUnicode ) const
-{
-    PdfFontMetricsFreetype* pFreetype = dynamic_cast<PdfFontMetricsFreetype*>(m_pMetrics);
-	if (!pFreetype) return;
-
-    int  nFirstChar = m_pEncoding->GetFirstChar();
-    int  nLastChar  = m_pEncoding->GetLastChar();
-
-    std::ostringstream oss;
-
-    FT_Face   face = pFreetype->GetFace();
-    FT_ULong  charcode;                                              
-    FT_UInt   gindex;                                                
-
-    TBFRange curRange;
-    curRange.srcCode = -1;
-    std::vector<TBFRange> vecRanges;
-    // Only 255 sequent characters are allowed to be in one range!
-    const unsigned int MAX_CHARS_IN_RANGE = 255;
-
-    charcode = FT_Get_First_Char( face, &gindex );                   
-    while ( gindex != 0 )                                            
-    {        
-        if( static_cast<int>(charcode) > nLastChar )
-        {
-            break;
-        }
-        else if( static_cast<int>(charcode) >= nFirstChar )
-        {
-            if( curRange.vecDest.size() == 0 ) 
-            {
-                curRange.srcCode  = gindex;
-                curRange.vecDest.push_back( charcode );
-            }
-            else if( (curRange.srcCode + curRange.vecDest.size() == gindex) && 
-                     ((gindex - curRange.srcCode + curRange.vecDest.size()) < MAX_CHARS_IN_RANGE) )
-            {
-                curRange.vecDest.push_back( charcode );
-            } 
-            else
-            {
-                // Create a new bfrange
-                vecRanges.push_back( curRange );
-                curRange.srcCode = gindex;
-                curRange.vecDest.clear();
-                curRange.vecDest.push_back( charcode );
-            }
-        }
-
-        charcode = FT_Get_Next_Char( face, charcode, &gindex );        
-    }   
-
-    if( curRange.vecDest.size() ) 
-        vecRanges.push_back( curRange );
-
-    // Now transform it into a string
-    // Make sure each bfrange section has a maximum of 
-    // 100 entries. If there are more Acrobat Reader might crash
-    std::ostringstream range;
-    int numberOfEntries = 0;
-
-    std::vector<TBFRange>::const_iterator it = vecRanges.begin();
-
-    const int BUFFER_LEN = 5;
-    char buffer[BUFFER_LEN]; // buffer of the format "XXXX\0"
-    
-    while( it != vecRanges.end() ) 
-    {
-        if( numberOfEntries == 99 ) 
-        {
-            oss << numberOfEntries << " beginbfrange" << std::endl;
-            oss << range.str();
-            oss << "endbfrange" << std::endl;
-
-            numberOfEntries = 0;
-            range.str("");
-        }
-
-        pdf_long iStart = (*it).srcCode;
-        pdf_long iEnd   = (*it).srcCode + (*it).vecDest.size() - 1;
-
-        snprintf( buffer, BUFFER_LEN, "%04X", static_cast<unsigned int>(iStart) );
-        range << "<" << buffer << "> <";
-        snprintf( buffer, BUFFER_LEN, "%04X", static_cast<unsigned int>(iEnd) );
-        range << buffer << "> [ ";
-
-        std::vector<int>::const_iterator it2 = (*it).vecDest.begin();
-        while( it2 != (*it).vecDest.end() )
-        {
-            snprintf( buffer, BUFFER_LEN, "%04X", *it2 );
-            range << "<" << buffer << "> ";
-
-            ++it2;
-        }
-
-        range << "]" << std::endl;
-        ++it;
-        ++numberOfEntries;
-    }
-
-    if( numberOfEntries > 0 ) 
-    {
-        oss << numberOfEntries << " beginbfrange" << std::endl;
-        oss << range.str();
-        oss << "endbfrange" << std::endl;
-    }
-
-    /*
-    // Create the beginbfchar section
-    std::ostringstream oss;
-    std::ostringstream tmp;
-    const int BUFFER_LEN = 14;
-    char buffer[BUFFER_LEN]; // buffer of the format "<XXXX> <XXXX>\0"
-    
-    bool bLittle = podofo_is_little_endian();
-    int  nCount  = 1;
-
-    while( nFirstChar <= nLastChar ) 
-    {
-        lGlyph = m_pMetrics->GetGlyphId( nFirstChar );
-        if( lGlyph && lGlyph <= 0xffff)
-        {
-            if( bLittle ) 
-                snprintf( buffer, BUFFER_LEN, "<%04X> <%04X>", static_cast<unsigned int>(lGlyph), 
-                          ((nFirstChar & 0xff00) >> 8) | ((nFirstChar & 0x00ff) << 8) );
-            else
-                snprintf( buffer, BUFFER_LEN, "<%04X> <%04X>", static_cast<unsigned int>(lGlyph), nFirstChar );
-
-            tmp << buffer << std::endl;
-
-            if( nCount % 100 == 0 )
-            {
-                // There can be at maximum 100 lines in a bfchar section
-                oss << nCount - 1 << " beginbfchar" << std::endl << tmp.str() << "endbfchar" << std::endl;
-                tmp.str(""); // clear the stream
-                nCount = 0;
-            }
-
-            ++nCount;
-        }
-        
-        ++nFirstChar;
-    }
-
-    if( nCount > 1 )
-        oss << nCount - 1 << " beginbfchar" << std::endl << tmp.str() << "endbfchar" << std::endl;
-    */
-
-    // Create the CMap
-    pUnicode->GetStream()->BeginAppend();
-    pUnicode->GetStream()->Append("/CIDInit /ProcSet findresource begin\n");
-    pUnicode->GetStream()->Append("10000 dict begin\n");
-    pUnicode->GetStream()->Append("begincmap\n");
-    pUnicode->GetStream()->Append("/CIDSystemInfo\n");
-    pUnicode->GetStream()->Append("<< /Registry (Adobe)\n");
-    pUnicode->GetStream()->Append("/Ordering (UCS)\n");
-    pUnicode->GetStream()->Append("/Supplement 0\n");
-    pUnicode->GetStream()->Append(">> def\n");
-    pUnicode->GetStream()->Append("/CMapName /Adobe-Identity-UCS def\n");
-    pUnicode->GetStream()->Append("/CMapType 2 def\n");
-    pUnicode->GetStream()->Append("1 begincodespacerange\n");
-    pUnicode->GetStream()->Append("<0000> <FFFF>\n");
-    pUnicode->GetStream()->Append("endcodespacerange\n");
-    pUnicode->GetStream()->Append( oss.str().c_str() );
-    pUnicode->GetStream()->Append("endcmap\n");
-    pUnicode->GetStream()->Append("CMapName currentdict /CMap defineresource pop\n");
-    pUnicode->GetStream()->Append("end\n");
-    pUnicode->GetStream()->Append("end\n");
-    pUnicode->GetStream()->EndAppend();
-}
-
-
-/*
-    // Get the string in UTF-16be format
-    PdfString    sStr = rsString.ToUnicode();
-    const pdf_utf16be* pStr = sStr.GetUnicode();
-    long         lGlyphId;
-
-    const bool   bLittle = podofo_is_little_endian();
-
-    std::ostringstream out;
-    PdfLocaleImbue(out);
-
-    out << "<";
-
-    while( *pStr ) 
-    {
-        //printf("Current byte: %04x\n", *pStr );
-        if( bLittle )
-            lGlyphId = m_pMetrics->GetGlyphId( (((*pStr & 0xff) << 8) | ((*pStr & 0xff00) >> 8)) );
-        else
-            lGlyphId = m_pMetrics->GetGlyphId( *pStr );
-
-        out << ToHex( (lGlyphId & 0xf000) >> 12 ) << ToHex( (lGlyphId & 0x0f00) >> 8 );
-        out << ToHex( (lGlyphId & 0xf0) >> 4 ) << ToHex( lGlyphId & 0x0f );
-
-        ++pStr;
-    }
-
-    out << ">";
-
-    pStream->Append( out.str().c_str(), out.str().length() );
-*/
-
-
-};
-
--- src/doc/PdfFontConfigWrapper.cpp.orig	2012-01-22 17:09:07.000000000 +0000
+++ src/doc/PdfFontConfigWrapper.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,109 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontConfigWrapper.h"
-
-#if defined(PODOFO_HAVE_FONTCONFIG)
-#include <fontconfig/fontconfig.h>
-#include "base/util/PdfMutexWrapper.h"
-#endif
-
-namespace PoDoFo {
-
-#if defined(PODOFO_HAVE_FONTCONFIG)
-Util::PdfMutex PdfFontConfigWrapper::m_FcMutex;
-#endif
-
-
-PdfFontConfigWrapper::PdfFontConfigWrapper()
-    : m_pFontConfig( NULL )
-{
-#if defined(PODOFO_HAVE_FONTCONFIG)
-    this->m_pFontConfig = new TRefCountedFontConfig();
-    this->m_pFontConfig->m_lRefCount = 1;
-    this->m_pFontConfig->m_bInitialized = false;
-    this->m_pFontConfig->m_pFcConfig = NULL;
-#endif
-}
-
-PdfFontConfigWrapper::PdfFontConfigWrapper(const PdfFontConfigWrapper & rhs)
-{
-    this->operator=(rhs);
-}
-
-PdfFontConfigWrapper::~PdfFontConfigWrapper()
-{
-    this->DerefBuffer();
-}
-
-const PdfFontConfigWrapper & PdfFontConfigWrapper::operator=(const PdfFontConfigWrapper & rhs)
-{
-    // Self assignment is a no-op
-    if (this == &rhs)
-        return rhs;
-
-    DerefBuffer();
-
-    this->m_pFontConfig = rhs.m_pFontConfig;
-    if( m_pFontConfig )
-    {
-        this->m_pFontConfig->m_lRefCount++;
-    }
-
-    return *this;
-}
-
-
-void PdfFontConfigWrapper::DerefBuffer()
-{
-    if ( m_pFontConfig && !(--m_pFontConfig->m_lRefCount) )
-    {
-#if defined(PODOFO_HAVE_FONTCONFIG)
-        if( this->m_pFontConfig->m_bInitialized )
-        {
-            Util::PdfMutexWrapper mutex(m_FcMutex);
-            FcConfigDestroy( static_cast<FcConfig*>(m_pFontConfig->m_pFcConfig) );
-        }
-#endif
-
-        delete m_pFontConfig;
-    }
-
-    // Whether or not it still exists, we no longer have anything to do with
-    // the buffer we just released our claim on.
-    m_pFontConfig = NULL;
-}
-
-void PdfFontConfigWrapper::InitializeFontConfig() 
-{
-#if defined(PODOFO_HAVE_FONTCONFIG)
-    if( !this->m_pFontConfig->m_bInitialized )
-    {
-        Util::PdfMutexWrapper mutex(m_FcMutex);
-        if( !this->m_pFontConfig->m_bInitialized ) 
-        {
-            this->m_pFontConfig->m_pFcConfig = static_cast<void*>(FcInitLoadConfigAndFonts());
-            this->m_pFontConfig->m_bInitialized = true;
-        }
-    }
-#endif
-}
-
-};
--- src/doc/PdfFontFactory.cpp.orig	2024-06-29 17:32:05.149339520 +0000
+++ src/doc/PdfFontFactory.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,323 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontFactory.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfEncoding.h"
-#include "base/PdfEncodingFactory.h"
-
-#include "PdfEncodingObjectFactory.h"
-#include "PdfFont.h"
-#include "PdfFontCID.h"
-#include "PdfFontMetrics.h"
-#include "PdfFontMetricsBase14.h"
-#include "PdfFontMetricsObject.h"
-#include "PdfFontType1.h"
-#include "PdfFontType1Base14.h"
-#include "PdfFontTrueType.h"
-#include "PdfFontFactoryBase14Data.h"
-
-namespace PoDoFo {
-
-PdfFont* PdfFontFactory::CreateFontObject( PdfFontMetrics* pMetrics, int nFlags, 
-                                           const PdfEncoding* const pEncoding,
-                                           PdfVecObjects* pParent )
-{
-    PdfFont*     pFont  = NULL;
-    EPdfFontType eType  = pMetrics->GetFontType();
-    bool         bEmbed = nFlags & ePdfFont_Embedded;
-    bool         bSubsetting = (nFlags & ePdfFont_Subsetting) != 0;
-
-    try
-    { 
-        pFont = PdfFontFactory::CreateFontForType( eType, pMetrics, pEncoding, bEmbed, bSubsetting, pParent );
-        
-        if( pFont ) 
-        {
-            pFont->SetBold( nFlags & ePdfFont_Bold ? true : false );
-            pFont->SetItalic( nFlags & ePdfFont_Italic ? true : false );
-        }
-        else
-        {
-            // something went wrong, so we have to delete
-            // the font metrics
-            delete pMetrics;
-            // make sure this will be done before the catch block
-            // as the encoding might be deleted already
-            // afterwars, but we cannot set the pointer to NULL
-            if( pEncoding && pEncoding->IsAutoDelete() )
-                delete pEncoding;
-        }
-    }
-    catch( PdfError & e ) 
-    {
-        // we have to delete the pMetrics object in case of error 
-        if( pFont ) 
-        {
-            // The font will delete encoding and metrics
-            delete pFont;
-            pFont = NULL;
-        }
-        else
-        {
-            // something went wrong, so we have to delete
-            // the font metrics (and if auto-delete, also the encoding)
-            delete pMetrics;
-            pMetrics = NULL;
-
-            if( pEncoding && pEncoding->IsAutoDelete() )
-                delete pEncoding;
-        }
-
-        e.AddToCallstack( __FILE__, __LINE__, "Font creation failed." );
-        throw e;
-        
-    }
-    
-    return pFont;
-}
-
-PdfFont* PdfFontFactory::CreateFontForType( EPdfFontType eType, PdfFontMetrics* pMetrics, 
-                                            const PdfEncoding* const pEncoding, 
-                                            bool bEmbed, bool bSubsetting, PdfVecObjects* pParent )
-{
-    PdfFont* pFont = NULL;
-
-    if( pEncoding->IsSingleByteEncoding() ) 
-    {
-        switch( eType ) 
-        {
-            case ePdfFontType_TrueType:
-                // Peter Petrov 30 April 2008 - added bEmbed parameter
-                pFont = new PdfFontTrueType( pMetrics, pEncoding, pParent, bEmbed );
-                break;
-                
-            case ePdfFontType_Type1Pfa:
-            case ePdfFontType_Type1Pfb:
-				if ( bSubsetting )
-				{
-					// don't embed yet for subsetting
-	                pFont = new PdfFontType1( pMetrics, pEncoding, pParent, false, true );
-				}
-				else
-					pFont = new PdfFontType1( pMetrics, pEncoding, pParent, bEmbed );
-                break;
-                
-            case ePdfFontType_Unknown:
-            case ePdfFontType_Type1Base14:
-            default:
-                PdfError::LogMessage( eLogSeverity_Error, "The font format is unknown. Fontname: %s Filename: %s\n", 
-                                      (pMetrics->GetFontname() ? pMetrics->GetFontname() : "<unknown>"),
-                                      (pMetrics->GetFilename() ? pMetrics->GetFilename() : "<unknown>") );
-        }
-    }
-    else
-    {
-        switch( eType ) 
-        {
-            case ePdfFontType_TrueType:
-                // Peter Petrov 30 April 2008 - added bEmbed parameter
-                pFont = new PdfFontCID( pMetrics, pEncoding, pParent, bEmbed );
-                break;
-            case ePdfFontType_Type1Pfa:
-            case ePdfFontType_Type1Pfb:
-            case ePdfFontType_Type1Base14:
-            case ePdfFontType_Unknown:
-            default:
-                PdfError::LogMessage( eLogSeverity_Error, 
-                                      "The font format is unknown or no multibyte encoding defined. Fontname: %s Filename: %s\n", 
-                                      (pMetrics->GetFontname() ? pMetrics->GetFontname() : "<unknown>"),
-                                      (pMetrics->GetFilename() ? pMetrics->GetFilename() : "<unknown>") );
-        }
-    }
-
-    return pFont;
-}
-
-PdfFont* PdfFontFactory::CreateFont( FT_Library*, PdfObject* pObject )
-{
-    PdfFontMetrics* pMetrics    = NULL;
-    PdfFont*        pFont       = NULL;
-    PdfObject*      pDescriptor = NULL;
-    PdfObject*      pEncoding   = NULL;
-
-    if( pObject->GetDictionary().GetKey( PdfName::KeyType )->GetName() != PdfName("Font") )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    PdfVariant* pSubTypeKey = pObject->GetDictionary()
-                            .GetKey( PdfName::KeySubtype );
-    if ( NULL == pSubTypeKey )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidDataType, "Font: No SubType" );
-    }
-    const PdfName & rSubType = pSubTypeKey->GetName();
-    if( rSubType == PdfName("Type0") ) 
-    {
-        // The PDF reference states that DescendantFonts must be an array,
-        // some applications (e.g. MS Word) put the array into an indirect object though.
-        const PdfArray & descendant  = 
-            pObject->GetIndirectKey( "DescendantFonts" )->GetArray();
-        PdfObject* pFontObject = pObject->GetOwner()->GetObject( descendant[0].GetReference() );
-
-        pDescriptor = pFontObject->GetIndirectKey( "FontDescriptor" );
-        pEncoding   = pObject->GetIndirectKey( "Encoding" );
-
-        if ( pEncoding && pDescriptor ) // OC 18.08.2010: Avoid sigsegv
-        {
-           const PdfEncoding* const pPdfEncoding = 
-               PdfEncodingObjectFactory::CreateEncoding( pEncoding );
-
-           // OC 15.08.2010 BugFix: Parameter pFontObject added: TODO: untested
-           pMetrics    = new PdfFontMetricsObject( pFontObject, pDescriptor, pPdfEncoding );
-           pFont       = new PdfFontCID( pMetrics, pPdfEncoding, pObject, false );
-        }
-    }
-    else if( rSubType == PdfName("Type1") ) 
-    {
-        // TODO: Old documents do not have a FontDescriptor for 
-        //       the 14 standard fonts. This suggestions is 
-        //       deprecated now, but give us problems with old documents.
-        pDescriptor = pObject->GetIndirectKey( "FontDescriptor" );
-        pEncoding   = pObject->GetIndirectKey( "Encoding" );
-
-        // OC 13.08.2010: Handle missing FontDescriptor for the 14 standard fonts:
-        if( !pDescriptor )
-        {
-           // Check if its a PdfFontType1Base14
-           PdfObject* pBaseFont = NULL;
-           pBaseFont = pObject->GetIndirectKey( "BaseFont" );
-           const char* pszBaseFontName = pBaseFont->GetName().GetName().c_str();
-           PdfFontMetricsBase14* pMetrics = PODOFO_Base14FontDef_FindBuiltinData(pszBaseFontName);
-           if ( pMetrics != NULL )
-           {
-               // pEncoding may be undefined, found a valid pdf with
-               //   20 0 obj
-               //   <<
-               //   /Type /Font
-               //   /BaseFont /ZapfDingbats
-               //   /Subtype /Type1
-               //   >>
-               //   endobj 
-               // If pEncoding is null then
-               // use StandardEncoding for Courier, Times, Helvetica font families
-               // and special encodings for Symbol and ZapfDingbats
-               const PdfEncoding* pPdfEncoding = NULL;
-               if ( pEncoding!= NULL )
-                   pPdfEncoding = PdfEncodingObjectFactory::CreateEncoding( pEncoding );
-               else if ( !pMetrics->IsSymbol() )
-                   pPdfEncoding = PdfEncodingFactory::GlobalStandardEncodingInstance();
-               else if ( strcmp(pszBaseFontName, "Symbol") == 0 )
-                   pPdfEncoding = PdfEncodingFactory::GlobalSymbolEncodingInstance();
-               else if ( strcmp(pszBaseFontName, "ZapfDingbats") == 0 )
-                   pPdfEncoding = PdfEncodingFactory::GlobalZapfDingbatsEncodingInstance();
-               return new PdfFontType1Base14(pMetrics, pPdfEncoding, pObject);
-           }
-        }
-        const PdfEncoding* pPdfEncoding = NULL;
-        if ( pEncoding != NULL )
-            pPdfEncoding = PdfEncodingObjectFactory::CreateEncoding( pEncoding );
-        else if ( pDescriptor )
-        {
-           // OC 18.08.2010 TODO: Encoding has to be taken from the font's built-in encoding
-           // Its extremely complicated to interpret the type1 font programs
-           // so i try to determine if its a symbolic font by reading the FontDescriptor Flags
-           // Flags & 4 --> Symbolic, Flags & 32 --> Nonsymbolic
-            pdf_int32 lFlags = static_cast<pdf_int32>(pDescriptor->GetDictionary().GetKeyAsLong( "Flags", 0L ));
-            if ( lFlags & 32 ) // Nonsymbolic, otherwise pEncoding remains NULL
-                pPdfEncoding = PdfEncodingFactory::GlobalStandardEncodingInstance();
-        }
-        if ( pPdfEncoding && pDescriptor ) // OC 18.08.2010: Avoid sigsegv
-        {
-            // OC 15.08.2010 BugFix: Parameter pObject added:
-            pMetrics    = new PdfFontMetricsObject( pObject, pDescriptor, pPdfEncoding );
-            pFont       = new PdfFontType1( pMetrics, pPdfEncoding, pObject );
-        }
-    }
-    else if( rSubType == PdfName("TrueType") ) 
-    {
-        pDescriptor = pObject->GetIndirectKey( "FontDescriptor" );
-        pEncoding   = pObject->GetIndirectKey( "Encoding" );
-
-        if ( pEncoding && pDescriptor ) // OC 18.08.2010: Avoid sigsegv
-        {
-           const PdfEncoding* const pPdfEncoding = 
-               PdfEncodingObjectFactory::CreateEncoding( pEncoding );
-
-           // OC 15.08.2010 BugFix: Parameter pObject added:
-           pMetrics    = new PdfFontMetricsObject( pObject, pDescriptor, pPdfEncoding );
-           pFont       = new PdfFontTrueType( pMetrics, pPdfEncoding, pObject );
-        }
-    }
-
-    return pFont;
-}
-
-EPdfFontType PdfFontFactory::GetFontType( const char* pszFilename )
-{
-    EPdfFontType eFontType = ePdfFontType_Unknown;
-
-    // We check by file extension right now
-    // which is not quite correct, but still better than before
-
-    if( pszFilename && strlen( pszFilename ) > 3 )
-    {
-        const char* pszExtension = pszFilename + strlen( pszFilename ) - 3;
-        if( PoDoFo::compat::strncasecmp( pszExtension, "ttf", 3 ) == 0 )
-            eFontType = ePdfFontType_TrueType;
-        else if( PoDoFo::compat::strncasecmp( pszExtension, "pfa", 3 ) == 0 )
-            eFontType = ePdfFontType_Type1Pfa;
-        else if( PoDoFo::compat::strncasecmp( pszExtension, "pfb", 3 ) == 0 )
-            eFontType = ePdfFontType_Type1Pfb;
-    }
-
-    return eFontType;
-}
-
-
-PdfFontMetricsBase14*
-PODOFO_Base14FontDef_FindBuiltinData(const char  *font_name)
-{
-    unsigned int i = 0;
-	bool found = false;
-    while (PODOFO_BUILTIN_FONTS[i].font_name) {
-        if (strcmp(PODOFO_BUILTIN_FONTS[i].font_name, font_name) == 0) // kaushik  : HPDFStrcmp changed to strcmp
-		{
-			found = true;
-			break;
-		}
-
-        i++;
-    }
-
-	return found ? &PODOFO_BUILTIN_FONTS[i] : NULL;
-}
-
-PdfFont* CreateBase14Font(const char* pszFontName, const PdfEncoding * const pEncoding,PdfVecObjects *pvecObjects)
-{
-	return new PdfFontType1Base14(PODOFO_Base14FontDef_FindBuiltinData(pszFontName), pEncoding, pvecObjects);
-}
-
-};
--- src/doc/PdfFontMetricsBase14.cpp.orig	2011-01-17 21:28:51.000000000 +0000
+++ src/doc/PdfFontMetricsBase14.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,261 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontMetricsBase14.h"
-
-#include "base/PdfDefinesPrivate.h"
-#include "base/PdfArray.h"
-
-#include "PdfFontFactoryBase14Data.h"
-
-namespace PoDoFo {
-
-
-PdfFontMetricsBase14::PdfFontMetricsBase14(const char      *mfont_name,
-                                           const PODOFO_CharData  *mwidths_table,
-                                           bool             mis_font_specific,
-                                           pdf_int16            mascent,
-                                           pdf_int16            mdescent,
-                                           pdf_uint16           mx_height,
-                                           pdf_uint16           mcap_height,
-                                           const PdfRect &      mbbox)
-    : PdfFontMetrics( ePdfFontType_Type1Base14, "", NULL),
-      font_name(mfont_name),
-      widths_table(mwidths_table),
-      is_font_specific(mis_font_specific),
-      ascent(mascent), 
-      descent(mdescent),
-      x_height(mx_height), 
-      cap_height(mcap_height), 
-      bbox(mbbox), 
-      m_bSymbol(is_font_specific)
-{			
-    m_nWeight             = 500;
-    m_nItalicAngle        = 0;
-    m_dLineSpacing        = 0.0;
-    m_dUnderlineThickness = 0.0;
-    m_dUnderlinePosition  = 0.0;
-    m_dStrikeOutPosition  = 0.0;
-    m_dStrikeOutThickness = 0.0;
-    units_per_EM          = 1000;
-    m_dPdfAscent          = ascent * 1000 / units_per_EM;
-    m_dPdfDescent         = descent * 1000 / units_per_EM;
-    
-    m_dAscent             = ascent;
-    m_dDescent            = descent;	     
-
-    // calculate the line spacing now, as it changes only with the font size
-    m_dLineSpacing        = (static_cast<double>(ascent + abs(descent)) / units_per_EM);
-    m_dAscent             = static_cast<double>(ascent) /  units_per_EM;
-    m_dDescent            = static_cast<double>(descent) /  units_per_EM;
-    
-    // Set default values for strikeout, in case the font has no direct values
-    m_dStrikeOutPosition  = m_dAscent / 2.0; 
-	//	m_dStrikeOutThickness = m_dUnderlineThickness;
-}
-
-PdfFontMetricsBase14::~PdfFontMetricsBase14()
-{
-}
-
-double PdfFontMetricsBase14::GetGlyphWidth( int nGlyphId ) const 
-{
-    return widths_table[static_cast<unsigned int>(nGlyphId)].width; 
-}
-
-double PdfFontMetricsBase14::GetGlyphWidth( const char* ) const 
-{
-    return 0.0;
-}
-
-double PdfFontMetricsBase14::CharWidth( unsigned char c ) const 
-{
-    double dWidth = widths_table[static_cast<unsigned int>(GetGlyphId(c) )].width;
-    
-    return dWidth * static_cast<double>(this->GetFontSize() * this->GetFontScale() / 100.0) / 1000.0 +
-        static_cast<double>( this->GetFontSize() * this->GetFontScale() / 100.0 * this->GetFontCharSpace() / 100.0);
-}
-
-double PdfFontMetricsBase14::UnicodeCharWidth( unsigned short c ) const 
-{
-    double   dWidth = 0.0;
-    
-    dWidth = widths_table[static_cast<unsigned int>(GetGlyphIdUnicode(c) )].width;
-	
-    return dWidth * static_cast<double>(this->GetFontSize() * this->GetFontScale() / 100.0) / 1000.0 +
-        static_cast<double>( this->GetFontSize() * this->GetFontScale() / 100.0 * this->GetFontCharSpace() / 100.0);
-}
-
-inline double PdfFontMetricsBase14::GetLineSpacing() const 
-{
-    return m_dLineSpacing * this->GetFontSize();
-}
-
-inline double PdfFontMetricsBase14::GetUnderlineThickness() const 
-{
-    return m_dUnderlineThickness * this->GetFontSize();
-}
-
-inline double PdfFontMetricsBase14::GetUnderlinePosition() const 
-{
-    return m_dUnderlinePosition * this->GetFontSize();
-}
-
-inline double PdfFontMetricsBase14::GetStrikeOutPosition() const 
-{
-    return m_dStrikeOutPosition * this->GetFontSize();
-}
-
-inline double PdfFontMetricsBase14::GetStrikeoutThickness() const 
-{
-    return m_dStrikeOutThickness * this->GetFontSize();
-}
-
-const char* PdfFontMetricsBase14::GetFontname() const 
-{
-#ifdef MYASSERT
-    assert(font_name != NULL);
-#endif
-    return font_name;
-}
-
-unsigned int PdfFontMetricsBase14::GetWeight() const 
-{
-    return m_nWeight;
-}
-
-double PdfFontMetricsBase14::GetAscent() const 
-{
-    return m_dAscent * this->GetFontSize();
-}
-
-double PdfFontMetricsBase14::GetPdfAscent() const 
-{
-    return m_dPdfAscent;
-}
-
-double PdfFontMetricsBase14::GetDescent() const 
-{
-    return m_dDescent * this->GetFontSize();
-}
-
-double PdfFontMetricsBase14::GetPdfDescent() const 
-{
-    return m_dPdfDescent;
-}
-
-int PdfFontMetricsBase14::GetItalicAngle() const 
-{
-    return m_nItalicAngle;
-}
-
-long PdfFontMetricsBase14::GetGlyphIdUnicode( long lUnicode ) const
-{
-    long lGlyph = 0;
-    
-    // Handle symbol fonts!
-    /*
-      if( m_bSymbol ) 
-      {
-      lUnicode = lUnicode | 0xf000;
-      }
-    */
-    
-    for(int i = 0; widths_table[i].unicode != 0xFFFF ; ++i)
-    {
-        if (widths_table[i].unicode == lUnicode) 
-        {
-            lGlyph = i; //widths_table[i].char_cd ;
-            break;
-        }
-    }
-    
-    //FT_Get_Char_Index( m_face, lUnicode );
-	
-    return lGlyph;
-}
-
-long PdfFontMetricsBase14::GetGlyphId( long charId ) const
-{
-    long lGlyph = 0;
-    
-    // Handle symbol fonts!
-    /*
-      if( m_bSymbol ) 
-      {
-      charId = charId | 0xf000;
-      }
-    */
-    
-    for(int i = 0; widths_table[i].unicode != 0xFFFF  ; ++i)
-    {
-        if (widths_table[i].char_cd == charId) 
-        {
-            lGlyph = i; //widths_table[i].char_cd ;
-            break;
-        }
-    }
-    
-    //FT_Get_Char_Index( m_face, lUnicode );
-
-    return lGlyph;
-}
-
-inline bool PdfFontMetricsBase14::IsSymbol() const
-{
-    
-    return m_bSymbol;
-}
-
-void PdfFontMetricsBase14::GetBoundingBox( PdfArray & array ) const
-{
-    array.Clear();
-    array.push_back( PdfVariant( bbox.GetLeft() * 1000.0 / units_per_EM ) );
-    array.push_back( PdfVariant( bbox.GetBottom() * 1000.0 / units_per_EM ) );
-    array.push_back( PdfVariant( bbox.GetWidth() * 1000.0 / units_per_EM ) );
-    array.push_back( PdfVariant( bbox.GetHeight() * 1000.0 / units_per_EM ) );
-    
-    return;
-}
-
-void PdfFontMetricsBase14::GetWidthArray( PdfVariant & var, unsigned int nFirst, unsigned int nLast ) const
-{
-    unsigned int i;
-    PdfArray     list;
-    
-    for( i=nFirst;i<=nLast;i++ )
-    {
-		list.push_back( PdfVariant(  double(widths_table[i].width)  ) );
-    }
-    
-    var = PdfVariant( list );
-}
-
-const char* PdfFontMetricsBase14::GetFontData() const
-{
-    return NULL;
-}
-
-pdf_long PdfFontMetricsBase14::GetFontDataLen() const
-{
-    return 0;
-}
-
-};
--- src/doc/PdfFontMetricsObject.cpp.orig	2012-03-07 09:22:07.000000000 +0000
+++ src/doc/PdfFontMetricsObject.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,322 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontMetricsObject.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfDictionary.h"
-#include "base/PdfName.h"
-#include "base/PdfObject.h"
-#include "base/PdfVariant.h"
-
-namespace PoDoFo {
-
-PdfFontMetricsObject::PdfFontMetricsObject( PdfObject* pFont, PdfObject* pDescriptor, const PdfEncoding* const pEncoding )
-    : PdfFontMetrics( ePdfFontType_Unknown, "", NULL ),
-      m_pEncoding( pEncoding ), m_dDefWidth(0.0)
-{
-    if( !pDescriptor )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-	const PdfName & rSubType = pFont->GetDictionary().GetKey( PdfName::KeySubtype )->GetName();
-
-    // OC 15.08.2010 BugFix: /FirstChar /LastChar /Widths are in the Font dictionary and not in the FontDescriptor
-	if ( rSubType == PdfName("Type1") || rSubType == PdfName("TrueType") ) {
-		m_sName        = pDescriptor->GetIndirectKey( "FontName" )->GetName();
-		m_bbox         = pDescriptor->GetIndirectKey( "FontBBox" )->GetArray();
-    m_nFirst       = static_cast<int>(pFont->GetDictionary().GetKeyAsLong( "FirstChar", 0L ));
-    m_nLast        = static_cast<int>(pFont->GetDictionary().GetKeyAsLong( "LastChar", 0L ));
-	 // OC 15.08.2010 BugFix: GetIndirectKey() instead of GetDictionary().GetKey() and "Widths" instead of "Width"
-    PdfObject* widths = pFont->GetIndirectKey( "Widths" );
-    if( widths != NULL )
-    {
-        m_width        = widths->GetArray();
-        m_missingWidth = NULL;
-    }
-    else
-    {
-        widths = pDescriptor->GetDictionary().GetKey( "MissingWidth" );
-        if( widths == NULL ) 
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_NoObject, "Font object defines neither Widths, nor MissingWidth values!" );
-            m_missingWidth = widths;
-        }
-    }
-	} else if ( rSubType == PdfName("CIDFontType0") || rSubType == PdfName("CIDFontType2") ) {
-		PdfObject *pObj = pDescriptor->GetIndirectKey( "FontName" );
-		if (pObj) {
-			m_sName = pObj->GetName();
-		}
-		pObj = pDescriptor->GetIndirectKey( "FontBBox" );
-		if (pObj) {
-			m_bbox = pObj->GetArray();
-		}
-		m_nFirst = 0;
-		m_nLast = 0;
-
-		m_dDefWidth = static_cast<double>(pFont->GetDictionary().GetKeyAsLong( "DW", 1000L ));
-		PdfVariant default_width(m_dDefWidth);
-		PdfObject * pw = pFont->GetIndirectKey( "W" );
-
-		for (int i = m_nFirst; i <= m_nLast; ++i) {
-			m_width.push_back(default_width);
-		}
-		if (pw) {
-			PdfArray w = pw->GetArray();
-			int pos = 0;
-			while (pos < static_cast<int>(w.GetSize())) {
-				int start = static_cast<int>(w[pos++].GetNumber());
-				PODOFO_ASSERT (start >= 0);
-				if (w[pos].IsArray()) {
-					PdfArray widths = w[pos++].GetArray();
-					int length = start + static_cast<int>(widths.GetSize());
-					PODOFO_ASSERT (length >= start);
-					if (length > static_cast<int>(m_width.GetSize())) {
-						m_width.resize(length, default_width);
-					}
-					for (int i = 0; i < static_cast<int>(widths.GetSize()); ++i) {
-						m_width[start + i] = widths[i];
-					}
-				} else {
-					int end = static_cast<int>(w[pos++].GetNumber());
-					int length = start + end;
-					PODOFO_ASSERT (length >= start);
-					if (length > static_cast<int>(m_width.GetSize())) {
-						m_width.resize(length, default_width);
-					}
-					pdf_int64 width = w[pos++].GetNumber();
-					for (int i = start; i <= end; ++i)
-						m_width[i] = PdfVariant(width);
-				}
-			}
-		}
-		m_nLast = m_width.GetSize() - 1;
-	} else {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedFontFormat, rSubType.GetEscapedName().c_str() );
-	}
-
-
-    m_nWeight      = static_cast<unsigned int>(pDescriptor->GetDictionary().GetKeyAsLong( "FontWeight", 400L ));
-    m_nItalicAngle = static_cast<int>(pDescriptor->GetDictionary().GetKeyAsLong( "ItalicAngle", 0L ));
-
-    m_dPdfAscent   = pDescriptor->GetDictionary().GetKeyAsReal( "Ascent", 0.0 );
-    m_dAscent      = m_dPdfAscent / 1000.0;
-    m_dPdfDescent  = pDescriptor->GetDictionary().GetKeyAsReal( "Descent", 0.0 );
-    m_dDescent     = m_dPdfDescent / 1000.0;
-    m_dLineSpacing = m_dAscent + m_dDescent;
-    
-    // Try to fine some sensible values
-    m_dUnderlineThickness = 1.0;
-    m_dUnderlinePosition  = 0.0;
-    m_dStrikeOutThickness = m_dUnderlinePosition;
-    m_dStrikeOutPosition  = m_dAscent / 2.0;
-
-    m_bSymbol = false; // TODO
-}
-
-PdfFontMetricsObject::~PdfFontMetricsObject()
-{
-}
-
-const char* PdfFontMetricsObject::GetFontname() const
-{
-    return m_sName.GetName().c_str();
-}
-
-void PdfFontMetricsObject::GetBoundingBox( PdfArray & array ) const
-{
-    array = m_bbox;
-}
-
-double PdfFontMetricsObject::CharWidth( unsigned char c ) const
-{
-    if( c >= m_nFirst && c <= m_nLast
-        && c - m_nFirst < static_cast<int>(m_width.GetSize()) )
-    { 
-        double dWidth = m_width[c - m_nFirst].GetReal();
-        
-        return dWidth * static_cast<double>(this->GetFontSize() * this->GetFontScale() / 100.0) / 1000.0 +
-            static_cast<double>( this->GetFontSize() * this->GetFontScale() / 100.0 * this->GetFontCharSpace() / 100.0);
-
-    }
-
-    if( m_missingWidth != NULL )
-        return m_missingWidth->GetReal ();
-    else
-        return m_dDefWidth;
-}
-
-double PdfFontMetricsObject::UnicodeCharWidth( unsigned short c ) const
-{
-    if( c >= m_nFirst && c <= m_nLast
-        && c - m_nFirst < static_cast<int>(m_width.GetSize()) )
-    {
-        double dWidth = m_width[c - m_nFirst].GetReal();
-
-        return dWidth * static_cast<double>(this->GetFontSize() * this->GetFontScale() / 100.0) / 1000.0 +
-            static_cast<double>( this->GetFontSize() * this->GetFontScale() / 100.0 * this->GetFontCharSpace() / 100.0);
-
-    }
-
-    if( m_missingWidth != NULL )
-        return m_missingWidth->GetReal ();
-    else
-        return m_dDefWidth;
-}
-
-void PdfFontMetricsObject::GetWidthArray( PdfVariant & var, unsigned int, unsigned int ) const
-{
-    var = m_width;
-}
-
-double PdfFontMetricsObject::GetGlyphWidth( int ) const
-{
-    // TODO
-    return 0.0; // OC 13.08.2010 BugFix: Avoid microsoft compiler error
-}
-
-double PdfFontMetricsObject::GetGlyphWidth( const char* ) const
-{
-    // TODO
-    return 0.0;
-}
-
-long PdfFontMetricsObject::GetGlyphId( long ) const
-{
-    // TODO
-    return 0; // OC 13.08.2010 BugFix: Avoid microsoft compiler error
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetLineSpacing() const
-{
-    return m_dLineSpacing * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetUnderlinePosition() const
-{
-    return m_dUnderlinePosition * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetStrikeOutPosition() const
-{
-	return m_dStrikeOutPosition * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetUnderlineThickness() const
-{
-    return m_dUnderlineThickness * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetStrikeoutThickness() const
-{
-    return m_dStrikeOutThickness * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-const char* PdfFontMetricsObject::GetFontData() const
-{
-    return NULL;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-pdf_long PdfFontMetricsObject::GetFontDataLen() const
-{
-    return 0;
-}  
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-unsigned int PdfFontMetricsObject::GetWeight() const
-{
-    return m_nWeight;
-}  
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetAscent() const
-{
-    return m_dAscent * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetPdfAscent() const
-{
-    return m_dPdfAscent;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetDescent() const
-{
-    return m_dDescent * this->GetFontSize();
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-double PdfFontMetricsObject::GetPdfDescent() const
-{
-    return m_dPdfDescent;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-int PdfFontMetricsObject::GetItalicAngle() const
-{
-    return m_nItalicAngle;
-}
-
-// -----------------------------------------------------
-// 
-// -----------------------------------------------------
-bool PdfFontMetricsObject::IsSymbol() const
-{
-    return m_bSymbol;
-}
-
-};
--- src/doc/PdfFontSimple.cpp.orig	2011-04-19 16:53:06.000000000 +0000
+++ src/doc/PdfFontSimple.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,110 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontSimple.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfEncoding.h"
-#include "base/PdfFilter.h"
-#include "base/PdfName.h"
-#include "base/PdfStream.h"
-
-namespace PoDoFo {
-
-PdfFontSimple::PdfFontSimple( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, PdfVecObjects* pParent )
-    : PdfFont( pMetrics, pEncoding, pParent )
-{
-}
-
-PdfFontSimple::PdfFontSimple( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, PdfObject* pObject )
-    : PdfFont( pMetrics, pEncoding, pObject )
-{
-}
-
-void PdfFontSimple::Init( bool bEmbed, const PdfName & rsSubType )
-{
-    PdfObject*    pWidth;
-    PdfObject*    pDescriptor;
-    PdfVariant    var;
-    PdfArray      array;
-
-    pWidth = this->GetObject()->GetOwner()->CreateObject();
-    if( !pWidth )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_pMetrics->GetWidthArray( *pWidth, m_pEncoding->GetFirstChar(), m_pEncoding->GetLastChar() );
-
-    pDescriptor = this->GetObject()->GetOwner()->CreateObject( "FontDescriptor" );
-    if( !pDescriptor )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-	std::string name;
-	if ( m_bIsSubsetting )
-		name = this->GetObject()->GetOwner()->GetNextSubsetPrefix();
-	name += this->GetBaseFont().GetName();
-
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, rsSubType );
-    this->GetObject()->GetDictionary().AddKey("BaseFont", PdfName( name ) );
-    this->GetObject()->GetDictionary().AddKey("FirstChar", PdfVariant( static_cast<pdf_int64>(m_pEncoding->GetFirstChar()) ) );
-    this->GetObject()->GetDictionary().AddKey("LastChar", PdfVariant( static_cast<pdf_int64>(m_pEncoding->GetLastChar()) ) );
-    m_pEncoding->AddToDictionary( this->GetObject()->GetDictionary() ); // Add encoding key
-
-    this->GetObject()->GetDictionary().AddKey("Widths", pWidth->Reference() );
-    this->GetObject()->GetDictionary().AddKey( "FontDescriptor", pDescriptor->Reference() );
-
-    m_pMetrics->GetBoundingBox( array );
-
-    pDescriptor->GetDictionary().AddKey( "FontName", PdfName( name ) );
-    //pDescriptor->GetDictionary().AddKey( "FontWeight", (long)m_pMetrics->Weight() );
-    pDescriptor->GetDictionary().AddKey( PdfName::KeyFlags, PdfVariant( static_cast<pdf_int64>(32LL) ) ); // TODO: 0 ????
-    pDescriptor->GetDictionary().AddKey( "FontBBox", array );
-    pDescriptor->GetDictionary().AddKey( "ItalicAngle", PdfVariant( static_cast<pdf_int64>(m_pMetrics->GetItalicAngle()) ) );
-    pDescriptor->GetDictionary().AddKey( "Ascent", m_pMetrics->GetPdfAscent() );
-    pDescriptor->GetDictionary().AddKey( "Descent", m_pMetrics->GetPdfDescent() );
-    pDescriptor->GetDictionary().AddKey( "CapHeight", m_pMetrics->GetPdfAscent() ); // m_pMetrics->CapHeight() );
-    pDescriptor->GetDictionary().AddKey( "StemV", PdfVariant( static_cast<pdf_int64>(1LL) ) );               // m_pMetrics->StemV() );
-
-    // Peter Petrov 24 September 2008
-    m_pDescriptor = pDescriptor;
-
-    if( bEmbed )
-    {
-        this->EmbedFontFile( pDescriptor );
-        m_bWasEmbedded = true;
-    }
-}
-
-void PdfFontSimple::EmbedFont()
-{
-    if (!m_bWasEmbedded)
-    {
-        this->EmbedFontFile( m_pDescriptor );
-        m_bWasEmbedded = true;
-    }
-}
-
-};
--- src/doc/PdfFontType1Base14.cpp.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/doc/PdfFontType1Base14.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,91 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2010 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontType1Base14.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfDictionary.h"
-#include "base/PdfEncoding.h"
-
-namespace PoDoFo {
-
-PdfFontType1Base14::PdfFontType1Base14( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, 
-                                        PdfVecObjects* pParent )
-    : PdfFontSimple( pMetrics, pEncoding, pParent )
-{
-    InitBase14Font();
-}
-
-// OC 13.08.2010 New:
-PdfFontType1Base14::PdfFontType1Base14( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, 
-                                        PdfObject* pObject )
-    : PdfFontSimple( pMetrics, pEncoding, pObject )
-{
-    InitBase14Font();
-}
-
-PdfFontType1Base14::~PdfFontType1Base14()
-{
-    // FontMetrics of base14 fonts may not be deleted
-    m_pMetrics = NULL;
-}
-
-/*
-kausik : April 12th 2010
-This is the font dictionary. It gets added to the page resources dictionary of the pdf.
-*/
-void PdfFontType1Base14::InitBase14Font( )
-{
-    PdfVariant    var;
-    
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, PdfName("Type1"));
-    this->GetObject()->GetDictionary().AddKey("BaseFont", this->GetBaseFont() );
-		 
-    m_pEncoding->AddToDictionary( this->GetObject()->GetDictionary() ); // Add encoding key
-//	pDescriptor->GetDictionary().AddKey( "FontName", this->GetBaseFont() );
-    //pDescriptor->GetDictionary().AddKey( "FontWeight", (long)m_pMetrics->Weight() );
-//		pDescriptor->GetDictionary().AddKey( PdfName::KeyFlags, PdfVariant( static_cast<pdf_int64>(32LL) ) ); // TODO: 0 ????
-//		pDescriptor->GetDictionary().AddKey( "FontBBox", array );
-	
-    
-	
-		
-//			pDescriptor->GetDictionary().AddKey( "ItalicAngle", PdfVariant( static_cast<pdf_int64>(m_pMetrics->GetItalicAngle()) ) );
-//			pDescriptor->GetDictionary().AddKey( "Ascent", m_pMetrics->GetPdfAscent() );
-//			pDescriptor->GetDictionary().AddKey( "Descent", m_pMetrics->GetPdfDescent() );
-//			pDescriptor->GetDictionary().AddKey( "CapHeight", m_pMetrics->GetPdfAscent() ); // m_pMetrics->CapHeight() );
-		 
-
-//		pDescriptor->GetDictionary().AddKey( "StemV", PdfVariant( static_cast<pdf_int64>(1LL) ) );               // m_pMetrics->StemV() );
-
-		// Peter Petrov 24 September 2008
-//		m_pDescriptor = pDescriptor;
-
-		 
-}
-
-void PdfFontType1Base14::EmbedFontFile( PdfObject* )
-{
-    // Do nothing, base 14 fonts do not need to be embedded
-}
-
-
-};
--- src/doc/PdfFontType1.cpp.orig	2011-04-27 07:25:21.000000000 +0000
+++ src/doc/PdfFontType1.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,696 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfFontType1.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfName.h"
-#include "base/PdfStream.h"
-
-#include "PdfDifferenceEncoding.h"
-
-#include <stdlib.h>
-
-namespace PoDoFo {
-
-PdfFontType1::PdfFontType1( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, 
-                            PdfVecObjects* pParent, bool bEmbed, bool bSubsetting )
-    : PdfFontSimple( pMetrics, pEncoding, pParent )
-{
-	memset( m_bUsed, 0, sizeof( m_bUsed ) );
-	m_bIsSubsetting = bSubsetting;
-    this->Init( bEmbed, PdfName("Type1") );
-}
-
-
-PdfFontType1::PdfFontType1( PdfFontMetrics* pMetrics, const PdfEncoding* const pEncoding, 
-                            PdfObject* pObject )
-    : PdfFontSimple( pMetrics, pEncoding, pObject )
-{
-	memset( m_bUsed, 0, sizeof( m_bUsed ) );
-}
-
-PdfFontType1::PdfFontType1( PdfFontType1* pFont, PdfFontMetrics* pMetrics, const char *pszSuffix, PdfVecObjects* pParent )
-    : PdfFontSimple( pMetrics, pFont->m_pEncoding, pParent )
-{
-	memset( m_bUsed, 0, sizeof( m_bUsed ) );
-	// don't embedd font
-    Init( false, PdfName("Type1") );
-
-	// Use identical subset-names
-	if ( pFont->IsSubsetting() )
-		GetObject()->GetDictionary().AddKey( "BaseFont", pFont->GetObject()->GetDictionary().GetKey( "BaseFont" ) );
-
-	// set identifier
-	std::string id = pFont->GetIdentifier().GetName();
-	id += pszSuffix;
-	m_Identifier = id;
-
-	// remove new FontDescriptor and use FontDescriptor of source font instead
-	PdfObject* pObj = pParent->RemoveObject( GetObject()->GetIndirectKey( "FontDescriptor" )->Reference() );
-	delete pObj;
-	GetObject()->GetDictionary().AddKey( "FontDescriptor", pFont->GetObject()->GetDictionary().GetKey( "FontDescriptor" ) );
-}
-
-void PdfFontType1::AddUsedSubsettingGlyphs( const PdfString & sText, long lStringLen )
-{
-	if ( m_bIsSubsetting )
-	{
-		// TODO: Unicode and Hex not yet supported
-		PODOFO_ASSERT( sText.IsUnicode() == false );
-		PODOFO_ASSERT( sText.IsHex() == false );
-		const unsigned char* strp = reinterpret_cast<const unsigned char *>(sText.GetString());	// must be unsigned for access to m_bUsed-array
-		for ( int i = 0; i < lStringLen; i++ )
-		{
-			m_bUsed[strp[i] / 32] |= 1 << (strp[i] % 32 ); 
-		}
-	}
-}
-
-void PdfFontType1::AddUsedGlyphname( const char * sGlyphName )
-{
-	if ( m_bIsSubsetting )
-    {
-		m_sUsedGlyph.insert( sGlyphName ); 
-    }
-}
-
-void PdfFontType1::EmbedSubsetFont()
-{
-	if ( !m_bIsSubsetting  ||  m_bWasEmbedded == true )
-		return;
-
-    pdf_long    lSize    = 0;
-    pdf_int64   lLength1 = 0L;
-    pdf_int64   lLength2 = 0L;
-    pdf_int64   lLength3 = 0L;
-    PdfObject*  pContents;
-    const char* pBuffer;
-    char*       pAllocated = NULL;
-
-    m_bWasEmbedded = true;
-
-    pContents = this->GetObject()->GetOwner()->CreateObject();
-    if( !pContents )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-        
-    m_pDescriptor->GetDictionary().AddKey( "FontFile", pContents->Reference() );
-
-    // if the data was loaded from memory - use it from there
-    // otherwise, load from disk
-    if ( m_pMetrics->GetFontDataLen() && m_pMetrics->GetFontData() ) 
-    {
-        pBuffer = m_pMetrics->GetFontData();
-        lSize   = m_pMetrics->GetFontDataLen();
-    }
-    else
-    {
-        FILE* hFile = fopen( m_pMetrics->GetFilename(), "rb" );
-        if( !hFile )
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, m_pMetrics->GetFilename() );
-        }
-
-        fseek( hFile, 0L, SEEK_END );
-        lSize = ftell( hFile );
-        fseek( hFile, 0L, SEEK_SET );
-
-        pAllocated = static_cast<char*>(malloc( sizeof(char) * lSize ));
-        if( !pAllocated )
-        {
-            fclose( hFile );
-            PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-        }
-
-        fread( pAllocated, sizeof(char), lSize, hFile );
-        fclose( hFile );
-
-        pBuffer = pAllocated;
-    }
-
-	// Allocate buffer for subsetted font, worst case size is input size
-	unsigned char * outBuff = new unsigned char[lSize];
-	int outIndex = 0;
-
-	// unsigned to make comparisons work
-	unsigned const char * inBuff = reinterpret_cast<unsigned const char*>(pBuffer);
-	int inIndex = 0;
-
-	// 6-Byte binary header for leading ascii-part
-	PODOFO_ASSERT( inBuff[inIndex + 0] == 0x80 );
-	PODOFO_ASSERT( inBuff[inIndex + 1] == 0x01 );
-	int length = inBuff[inIndex + 2] + 
-        (inBuff[inIndex + 3] << 8) + 
-        (inBuff[inIndex + 4] << 16) + 
-        (inBuff[inIndex + 5] << 24);				// little endian
-	inIndex += 6;
-	
-	PODOFO_ASSERT( memcmp( &inBuff[inIndex], "%!PS-AdobeFont-1.", 17 ) == 0 );
-
-	// transfer ascii-part, modify encoding dictionary (dup ...), if present
-	std::string line;
-	bool dupFound = false;
-	for ( int i = 0; i < length; i++ )
-	{
-		line += static_cast<char>( inBuff[inIndex+i] );
-		if ( inBuff[inIndex+i] == '\r' )
-		{
-			if ( line.find( "dup " ) != 0 )
-			{
-				memcpy( &outBuff[outIndex], line.c_str(), line.length() );
-				outIndex += line.length();
-			}
-			else
-			{
-				if ( dupFound == false )
-				{
-					// if first found, replace with new dictionary according to used glyphs
-					// ignore further dup's
-					for ( int i = 0; i < 256; i++ )
-					{
-						if ( (m_bUsed[i / 32] & (1 << (i % 32 ))) != 0 )
-						{
-							outIndex += sprintf( reinterpret_cast<char *>( &outBuff[outIndex] ), 
-												 "dup %d /%s put\r", 
-												 i, 
-												 PdfDifferenceEncoding::UnicodeIDToName( GetEncoding()->GetCharCode(i) ).GetName().c_str() );
-						}
-					}
-					dupFound = true;
-				}
-			}
-			line.clear();
-		}
-	}
-	inIndex += length;
-	lLength1 = outIndex;
-
-
-	// 6-Byte binary header for binary-part
-	PODOFO_ASSERT( inBuff[inIndex + 0] == 0x80 );
-	PODOFO_ASSERT( inBuff[inIndex + 1] == 0x02 );
-	length = inBuff[inIndex + 2] + 
-        (inBuff[inIndex + 3] << 8) + 
-        (inBuff[inIndex + 4] << 16) + 
-        (inBuff[inIndex + 5] << 24);				// little endian
-	inIndex += 6;
-
-	// copy binary using encrpytion
-	int outIndexStart = outIndex;
-	bool foundSeacGlyph;
-
-	// if glyph contains seac-command, add the used base-glyphs and loop again
-	do
-	{
-		PdfType1EncryptEexec inCrypt;
-		
-		outIndex = outIndexStart;
-		line.clear();
-		foundSeacGlyph = false;
-		bool inCharString = false;
-		for ( int i = 0; i < length;  )
-		{
-			unsigned char plain = inCrypt.Decrypt( inBuff[inIndex+i] );
-			i++;
-
-			line += static_cast<char>(plain);
-
-			// output is ssssbuild uncrypted, as parts might be skipped and cipher-engine must be unchanged
-			if ( inCharString && line.find( "/" ) == 0 )
-			{
-				// we are now inside a glyph, copy anything until RD or -| to output,
-				// in case this glyph will be skipped we go back to saveOutIndex
-				int outIndexSave = outIndex;
-
-				outBuff[outIndex++] = plain;
-				while ( line.find( "RD " ) == static_cast<size_t>(-1) 
-                        && line.find( "-| " ) == static_cast<size_t>(-1) )
-				{
-					plain = inCrypt.Decrypt( inBuff[inIndex+i] );
-					outBuff[outIndex++] = plain;
-					line += static_cast<char>(plain);
-					i++;
-				}
-
-				// parse line for name and length of glyph
-				char *glyphName = new char[line.length()];
-				int glyphLen;
-				int result;
-				if ( line.find( "RD " ) != static_cast<size_t>(-1) ) 
-                {
-					result = sscanf( line.c_str(), "%s %d RD ", glyphName, &glyphLen );
-                }
-				else
-                {
-					result = sscanf( line.c_str(), "%s %d -| ", glyphName, &glyphLen );
-                }
-				PODOFO_ASSERT( result == 2);
-
-				bool useGlyph = false;
-				// determine if this glyph is used in normal chars
-				for ( int code = 0; code <= 255; code++ )
-				{
-					if ( 
-						(m_bUsed[code / 32] & (1 << (code % 32 ))) != 0	&&
-						strcmp( glyphName+1, PdfDifferenceEncoding::UnicodeIDToName( GetEncoding()->GetCharCode(code) ).GetName().c_str() ) == 0
-                        )
-					{
-						useGlyph = true;
-						break;
-					}
-				}
-
-				// determine if this glyph is used in special chars
-				if ( m_sUsedGlyph.find( glyphName+1 ) != m_sUsedGlyph.end() )
-					useGlyph = true;
-
-				// always use .notdef
-				if ( strcmp( glyphName, "/.notdef" ) == 0 )
-					useGlyph = true;
-
-
-				// transfer glyph to output
-				for ( int j = 0; j < glyphLen; j++, i++ )
-					outBuff[outIndex++] = inCrypt.Decrypt( inBuff[inIndex+i] );
-
-				// check used glyph for seac-command
-				if ( useGlyph  &&  FindSeac( &outBuff[outIndex - glyphLen], glyphLen ) )
-					foundSeacGlyph = true;
-
-				delete[] glyphName;
-
-				// transfer rest until end of line to output
-				do
-				{
-					plain = inCrypt.Decrypt( inBuff[inIndex+i] );
-					outBuff[outIndex++] = plain;
-					line += static_cast<char>(plain);
-					i++;
-				} while ( plain != '\r'  &&  plain != '\n' );
-
-				if ( useGlyph == false )
-				{
-					// glyph is not used, go back to saved position
-					outIndex = outIndexSave;
-				}
-			}
-			else
-			{
-				// copy anything outside glyph to output
-				outBuff[outIndex++] = plain;
-			}
-
-			if ( plain == '\r' ||  plain == '\n' )
-			{
-				// parse for /CharStrings = begin of glyphs
-				if ( line.find( "/CharStrings" ) != static_cast<size_t>(-1) )
-					inCharString = true;
-				line.clear();
-			}
-		}
-	} while ( foundSeacGlyph );
-
-	// now encrypt resulting output-buffer
-	PdfType1EncryptEexec outCrypt;
-	for ( int i = outIndexStart; i < outIndex; i++ )
-		outBuff[i] = outCrypt.Encrypt( outBuff[i] );
-
-	lLength2 = outIndex - outIndexStart;
-	inIndex += length;
-
-
-	// 6-Byte binary header for ascii-part
-	PODOFO_ASSERT( inBuff[inIndex + 0] == 0x80 );
-	PODOFO_ASSERT( inBuff[inIndex + 1] == 0x01 );
-	length = inBuff[inIndex + 2] + 
-        (inBuff[inIndex + 3] << 8) + 
-        (inBuff[inIndex + 4] << 16) + 
-        (inBuff[inIndex + 5] << 24);				// little endian
-	inIndex += 6;
-
-	// copy ascii
-	memcpy( &outBuff[outIndex], &inBuff[inIndex], length );
-	lLength3 = length;
-	inIndex += length;
-	outIndex += length;
-
-	// now embed
-	pContents->GetStream()->Set( reinterpret_cast<const char *>(outBuff), outIndex );
-
-	// cleanup memory
-    if( pAllocated )
-        free( pAllocated );
-	free( outBuff );
-
-	// enter length in dictionary
-    pContents->GetDictionary().AddKey( "Length1", PdfVariant( lLength1 ) );
-    pContents->GetDictionary().AddKey( "Length2", PdfVariant( lLength2 ) );
-    pContents->GetDictionary().AddKey( "Length3", PdfVariant( lLength3 ) );
-}
-
-void PdfFontType1::EmbedFontFile( PdfObject* pDescriptor )
-{
-    pdf_long    lSize    = 0;
-    pdf_int64   lLength1 = 0L;
-    pdf_int64   lLength2 = 0L;
-    pdf_int64   lLength3 = 0L;
-    PdfObject*  pContents;
-    const char* pBuffer;
-    char*       pAllocated = NULL;
-
-	if (m_isBase14) 
-	{
-		m_bWasEmbedded = false;
-		return;
-	}
-
-    m_bWasEmbedded = true;
-
-    pContents = this->GetObject()->GetOwner()->CreateObject();
-    if( !pContents )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-        
-    pDescriptor->GetDictionary().AddKey( "FontFile", pContents->Reference() );
-
-    // if the data was loaded from memory - use it from there
-    // otherwise, load from disk
-    if ( m_pMetrics->GetFontDataLen() && m_pMetrics->GetFontData() ) 
-    {
-        pBuffer = m_pMetrics->GetFontData();
-        lSize   = m_pMetrics->GetFontDataLen();
-    }
-    else
-    {
-        FILE* hFile = fopen( m_pMetrics->GetFilename(), "rb" );
-        if( !hFile )
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, m_pMetrics->GetFilename() );
-        }
-
-        fseek( hFile, 0L, SEEK_END );
-        lSize = ftell( hFile );
-        fseek( hFile, 0L, SEEK_SET );
-
-        pAllocated = static_cast<char*>(malloc( sizeof(char) * lSize ));
-        if( !pAllocated )
-        {
-            fclose( hFile );
-            PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-        }
-
-        fread( pAllocated, sizeof(char), lSize, hFile );
-        fclose( hFile );
-
-        pBuffer = pAllocated;
-    }
-
-	// Remove binary segment headers from pfb
-	unsigned char *pBinary = reinterpret_cast<unsigned char*>(const_cast<char*>(pBuffer));
-	while( *pBinary == 0x80 )	// binary segment header
-	{
-		const int	cHeaderLength  = 6;
-		int			iSegmentType   = pBinary[1];	// binary segment type
-		long		lSegmentLength = 0L;
-		long		lSegmentDelta  = static_cast<long>(&pBuffer[lSize] - reinterpret_cast<const char*>(pBinary) );
-
-		switch( iSegmentType )
-		{
-			case 1:									// ASCII text
-				lSegmentLength = pBinary[2] + 		// little endian
-								 pBinary[3] * 256L + 
-								 pBinary[4] * 65536L +
-								 pBinary[5] * 16777216L;
-				if( lLength1 == 0L )
-					lLength1 = lSegmentLength;
-				else
-					lLength3 = lSegmentLength;
-				lSize -= cHeaderLength;
-				memmove( pBinary, &pBinary[cHeaderLength], lSegmentDelta );
-				pBinary = &pBinary[lSegmentLength];
-				break;
-			case 2:									// binary data
-				lSegmentLength = pBinary[2] + 		// little endian
-								 pBinary[3] * 256L + 
-								 pBinary[4] * 65536L +
-								 pBinary[5] * 16777216L;
-				lLength2 = lSegmentLength;
-				lSize -= cHeaderLength;
-				memmove( pBinary, &pBinary[cHeaderLength], lSegmentDelta );
-				pBinary = &pBinary[lSegmentLength];
-				break;
-			case 3:									// end-of-file
-				pContents->GetStream()->Set( pBuffer, lSize - 2L );
-				if( pAllocated )
-					free( pAllocated );
-
-				pContents->GetDictionary().AddKey( "Length1", PdfVariant( lLength1 ) );
-                pContents->GetDictionary().AddKey( "Length2", PdfVariant( lLength2 ) );
-                pContents->GetDictionary().AddKey( "Length3", PdfVariant( lLength3 ) );
-
-				return;
-			default:
-				break;
-		}
-	}
-
-	// Parse the font data buffer to get the values for length1, length2 and length3
-	lLength1 = FindInBuffer( "eexec", pBuffer, lSize );
-	if( lLength1 > 0 )
-		lLength1 += 6; // 6 == eexec + lf
-	else
-		lLength1 = 0;
-
-	if( lLength1 )
-	{
-		lLength2 = FindInBuffer( "cleartomark", pBuffer, lSize );
-		if( lLength2 > 0 )
-			lLength2 = lSize - lLength1 - 520; // 520 == 512 + strlen(cleartomark)
-		else
-			lLength1 = 0;
-	}
-
-	lLength3 = lSize - lLength2 - lLength1;
-    
-	// TODO: Pdf Supports only Type1 fonts with binary encrypted sections and not the hex format
-	pContents->GetStream()->Set( pBuffer, lSize );
-    if( pAllocated )
-        free( pAllocated );
-
-    pContents->GetDictionary().AddKey( "Length1", PdfVariant( lLength1 ) );
-    pContents->GetDictionary().AddKey( "Length2", PdfVariant( lLength2 ) );
-    pContents->GetDictionary().AddKey( "Length3", PdfVariant( lLength3 ) );
-}
-
-bool PdfFontType1::FindSeac( const unsigned char * buffer, int length )
-{
-	PdfType1EncryptCharstring crypt;
-	const PdfEncoding * stdEncoding = PdfEncodingFactory::GlobalStandardEncodingInstance();
-
-	bool foundNewGlyph = false;
-	int code1 = 0;
-	int code2 = 0;
-	for ( int j = 0; j < length; )
-	{
-		unsigned char plain = crypt.Decrypt( buffer[j++] );
-
-		if ( j <= 4 )
-		{
-			// skip first 4 bytes
-		}
-		else if ( plain < 32 )
-		{
-			// decode commands
-			switch ( plain )
-			{
-				case 1:		// hstem
-				case 3:		// vstem
-				case 4:		// rmoveto
-				case 5:		// rlineto
-				case 6:		// hlineto
-				case 7:		// vlineto
-				case 8:		// rrcurveto
-				case 9:		// closepath
-				case 10:	// callsubr
-				case 11:	// return
-				break;
-
-				case 12:	// escape
-				{
-					plain = crypt.Decrypt( buffer[j++] );
-					switch ( plain )
-					{
-						case 0:		// dotsection
-						case 1:		// vstem3
-						case 2:		// hstem3
-						break;
-
-						case 6:		// seac
-						{
-							// found seac command, use acquired code1 and code2 to get glyphname in standard-encoding
-							std::string name;
-							name = PdfDifferenceEncoding::UnicodeIDToName( stdEncoding->GetCharCode(code1) ).GetName().c_str();
-							if ( m_sUsedGlyph.find( name ) == m_sUsedGlyph.end() )
-							{
-								// add new glyph
-								m_sUsedGlyph.insert( name );
-								foundNewGlyph = true;
-							}
-
-							name = PdfDifferenceEncoding::UnicodeIDToName( stdEncoding->GetCharCode(code2) ).GetName().c_str();
-							if ( m_sUsedGlyph.find( name ) == m_sUsedGlyph.end() )
-							{
-								// add new glyph
-								m_sUsedGlyph.insert( name );
-								foundNewGlyph = true;
-							}
-						}
-						break;
-
-						case 7:		// sbw
-						case 12:	// div
-						case 16:	// callothersubr
-						case 17:	// pop
-						case 33:	// setcurrentpoint
-						break;
-
-						default:	// ???
-						break;
-					}
-				}
-				break;
-
-				case 13:	// hsbw
-				case 14:	// endchar
-				case 21:	// rmoveto
-				case 22:	// hmoveto
-				case 30:	// vhcurveto
-				case 31:	// hcurveto
-				break;
-
-				default:	// ???
-				break;
-			}
-		}
-		else if ( plain >= 32 ) // &&  plain <= 255 )
-		{
-			// this is a number
-			int number = 0;
-			if ( plain >= 32  &&  plain <= 246 )
-			{
-				number = static_cast<int>(plain-139);
-			}
-			else if ( plain >= 247  &&  plain <= 250 )
-			{
-				unsigned char next = crypt.Decrypt( buffer[j++] );
-
-				number = (static_cast<int>(plain)-247)*256 + next + 108;
-			}
-			else if ( plain >= 251  &&  plain <= 254 )
-			{
-				unsigned char next = crypt.Decrypt( buffer[j++] );
-
-				number = -((static_cast<int>(plain)-251)*256) - next - 108;
-			}
-			else if ( plain == 255 )
-			{
-				unsigned char next1 = crypt.Decrypt( buffer[j++] );
-				unsigned char next2 = crypt.Decrypt( buffer[j++] );
-				unsigned char next3 = crypt.Decrypt( buffer[j++] );
-				unsigned char next4 = crypt.Decrypt( buffer[j++] );
-
-				number = (static_cast<int>(next1) << 24)
-                    + (static_cast<int>(next2) << 16)
-                    + (static_cast<int>(next3) << 8)
-                    + next4 ;
-			}
-
-			char num[32];
-			sprintf( num, "%d ", number );
-
-			code1 = code2;
-			code2 = number;
-		}
-	}
-	return foundNewGlyph;
-}
-
-pdf_long PdfFontType1::FindInBuffer( const char* pszNeedle, const char* pszHaystack, pdf_long lLen ) const
-{
-    // if lNeedleLen is 0 the while loop will not be executed and we return -1
-    pdf_long lNeedleLen      = pszNeedle ? strlen( pszNeedle ) : 0; 
-    const char* pszEnd   = pszHaystack + lLen - lNeedleLen; 
-    const char* pszStart = pszHaystack;
-
-    while( pszHaystack < pszEnd ) 
-    {
-        if( strncmp( pszHaystack, pszNeedle, lNeedleLen ) == 0 )
-            return pszHaystack - pszStart;
-
-        ++pszHaystack;
-    }
-
-    return -1;
-}
-
-PdfType1EncryptEexec::PdfType1EncryptEexec() 
-	: PdfType1Encrypt()
-{
-	m_r = 55665;
-}
- 
-PdfType1EncryptCharstring::PdfType1EncryptCharstring() 
-    : PdfType1Encrypt()
-{
- 	m_r = 4330;
- }
-
-PdfType1Encrypt::PdfType1Encrypt()
-{
-	m_c1 = 52845;
-	m_c2 = 22719;
-}
-
-unsigned char PdfType1Encrypt::Encrypt( unsigned char plain )
-{
-	unsigned char cipher;
-	cipher = (plain ^ (m_r >> 8));
-	m_r = ((cipher + m_r) * m_c1 + m_c2) & ((1<<16) -1);
-
-	return cipher;
-}
-
-unsigned char PdfType1Encrypt::Decrypt( unsigned char cipher )
-{
-	unsigned char plain;
-	plain = (cipher ^ (m_r >> 8));
-	m_r = (cipher + m_r) * m_c1 + m_c2;
-
-	return plain;
-}
-
-};
-
--- src/doc/PdfImage.cpp.orig	2024-06-29 17:32:04.966340347 +0000
+++ src/doc/PdfImage.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,747 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfImage.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfColor.h"
-#include "base/PdfStream.h"
-#include "base/PdfFiltersPrivate.h"
-
-#include <stdio.h>
-#include <wchar.h>
-#include <sstream>
-
-#define PODOFO_JPEG_RUNTIME_COMPATIBLE
-#ifdef PODOFO_HAVE_TIFF_LIB
-extern "C" {
-#  include "tiffio.h"
-#  ifdef _WIN32		// Collision between tiff and jpeg-headers
-#    ifndef XMD_H
-#    define XMD_H
-#    endif
-#    undef FAR
-#  endif
-}
-#endif // PODOFO_HAVE_TIFF_LIB
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-extern "C" {
-#  ifndef XMD_H
-#    define XMD_H
-#  endif
-#  include "jpeglib.h"
-}
-#endif // PODOFO_HAVE_JPEG_LIB
-
-#ifdef PODOFO_HAVE_PNG_LIB
-#include <png.h>
-#endif /// PODOFO_HAVE_PNG_LIB
-
-// <windows.h> defines an annoying GetObject macro that changes uses of GetObject to
-// GetObjectA . Since macros aren't scope and namespace aware that breaks our code.
-// Since we won't be using the Win32 resource manager API here, just undefine it.
-#if defined(GetObject)
-#undef GetObject
-#endif
-
-using namespace std;
-
-namespace PoDoFo {
-
-PdfImage::PdfImage( PdfVecObjects* pParent, const char* pszPrefix )
-    : PdfXObject( "Image", pParent, pszPrefix )
-{
-    m_rRect = PdfRect();
-
-    this->SetImageColorSpace( ePdfColorSpace_DeviceRGB );
-}
-
-PdfImage::PdfImage( PdfDocument* pParent, const char* pszPrefix )
-    : PdfXObject( "Image", pParent, pszPrefix )
-{
-    m_rRect = PdfRect();
-
-    this->SetImageColorSpace( ePdfColorSpace_DeviceRGB );
-}
-
-PdfImage::PdfImage( PdfObject* pObject )
-    : PdfXObject( "Image", pObject )
-{
-    m_rRect.SetHeight( static_cast<double>(this->GetObject()->GetDictionary().GetKey( "Height" )->GetNumber()) );
-    m_rRect.SetWidth ( static_cast<double>(this->GetObject()->GetDictionary().GetKey( "Width" )->GetNumber()) );
-}
-
-PdfImage::~PdfImage()
-{
-
-}
-
-     /* Example: { "JPEG", "TIFF", NULL }
-     *
-     * \returns a zero terminates list of all supported image formats
-     */
-const char** PdfImage::GetSupportedFormats()
-{
-    static const char* ppszFormats[] = {
-#ifdef PODOFO_HAVE_JPEG_LIB
-        "JPEG",
-#endif // PODOFO_HAVE_JPEG_LIB
-#ifdef PODOFO_HAVE_PNG_LIB
-        "PNG", 
-#endif // PODOFO_HAVE_PNG_LIB
-#ifdef PODOFO_HAVE_TIFF_LIB
-        "TIFF", 
-#endif // PODOFO_HAVE_TIFF_LIB
-        NULL
-    };
-
-    return ppszFormats;
-}
-
-void PdfImage::SetImageColorSpace( EPdfColorSpace eColorSpace )
-{
-    this->GetObject()->GetDictionary().AddKey( PdfName("ColorSpace"), ColorspaceToName( eColorSpace ) );
-}
-
-void PdfImage::SetImageICCProfile( PdfInputStream* pStream, long lColorComponents, EPdfColorSpace eAlternateColorSpace ) 
-{
-    // Check lColorComponents for a valid value
-    if( lColorComponents != 1 &&
-        lColorComponents != 3 &&  
-        lColorComponents != 4 )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_ValueOutOfRange, "SetImageICCProfile lColorComponents must be 1,3 or 4!" );
-    }
-
-    // Create a colorspace object
-    PdfObject* pIccObject = this->GetObject()->GetOwner()->CreateObject();
-    pIccObject->GetDictionary().AddKey( PdfName("Alternate"), ColorspaceToName( eAlternateColorSpace ) ); 
-    pIccObject->GetDictionary().AddKey( PdfName("N"), static_cast<pdf_int64>(lColorComponents) );
-    pIccObject->GetStream()->Set( pStream );
-    
-    // Add the colorspace to our image
-    PdfArray array;
-    array.push_back( PdfName("ICCBased") );
-    array.push_back( pIccObject->Reference() );
-    this->GetObject()->GetDictionary().AddKey( PdfName("ColorSpace"), array );
-}
-
-void PdfImage::SetImageSoftmask( const PdfImage* pSoftmask )
-{
-	GetObject()->GetDictionary().AddKey( "SMask", pSoftmask->GetObject()->Reference() );
-}
-
-void PdfImage::SetImageData( unsigned int nWidth, unsigned int nHeight, 
-                             unsigned int nBitsPerComponent, PdfInputStream* pStream )
-{
-    TVecFilters vecFlate;
-    vecFlate.push_back( ePdfFilter_FlateDecode );
-
-    this->SetImageData( nWidth, nHeight, nBitsPerComponent, pStream, vecFlate );
-}
-
-void PdfImage::SetImageData( unsigned int nWidth, unsigned int nHeight, 
-                             unsigned int nBitsPerComponent, PdfInputStream* pStream, 
-                             const TVecFilters & vecFilters )
-{
-    m_rRect.SetWidth( nWidth );
-    m_rRect.SetHeight( nHeight );
-
-    this->GetObject()->GetDictionary().AddKey( "Width",  PdfVariant( static_cast<pdf_int64>(nWidth) ) );
-    this->GetObject()->GetDictionary().AddKey( "Height", PdfVariant( static_cast<pdf_int64>(nHeight) ) );
-    this->GetObject()->GetDictionary().AddKey( "BitsPerComponent", PdfVariant( static_cast<pdf_int64>(nBitsPerComponent) ) );
-
-    PdfVariant var;
-    m_rRect.ToVariant( var );
-    this->GetObject()->GetDictionary().AddKey( "BBox", var );
-
-    this->GetObject()->GetStream()->Set( pStream, vecFilters );
-}
-
-void PdfImage::SetImageDataRaw( unsigned int nWidth, unsigned int nHeight, 
-                                unsigned int nBitsPerComponent, PdfInputStream* pStream )
-{
-    m_rRect.SetWidth( nWidth );
-    m_rRect.SetHeight( nHeight );
-
-    this->GetObject()->GetDictionary().AddKey( "Width",  PdfVariant( static_cast<pdf_int64>(nWidth) ) );
-    this->GetObject()->GetDictionary().AddKey( "Height", PdfVariant( static_cast<pdf_int64>(nHeight) ) );
-    this->GetObject()->GetDictionary().AddKey( "BitsPerComponent", PdfVariant( static_cast<pdf_int64>(nBitsPerComponent) ) );
-
-    PdfVariant var;
-    m_rRect.ToVariant( var );
-    this->GetObject()->GetDictionary().AddKey( "BBox", var );
-
-    this->GetObject()->GetStream()->SetRawData( pStream, -1 );
-}
-
-void PdfImage::LoadFromFile( const char* pszFilename )
-{
-    if( pszFilename && strlen( pszFilename ) > 3 )
-    {
-        const char* pszExtension = pszFilename + strlen( pszFilename ) - 3;
-
-#ifdef PODOFO_HAVE_TIFF_LIB
-        if( PoDoFo::compat::strncasecmp( pszExtension, "tif", 3 ) == 0 ||
-            PoDoFo::compat::strncasecmp( pszExtension, "iff", 3 ) == 0 ) // "tiff"
-        {
-            LoadFromTiff( pszFilename );
-            return;
-        }
-#endif
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-        if( PoDoFo::compat::strncasecmp( pszExtension, "jpg", 3 ) == 0 )
-        {
-            LoadFromJpeg( pszFilename );
-            return;
-        }
-#endif
-
-#ifdef PODOFO_HAVE_PNG_LIB
-        if( PoDoFo::compat::strncasecmp( pszExtension, "png", 3 ) == 0 )
-        {
-            LoadFromPng( pszFilename );
-            return;
-        }
-#endif
-
-	}
-	PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedImageFormat, pszFilename );
-}
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-extern "C" {
-static void JPegErrorExit(j_common_ptr cinfo)
-{
-#if 1	
-    char buffer[JMSG_LENGTH_MAX];
-
-    /* Create the message */
-    (*cinfo->err->format_message) (cinfo, buffer);
-#endif
-    jpeg_destroy(cinfo);
-    PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedImageFormat, buffer);
-}
-
-static void JPegErrorOutput(j_common_ptr, int)
-{
-}
-
-};
-
-
-void PdfImage::LoadFromJpeg( const char* pszFilename )
-    {
-    /* Constructor will throw exception */
-    PdfFileInputStream stream( pszFilename );
-    LoadFromJpegHandle( &stream );
-}
-
-#ifdef _WIN32
-void PdfImage::LoadFromJpeg( const wchar_t* pszFilename )
-{
-    PdfFileInputStream stream( pszFilename );
-    LoadFromJpegHandle( &stream );
-}
-#endif // _WIN32
-
-void PdfImage::LoadFromJpegHandle( PdfFileInputStream* pInStream )
-{
-    struct jpeg_decompress_struct cinfo;
-    struct jpeg_error_mgr         jerr;
-
-    cinfo.err = jpeg_std_error(&jerr);
-    jerr.error_exit = &JPegErrorExit;
-    jerr.emit_message = &JPegErrorOutput;
-
-    jpeg_create_decompress(&cinfo);
-
-#if !defined(PODOFO_JPEG_RUNTIME_COMPATIBLE)
-    const long lSize = 1024;
-    PdfRefCountedBuffer buffer( lSize );
-    fread( buffer.GetBuffer(), sizeof(char), lSize, hInfile );
-    
-    // On WIN32, you can only pass a FILE Handle to DLLs which where compiled using the same
-    // C library. This is usually not the case with LibJpeg on WIN32. 
-    // As a reason we use a memory buffer to determine the header information.
-    //
-    // If you are sure that libJpeg is compiled against the same C library as your application
-    // you can removed this ifdef.
-    jpeg_memory_src ( &cinfo, reinterpret_cast<JOCTET*>(buffer.GetBuffer()), buffer.GetSize() );
-#else
-    jpeg_stdio_src(&cinfo, pInStream->GetHandle());
-#endif // PODOFO_JPEG_RUNTIME_COMPATIBLE
-
-    if( jpeg_read_header(&cinfo, TRUE) <= 0 )
-    {
-        (void) jpeg_destroy_decompress(&cinfo);
-
-        PODOFO_RAISE_ERROR( ePdfError_UnexpectedEOF );
-    }
-
-    jpeg_start_decompress(&cinfo);
-
-    m_rRect.SetWidth( cinfo.output_width );
-    m_rRect.SetHeight( cinfo.output_height );
-
-    // I am not sure wether this switch is fully correct.
-    // it should handle all cases though.
-    // Index jpeg files might look strange as jpeglib+
-    // returns 1 for them.
-    switch( cinfo.output_components )
-    {
-        case 3:
-            this->SetImageColorSpace( ePdfColorSpace_DeviceRGB );
-            break;
-        case 4:
-	{
-	    this->SetImageColorSpace( ePdfColorSpace_DeviceCMYK );
-	    // The jpeg-doc ist not specific in this point, but cmyk's seem to be stored
-	    // in a inverted fashion. Fix by attaching a decode array
-	    PdfArray decode;
-	    decode.push_back( 1.0 );
-	    decode.push_back( 0.0 );
-	    decode.push_back( 1.0 );
-	    decode.push_back( 0.0 );
-	    decode.push_back( 1.0 );
-	    decode.push_back( 0.0 );
-	    decode.push_back( 1.0 );
-	    decode.push_back( 0.0 );
-	    
-	    this->GetObject()->GetDictionary().AddKey( PdfName("Decode"), decode );
-	}
-	break;
-        default:
-            this->SetImageColorSpace( ePdfColorSpace_DeviceGray );
-            break;
-    }
-    
-    // Set the filters key to DCTDecode
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeyFilter, PdfName( "DCTDecode" ) );
-    // Do not apply any filters as JPEG data is already DCT encoded.
-    fseeko( pInStream->GetHandle(), 0L, SEEK_SET );
-    this->SetImageDataRaw( cinfo.output_width, cinfo.output_height, 8, pInStream );
-    
-    (void) jpeg_destroy_decompress(&cinfo);
-}
-#endif // PODOFO_HAVE_JPEG_LIB
-
-#ifdef PODOFO_HAVE_TIFF_LIB
-static void TIFFErrorWarningHandler(const char*, const char*, va_list)
-{
-    
-}
-
-void PdfImage::LoadFromTiff( const char* pszFilename )
-{
-    TIFFSetErrorHandler(TIFFErrorWarningHandler);
-    TIFFSetWarningHandler(TIFFErrorWarningHandler);
-    
-    if( !pszFilename )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    TIFF* hInfile = TIFFOpen(pszFilename, "rb");
-
-    if( !hInfile )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-    }
-
-    int32 row, width, height;
-    uint16 samplesPerPixel, bitsPerSample;
-    uint16* sampleInfo;
-    uint16 extraSamples;
-    uint16 planarConfig, photoMetric, orientation;
-    int32 resolutionUnit;
-
-    TIFFGetField(hInfile,	   TIFFTAG_IMAGEWIDTH,		&width);
-    TIFFGetField(hInfile,	   TIFFTAG_IMAGELENGTH,		&height);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_BITSPERSAMPLE,	&bitsPerSample);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_SAMPLESPERPIXEL,     &samplesPerPixel);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_PLANARCONFIG,	&planarConfig);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_PHOTOMETRIC,		&photoMetric);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_EXTRASAMPLES,	&extraSamples, &sampleInfo);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_ORIENTATION,		&orientation);
-	
-    resolutionUnit = 0;
-    float resX;
-    float resY;
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_XRESOLUTION,		&resX);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_YRESOLUTION,		&resY);
-    TIFFGetFieldDefaulted(hInfile, TIFFTAG_RESOLUTIONUNIT,	&resolutionUnit);
-
-    int colorChannels = samplesPerPixel - extraSamples;
-
-    int bitsPixel = bitsPerSample * samplesPerPixel;
-
-    // TODO: implement special cases
-    if( TIFFIsTiled(hInfile) )
-    {
-        TIFFClose(hInfile);
-        PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-    }
-		
-    if ( planarConfig != PLANARCONFIG_CONTIG && colorChannels != 1 )
-    {
-        TIFFClose(hInfile);
-        PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-    }
-
-	if ( orientation != ORIENTATION_TOPLEFT )
-    {
-        TIFFClose(hInfile);
-        PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-    }
-
-	switch(photoMetric)
-	{
-		case PHOTOMETRIC_MINISBLACK:
-		{
-			if( bitsPixel == 1 )
-			{
-				PdfArray decode;
-				decode.insert( decode.end(), PdfVariant( static_cast<pdf_int64>(0) ) );
-				decode.insert( decode.end(), PdfVariant( static_cast<pdf_int64>(1) ) );
-				this->GetObject()->GetDictionary().AddKey( PdfName("Decode"), decode );
-				this->GetObject()->GetDictionary().AddKey( PdfName("ImageMask"), PdfVariant( true ) );
-				this->GetObject()->GetDictionary().RemoveKey( PdfName("ColorSpace") );
-			}
-			else if ( bitsPixel == 8)
-	            SetImageColorSpace(ePdfColorSpace_DeviceGray);
-			else
-			{
-				TIFFClose(hInfile);
-				PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-			}
-		}
-		break;
-
-		case PHOTOMETRIC_MINISWHITE:
-		{
-			if( bitsPixel == 1 )
-			{
-				PdfArray decode;
-				decode.insert( decode.end(), PdfVariant( static_cast<pdf_int64>(1) ) );
-				decode.insert( decode.end(), PdfVariant( static_cast<pdf_int64>(0) ) );
-				this->GetObject()->GetDictionary().AddKey( PdfName("Decode"), decode );
-				this->GetObject()->GetDictionary().AddKey( PdfName("ImageMask"), PdfVariant( true ) );
-				this->GetObject()->GetDictionary().RemoveKey( PdfName("ColorSpace") );
-			}
-			else if ( bitsPixel == 8)
-	            SetImageColorSpace(ePdfColorSpace_DeviceGray);
-			else
-			{
-				TIFFClose(hInfile);
-				PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-			}
-		}
-		break;
-
-		case PHOTOMETRIC_RGB:
-            if ( bitsPixel != 24 )
-			{
-				TIFFClose(hInfile);
-				PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-			}
-			SetImageColorSpace(ePdfColorSpace_DeviceRGB);
-		break;
-
-		case PHOTOMETRIC_SEPARATED: 
-			if( bitsPixel != 32)
-			{
-				TIFFClose(hInfile);
-				PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-			}
-            SetImageColorSpace(ePdfColorSpace_DeviceCMYK);
-		break;
-
-		case PHOTOMETRIC_PALETTE:
-		{
-			int numColors = (1 << bitsPixel);
-
-			PdfArray decode;
-			decode.insert( decode.end(), PdfVariant( static_cast<pdf_int64>(0) ) );
-			decode.insert( decode.end(), PdfVariant( static_cast<pdf_int64>(numColors-1) ) );
-			this->GetObject()->GetDictionary().AddKey( PdfName("Decode"), decode );
-
-			uint16 * rgbRed;
-			uint16 * rgbGreen;
-			uint16 * rgbBlue;
-			TIFFGetField(hInfile, TIFFTAG_COLORMAP, &rgbRed, &rgbGreen, &rgbBlue);
-
-			char *datap = new char[numColors*3];
-
-			for ( int clr = 0; clr < numColors; clr++ )
-			{
-				datap[3*clr+0] = rgbRed[clr]/257;
-				datap[3*clr+1] = rgbGreen[clr]/257;
-				datap[3*clr+2] = rgbBlue[clr]/257;
-			}
-		    PdfMemoryInputStream stream( datap, numColors*3 );
-
-		    // Create a colorspace object
-		    PdfObject* pIdxObject = this->GetObject()->GetOwner()->CreateObject();
-			pIdxObject->GetStream()->Set( &stream );
-    
-		    // Add the colorspace to our image
-		    PdfArray array;
-		    array.push_back( PdfName("Indexed") );
-		    array.push_back( PdfName("DeviceRGB") );
-            array.push_back( static_cast<pdf_int64>(numColors-1) );
-		    array.push_back( pIdxObject->Reference() );
-		    this->GetObject()->GetDictionary().AddKey( PdfName("ColorSpace"), array );
-
-			delete[] datap;
-		}
-		break;
-
-		default:
-	        TIFFClose(hInfile);
-	        PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-		break;
-	}
-
-	int32 scanlineSize = TIFFScanlineSize(hInfile);
-    long bufferSize = scanlineSize * height;
-    char *buffer = new char[bufferSize];
-    if( !buffer ) 
-    {
-        TIFFClose(hInfile);
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-
-    for(row = 0; row < height; row++)
-    {
-        if(TIFFReadScanline(hInfile,
-                            &buffer[row * scanlineSize],
-                            row) == (-1))
-        {
-            TIFFClose(hInfile);
-            PODOFO_RAISE_ERROR( ePdfError_UnsupportedImageFormat );
-        }
-    }
-
-	PdfMemoryInputStream stream(buffer, bufferSize);
-
-    SetImageData(static_cast<unsigned int>(width), 
-                 static_cast<unsigned int>(height),
-                 static_cast<unsigned int>(bitsPerSample), 
-                 &stream);
-
-    delete[] buffer;
-
-    TIFFClose(hInfile);
-}
-#endif // PODOFO_HAVE_TIFF_LIB
-#ifdef PODOFO_HAVE_PNG_LIB
-void PdfImage::LoadFromPng( const char* pszFilename )
-{
-    if( !pszFilename )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    FILE* hFile = fopen(pszFilename, "rb");
-    if( !hFile )
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_FileNotFound, pszFilename );
-    }
-
-    png_byte header[8];
-    fread(header, 1, 8, hFile);
-    if( png_sig_cmp(header, 0, 8) )
-    {
-        fclose( hFile );
-        PODOFO_RAISE_ERROR_INFO( ePdfError_UnsupportedImageFormat, "The file could not be recognized as a PNG file." );
-    }
-    
-    png_structp pPng = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
-    if( !pPng )
-    {
-        fclose( hFile );
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    png_infop pInfo = png_create_info_struct(pPng);
-    if( !pInfo )
-    {
-        png_destroy_read_struct(&pPng, (png_infopp)NULL, (png_infopp)NULL);
-        fclose( hFile );
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( setjmp(png_jmpbuf(pPng)) )
-    {
-        png_destroy_read_struct(&pPng, &pInfo, (png_infopp)NULL);
-        fclose( hFile );
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    png_init_io(pPng, hFile);
-    png_set_sig_bytes(pPng, 8);
-    png_read_info(pPng, pInfo);
-
-// Begin
-    png_uint_32 width;
-    png_uint_32 height;
-    int depth;
-    int color_type;
-    int interlace;
-
-    png_get_IHDR (pPng, pInfo,
-                  &width, &height, &depth,
-                  &color_type, &interlace, NULL, NULL);
-
-    /* convert palette/gray image to rgb */
-    if (color_type == PNG_COLOR_TYPE_PALETTE)
-        png_set_palette_to_rgb(pPng);
-
-    if (color_type & PNG_COLOR_MASK_ALPHA)
-       png_set_strip_alpha(pPng);
-#if 0
-    /* expand gray bit depth if needed */
-    if (color_type == PNG_COLOR_TYPE_GRAY) {
-#if PNG_LIBPNG_VER >= 10209
-        png_set_expand_gray_1_2_4_to_8 (pPng);
-#else
-        png_set_gray_1_2_4_to_8 (pPng);
-#endif
-    }
-#endif
-    /* transform transparency to alpha */
-    if (png_get_valid (pPng, pInfo, PNG_INFO_tRNS))
-        png_set_tRNS_to_alpha (pPng);
-
-    if (depth == 16)
-        png_set_strip_16(pPng);
-
-    if (depth < 8)
-        png_set_packing(pPng);
-#if 0
-    /* convert grayscale to RGB */
-    if (color_type == PNG_COLOR_TYPE_GRAY ||
-	color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
-    {
-	png_set_gray_to_rgb (pPng);
-    }
-#endif
-    if (interlace != PNG_INTERLACE_NONE)
-        png_set_interlace_handling(pPng);
-
-    //png_set_filler (pPng, 0xff, PNG_FILLER_AFTER);
-
-    /* recheck header after setting EXPAND options */
-    png_read_update_info(pPng, pInfo);
-    png_get_IHDR (pPng, pInfo,
-                  &width, &height, &depth,
-                  &color_type, &interlace, NULL, NULL);
-// End //
-    
-    // Read the file
-    if( setjmp(png_jmpbuf(pPng)) ) 
-    {
-        png_destroy_read_struct(&pPng, &pInfo, (png_infopp)NULL);
-        fclose( hFile );
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-
-    long lLen = static_cast<long>(png_get_rowbytes(pPng, pInfo) * height);
-    char* pBuffer = static_cast<char*>(malloc(sizeof(char) * lLen));
-    png_bytepp pRows = static_cast<png_bytepp>(malloc(sizeof(png_bytep)*height));
-    for(unsigned int y=0; y<height; y++)
-    {
-        pRows[y] = reinterpret_cast<png_bytep>(pBuffer + (y * png_get_rowbytes(pPng, pInfo)));
-    }
-
-    png_read_image(pPng, pRows);
-    fclose(hFile);
-
-    m_rRect.SetWidth( width );
-    m_rRect.SetHeight( height );
-
-    switch( png_get_channels( pPng, pInfo ) )
-    {
-        case 3:
-            this->SetImageColorSpace( ePdfColorSpace_DeviceRGB );
-            break;
-        case 4:
-        {
-            this->SetImageColorSpace( ePdfColorSpace_DeviceCMYK );
-            // The jpeg-doc ist not specific in this point, but cmyk's seem to be stored
-            // in a inverted fashion. Fix by attaching a decode array
-            PdfArray decode;
-            decode.push_back( 1.0 );
-            decode.push_back( 0.0 );
-            decode.push_back( 1.0 );
-            decode.push_back( 0.0 );
-            decode.push_back( 1.0 );
-            decode.push_back( 0.0 );
-            decode.push_back( 1.0 );
-            decode.push_back( 0.0 );
-            
-            this->GetObject()->GetDictionary().AddKey( PdfName("Decode"), decode );
-        }
-        break;
-        default:
-            this->SetImageColorSpace( ePdfColorSpace_DeviceGray );
-            break;
-    }
-
-    // Set the image data and flate compress it
-    PdfMemoryInputStream stream( pBuffer, lLen );
-    this->SetImageData( width, height, depth, &stream );
-    
-    free(pBuffer);
-    free(pRows);
-    
-    png_destroy_read_struct(&pPng, &pInfo, (png_infopp)NULL);
-
-}
-#endif // PODOFO_HAVE_PNG_LIB
-
-PdfName PdfImage::ColorspaceToName( EPdfColorSpace eColorSpace )
-{
-    return PdfColor::GetNameForColorSpace( eColorSpace ).GetName();
-}
-
-void PdfImage::SetImageChromaKeyMask(pdf_int64 r, pdf_int64 g, pdf_int64 b, pdf_int64 threshold)
-{
-    PdfArray array;
-    array.push_back(r - threshold);
-    array.push_back(r + threshold);
-    array.push_back(g - threshold);
-    array.push_back(g + threshold);
-    array.push_back(b - threshold);
-    array.push_back(b + threshold);
-
-    this->GetObject()->GetDictionary().AddKey( "Mask", array);
-}
-
-void PdfImage::SetInterpolate(bool bValue)
-{
-    this->GetObject()->GetDictionary().AddKey( "Interpolate", PdfVariant(bValue));
-}
-};
--- src/doc/PdfNamesTree.cpp.orig	2011-05-30 21:13:58.000000000 +0000
+++ src/doc/PdfNamesTree.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,500 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfNamesTree.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfOutputDevice.h"
-
-#include <sstream>
-
-namespace PoDoFo {
-
-#define BALANCE_TREE_MAX 65
-
-/*
-#define BALANCE_TREE_MAX 9
-*/
-
-class PdfNameTreeNode {
-public:
-    PdfNameTreeNode( PdfNameTreeNode* pParent, PdfObject* pObject ) 
-        : m_pParent( pParent ), m_pObject( pObject )
-    {
-        m_bHasKids = m_pObject->GetDictionary().HasKey("Kids");
-    }
-
-    bool AddValue( const PdfString & key, const PdfObject & value );
-
-    void SetLimits();
-
-    inline PdfObject* GetObject() { return m_pObject; }
-
-private:
-    bool Rebalance();
-
-private:
-    PdfNameTreeNode* m_pParent;
-    PdfObject*       m_pObject;
-
-    bool             m_bHasKids;
-
-};
-
-bool PdfNameTreeNode::AddValue( const PdfString & key, const PdfObject & rValue )
-{
-    if( m_bHasKids )
-    {
-        const PdfArray &         kids   = this->GetObject()->GetDictionary().GetKey("Kids")->GetArray();
-        PdfArray::const_iterator it     = kids.begin();
-        PdfObject*               pChild = NULL;
-        EPdfNameLimits           eLimits = ePdfNameLimits_Before; // RG: TODO Compiler complains that this variable should be initialised
-
-        while( it != kids.end() )
-        {
-            pChild = this->GetObject()->GetOwner()->GetObject( (*it).GetReference() );
-            if( !pChild ) 
-            {
-                PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-            }
-
-            eLimits = PdfNamesTree::CheckLimits( pChild, key );
-            if( (eLimits == ePdfNameLimits_Before) || 
-                (eLimits == ePdfNameLimits_Inside) )
-            {
-                break;
-            }
-
-            ++it;
-        }
-
-        if( it == kids.end() ) 
-        {
-            // not added, so add to last child
-            pChild = this->GetObject()->GetOwner()->GetObject( kids.back().GetReference() );
-            if( !pChild ) 
-            {
-                PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-            }
-
-            eLimits = ePdfNameLimits_After;
-        }
-                
-        PdfNameTreeNode child( this, pChild );
-        if( child.AddValue( key, rValue ) ) 
-        {
-            // if a child insert the key in a way that the limits
-            // are changed, we have to change our limits as well!
-            // our parent has to change his parents too!
-            if( eLimits != ePdfNameLimits_Inside )
-                this->SetLimits();
-            
-            this->Rebalance();
-            return true;
-        }
-        else
-            return false;
-    }
-    else
-    {
-        bool bRebalance = false;
-        PdfArray limits;
-
-        if( this->GetObject()->GetDictionary().HasKey( "Names" ) ) 
-        {
-            PdfArray& array = this->GetObject()->GetDictionary().GetKey("Names")->GetArray();
-            PdfArray::iterator it = array.begin();
-            
-            while( it != array.end() )
-            {
-                if( (*it).GetString() == key ) 
-                {
-                    // no need to write the key as it is anyways the same
-                    ++it;
-                    // write the value
-                    *it = rValue;
-                    break;
-                }
-                else if( (*it).GetString() > key ) 
-                {                    
-                    it = array.insert( it, rValue ); // array.insert invalidates the iterator
-                    it = array.insert( it, key );
-                    break;
-                }
-                
-                it += 2;
-            }
-
-            if( it == array.end() )
-            {
-                array.push_back( key );
-                array.push_back( rValue );
-            }
-
-            limits.push_back( (*array.begin()) );
-            limits.push_back( (*(array.end()-2)) );
-            bRebalance = true;
-        }
-        else
-        {
-            // we create a completely new node
-            PdfArray array;
-            array.push_back( key );
-            array.push_back( rValue );
-
-            limits.push_back( key );
-            limits.push_back( key );
-
-            // create a child object
-            PdfObject* pChild = this->GetObject()->GetOwner()->CreateObject();
-            pChild->GetDictionary().AddKey( "Names", array );
-            pChild->GetDictionary().AddKey( "Limits", limits );
-
-            PdfArray kids( pChild->Reference() );
-            this->GetObject()->GetDictionary().AddKey( "Kids", kids );
-            m_bHasKids = true;
-        }
-
-        if( m_pParent )
-        {
-            // Root node is not allowed to have a limits key!
-            this->GetObject()->GetDictionary().AddKey( "Limits", limits );
-        }
-        
-        if( bRebalance )
-            this->Rebalance();
-
-        return true;
-    }
-}
-
-void PdfNameTreeNode::SetLimits() 
-{
-    PdfArray limits;
-
-    if( m_bHasKids ) 
-    {
-        if( this->GetObject()->GetDictionary().HasKey( PdfName("Kids") ) &&
-            this->GetObject()->GetDictionary().GetKey( PdfName("Kids") )->IsArray() )
-        {
-            const PdfReference & rRefFirst = (*this->GetObject()->GetDictionary().GetKey("Kids")->GetArray().begin()).GetReference();
-            PdfObject* pChild = this->GetObject()->GetOwner()->GetObject( rRefFirst );
-            if( pChild && pChild->GetDictionary().HasKey( PdfName("Limits") ) &&
-                pChild->GetDictionary().GetKey( PdfName("Limits") )->IsArray() ) 
-                limits.push_back( *(pChild->GetDictionary().GetKey("Limits")->GetArray().begin()) );
-            
-            const PdfReference & rRefLast = this->GetObject()->GetDictionary().GetKey("Kids")->GetArray().back().GetReference();
-            pChild = this->GetObject()->GetOwner()->GetObject( rRefLast );
-            if( pChild && pChild->GetDictionary().HasKey( PdfName("Limits") ) &&
-                pChild->GetDictionary().GetKey( PdfName("Limits") )->IsArray() ) 
-                limits.push_back( pChild->GetDictionary().GetKey("Limits")->GetArray().back() );
-        }
-        else
-            PdfError::LogMessage( eLogSeverity_Error, 
-                                  "Object %i %si does not have Kids array.", 
-                                  this->GetObject()->Reference().ObjectNumber(), 
-                                  this->GetObject()->Reference().GenerationNumber() );
-    }
-    else // has "Names"
-    {
-        if( this->GetObject()->GetDictionary().HasKey( PdfName("Names") ) &&
-            this->GetObject()->GetDictionary().GetKey( PdfName("Names") )->IsArray() )
-        {
-            limits.push_back( (*this->GetObject()->GetDictionary().GetKey("Names")->GetArray().begin()) );
-            limits.push_back( (*(this->GetObject()->GetDictionary().GetKey("Names")->GetArray().end()-2)) );
-        }
-        else
-            PdfError::LogMessage( eLogSeverity_Error, 
-                                  "Object %i %si does not have Names array.", 
-                                  this->GetObject()->Reference().ObjectNumber(), 
-                                  this->GetObject()->Reference().GenerationNumber() );
-    }
-
-    if( m_pParent )
-    {
-        // Root node is not allowed to have a limits key!
-        this->GetObject()->GetDictionary().AddKey("Limits", limits );
-    }
-}
-
-bool PdfNameTreeNode::Rebalance()
-{
-    PdfArray* pArray            = m_bHasKids ? &(this->GetObject()->GetDictionary().GetKey("Kids")->GetArray()) :
-                                               &(this->GetObject()->GetDictionary().GetKey("Names")->GetArray());
-    const PdfName& key          = m_bHasKids ? PdfName("Kids") : PdfName("Names");
-    const unsigned int nLength  = m_bHasKids ? BALANCE_TREE_MAX : BALANCE_TREE_MAX * 2;
-
-    if( !pArray ) 
-        return false;
-
-    if( pArray->size() > nLength )
-    {
-        PdfArray   first;
-        PdfArray   second;
-        PdfArray   kids;
-
-        first.insert( first.end(), pArray->begin(), pArray->begin()+(nLength/2)+1 );
-        second.insert( second.end(), pArray->begin()+(nLength/2)+1, pArray->end() );
-
-        PdfObject* pChild1;
-        PdfObject* pChild2 = this->GetObject()->GetOwner()->CreateObject();
-
-        if( !m_pParent ) 
-        {
-            m_bHasKids = true;
-            pChild1    = this->GetObject()->GetOwner()->CreateObject();
-            this->GetObject()->GetDictionary().RemoveKey( "Names" );
-        }
-        else
-        {
-            pChild1 = this->GetObject();
-            kids    = m_pParent->GetObject()->GetDictionary().GetKey("Kids")->GetArray();
-        }
-
-        pChild1->GetDictionary().AddKey( key, first );
-        pChild2->GetDictionary().AddKey( key, second );
-        
-        PdfArray::iterator it = kids.begin();
-        while( it != kids.end() ) 
-        {
-            if( (*it).GetReference() == pChild1->Reference() )
-            {
-                ++it;
-                it = kids.insert( it, pChild2->Reference() );
-                break;
-            }
-            
-            ++it;
-        }
-        
-        if( it == kids.end() )
-        {
-            kids.push_back( pChild1->Reference() );
-            kids.push_back( pChild2->Reference() );
-        }
-
-        if( m_pParent ) 
-            m_pParent->GetObject()->GetDictionary().AddKey( "Kids", kids );
-        else
-            this->GetObject()->GetDictionary().AddKey( "Kids", kids );
-
-        // Important is to the the limits
-        // of the children first,
-        // because SetLimits( pParent )
-        // depends on the /Limits key of all its children!
-        PdfNameTreeNode( NULL, pChild1 ).SetLimits();
-        PdfNameTreeNode( NULL, pChild2 ).SetLimits();
-
-        // limits do only change if splitting name arrays
-        if( m_bHasKids ) 
-            this->SetLimits();
-        else if( m_pParent )
-            m_pParent->SetLimits();
-        
-        return true;
-    }
-
-    return false;
-}
-
-///////////////////////////////////////////////////////////////////////
-
-/*
-  We use NULL for the PdfElement name, since the NamesTree dict
-  does NOT have a /Type key!
-*/
-PdfNamesTree::PdfNamesTree( PdfVecObjects* pParent )
-    : PdfElement( NULL, pParent ), m_pCatalog( NULL )
-{
-}
-
-PdfNamesTree::PdfNamesTree( PdfObject* pObject, PdfObject* pCatalog )
-    : PdfElement( NULL, pObject ), m_pCatalog( pCatalog )
-{
-}
-
-void PdfNamesTree::AddValue( const PdfName & tree, const PdfString & key, const PdfObject & rValue )
-{
-    PdfNameTreeNode root( NULL, this->GetRootNode( tree, true ) );    
-    if( !root.AddValue( key, rValue ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-    }
-}
-
-PdfObject* PdfNamesTree::GetValue( const PdfName & tree, const PdfString & key ) const 
-{
-    PdfObject* pObject = this->GetRootNode( tree );
-    PdfObject* pResult = NULL;
-
-    if( pObject )
-    {
-        pResult = this->GetKeyValue( pObject, key );
-        if( pResult && pResult->IsReference() )
-            pResult = this->GetObject()->GetOwner()->GetObject( pResult->GetReference() );
-    }
-
-    return pResult;
-}
-
-PdfObject* PdfNamesTree::GetKeyValue( PdfObject* pObj, const PdfString & key ) const
-{
-    if( PdfNamesTree::CheckLimits( pObj, key ) != ePdfNameLimits_Inside )
-        return NULL;
-
-    if( pObj->GetDictionary().HasKey("Kids") )
-    {
-        const PdfArray & kids       = pObj->GetDictionary().GetKey("Kids")->GetArray();
-        PdfArray::const_iterator it = kids.begin();
-
-        while( it != kids.end() )
-        {
-            PdfObject* pChild = this->GetObject()->GetOwner()->GetObject( (*it).GetReference() );
-            if( pChild ) 
-            {
-                PdfObject* pResult = GetKeyValue( pChild, key );
-                if( pResult ) // If recursive call returns NULL, 
-                              // continue with the next element
-                              // in the kids array.
-                    return pResult;
-            }
-            else
-                PdfError::LogMessage( eLogSeverity_Debug, "Object %lu %lu is child of nametree but was not found!", 
-                                      (*it).GetReference().ObjectNumber(), 
-                                      (*it).GetReference().GenerationNumber() );
-
-            ++it;
-        }
-    }
-    else
-    {
-        const PdfArray & names      = pObj->GetDictionary().GetKey("Names")->GetArray();
-        PdfArray::const_iterator it = names.begin();
-
-        // a names array is a set of PdfString/PdfObject pairs
-        // so we loop in sets of two - getting each pair
-        while( it != names.end() ) 
-        {
-            if( (*it).GetString() == key ) 
-            {
-                ++it;
-                return this->GetObject()->GetOwner()->GetObject( (*it).GetReference() );
-            }
-
-            it += 2;
-        }
-        
-    }
-
-    return NULL;
-}
-
-PdfObject* PdfNamesTree::GetRootNode( const PdfName & name, bool bCreate ) const
-{
-    PdfObject* pObj = this->GetObject()->GetIndirectKey( name );
-    if( !pObj && bCreate ) 
-    {
-        pObj = this->GetObject()->GetOwner()->CreateObject();
-        this->GetNonConstObject()->GetDictionary().AddKey( name, pObj->Reference() );
-    }
-
-    return pObj;
-}
-
-bool PdfNamesTree::HasValue( const PdfName & tree, const PdfString & key ) const
-{
-    return ( this->GetValue( tree, key ) != NULL );
-}
-
-EPdfNameLimits PdfNamesTree::CheckLimits( const PdfObject* pObj, const PdfString & key )
-{
-    if( pObj->GetDictionary().HasKey("Limits") ) 
-    {
-        const PdfArray & limits = pObj->GetDictionary().GetKey("Limits")->GetArray();
-
-        if( limits[0].GetString() > key )
-            return ePdfNameLimits_Before;
-
-        if( limits[1].GetString() < key )
-            return ePdfNameLimits_After;
-    }
-    else
-    {
-        PdfError::LogMessage( eLogSeverity_Debug, "Name tree object %lu %lu does not have a limits key!", 
-                              pObj->Reference().ObjectNumber(), 
-                              pObj->Reference().GenerationNumber() );
-    }
-
-    return ePdfNameLimits_Inside;
-}
-
-void PdfNamesTree::ToDictionary( const PdfName & tree, PdfDictionary& rDict )
-{
-    rDict.Clear();
-    PdfObject* pObj = this->GetRootNode( tree );
-    if( pObj )
-        AddToDictionary( pObj, rDict );
-}
-
-void PdfNamesTree::AddToDictionary( PdfObject* pObj, PdfDictionary & rDict )
-{
-    if( pObj->GetDictionary().HasKey("Kids") )
-    {
-        const PdfArray & kids       = pObj->GetDictionary().GetKey("Kids")->GetArray();
-        PdfArray::const_iterator it = kids.begin();
-
-        while( it != kids.end() )
-        {
-            PdfObject* pChild = this->GetObject()->GetOwner()->GetObject( (*it).GetReference() );
-            if( pChild ) 
-                this->AddToDictionary( pChild, rDict );
-            else
-                PdfError::LogMessage( eLogSeverity_Debug, "Object %lu %lu is child of nametree but was not found!\n", 
-                                      (*it).GetReference().ObjectNumber(), 
-                                      (*it).GetReference().GenerationNumber() );
-
-            ++it;
-        }
-    }
-    else if( pObj->GetDictionary().HasKey("Names") )
-    {
-        const PdfArray & names      = pObj->GetDictionary().GetKey("Names")->GetArray();
-        PdfArray::const_iterator it = names.begin();
-
-        // a names array is a set of PdfString/PdfObject pairs
-        // so we loop in sets of two - getting each pair
-        while( it != names.end() ) 
-        {
-            // convert all strings into names 
-            PdfName name( (*it).GetString().GetString() );
-            ++it;
-            rDict.AddKey( name, *(it) );
-            ++it;
-        }
-        
-    }
-
-}
-
-};
-
--- src/doc/PdfPage.cpp.orig	2024-06-29 17:32:05.147339529 +0000
+++ src/doc/PdfPage.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,629 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfPage.h" 
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfDictionary.h"
-#include "base/PdfRect.h"
-#include "base/PdfVariant.h"
-#include "base/PdfWriter.h"
-
-#include "PdfDocument.h"
-
-namespace PoDoFo {
-
-PdfPage::PdfPage( const PdfRect & rSize, PdfDocument* pParent )
-    : PdfElement( "Page", pParent ), PdfCanvas(), m_pContents( NULL )
-{
-    InitNewPage( rSize );
-}
-
-PdfPage::PdfPage( const PdfRect & rSize, PdfVecObjects* pParent )
-    : PdfElement( "Page", pParent ), PdfCanvas(), m_pContents( NULL )
-{
-    InitNewPage( rSize );
-}
-
-PdfPage::PdfPage( PdfObject* pObject, const std::deque<PdfObject*> & rListOfParents )
-    : PdfElement( "Page", pObject ), PdfCanvas()
-{
-    m_pResources = this->GetObject()->GetIndirectKey( "Resources" );
-    if( !m_pResources ) 
-    {
-        // Resources might be inherited
-        std::deque<PdfObject*>::const_reverse_iterator it = rListOfParents.rbegin();
-
-        while( it != rListOfParents.rend() && !m_pResources )
-        {
-            m_pResources = (*it)->GetIndirectKey( "Resources" );
-            ++it;
-        }
-    }
-
-    PdfObject* pContents = this->GetObject()->GetIndirectKey( "Contents" );
-    if (pContents)
-    {
-        m_pContents = new PdfContents( pContents );
-    }
-    else
-    {
-        // Create object on demand
-        m_pContents =  NULL;
-    }
-}
-
-PdfPage::~PdfPage()
-{
-    TIMapAnnotation it = m_mapAnnotations.begin();
-
-    while( it != m_mapAnnotations.end() )
-    {
-        delete (*it).second;
-
-        ++it;
-    }
-
-    delete m_pContents;	// just clears the C++ object from memory, NOT the PdfObject
-}
-
-void PdfPage::InitNewPage( const PdfRect & rSize )
-{
-    PdfVariant mediabox;
-    rSize.ToVariant( mediabox );
-    this->GetObject()->GetDictionary().AddKey( "MediaBox", mediabox );
-
-    // The PDF specification suggests that we send all available PDF Procedure sets
-    this->GetObject()->GetDictionary().AddKey( "Resources", PdfObject( PdfDictionary() ) );
-
-    m_pResources = this->GetObject()->GetIndirectKey( "Resources" );
-    m_pResources->GetDictionary().AddKey( "ProcSet", PdfCanvas::GetProcSet() );
-}
-
-void PdfPage::CreateContents() 
-{
-    if( !m_pContents ) 
-    {
-        m_pContents = new PdfContents( this );
-        this->GetObject()->GetDictionary().AddKey( PdfName::KeyContents, 
-                                                   m_pContents->GetContents()->Reference());   
-    }
-}
-
-PdfObject* PdfPage::GetContents() const 
-{ 
-    if( !m_pContents ) 
-    {
-        const_cast<PdfPage*>(this)->CreateContents();
-    }
-
-    return m_pContents->GetContents(); 
-}
-
-PdfObject* PdfPage::GetContentsForAppending() const
-{ 
-    if( !m_pContents ) 
-    {
-        const_cast<PdfPage*>(this)->CreateContents();
-    }
-
-    return m_pContents->GetContentsForAppending(); 
-}
-
-PdfRect PdfPage::CreateStandardPageSize( const EPdfPageSize ePageSize, bool bLandscape )
-{
-    PdfRect rect;
-
-    switch( ePageSize ) 
-    {
-        case ePdfPageSize_A0:
-            rect.SetWidth( 2384.0 );
-            rect.SetHeight( 3370.0 );
-            break;
-
-        case ePdfPageSize_A1:
-            rect.SetWidth( 1684.0 );
-            rect.SetHeight( 2384.0 );
-            break;
-
-        case ePdfPageSize_A2:
-            rect.SetWidth( 1191.0 );
-            rect.SetHeight( 1684.0 );
-            break;
-            
-        case ePdfPageSize_A3:
-            rect.SetWidth( 842.0 );
-            rect.SetHeight( 1190.0 );
-            break;
-
-        case ePdfPageSize_A4:
-            rect.SetWidth( 595.0 );
-            rect.SetHeight( 842.0 );
-            break;
-
-        case ePdfPageSize_A5:
-            rect.SetWidth( 420.0 );
-            rect.SetHeight( 595.0 );
-            break;
-
-        case ePdfPageSize_A6:
-            rect.SetWidth( 297.0 );
-            rect.SetHeight( 420.0 );
-            break;
-
-        case ePdfPageSize_Letter:
-            rect.SetWidth( 612.0 );
-            rect.SetHeight( 792.0 );
-            break;
-            
-        case ePdfPageSize_Legal:
-            rect.SetWidth( 612.0 );
-            rect.SetHeight( 1008.0 );
-            break;
-
-        case ePdfPageSize_Tabloid:
-            rect.SetWidth( 792.0 );
-            rect.SetHeight( 1224.0 );
-            break;
-
-        default:
-            break;
-    }
-
-    if( bLandscape ) 
-    {
-        double dTmp = rect.GetWidth();
-        rect.SetWidth ( rect.GetHeight() );
-        rect.SetHeight(  dTmp );
-    }
-
-    return rect;
-}
-
-const PdfObject* PdfPage::GetInheritedKeyFromObject( const char* inKey, const PdfObject* inObject ) const
-{
-    return GetInheritedKeyFromObject( inKey, inObject, 0 );
-}
-
-const PdfObject* PdfPage::GetInheritedKeyFromObject( const char* inKey, const PdfObject* inObject, int depth ) const
-{
-    const PdfObject* pObj = NULL;
-
-    // check for it in the object itself
-    if ( inObject->GetDictionary().HasKey( inKey ) ) 
-    {
-        pObj = inObject->GetDictionary().GetKey( inKey );
-        if ( !pObj->IsNull() ) 
-            return pObj;
-    }
-    
-    // if we get here, we need to go check the parent - if there is one!
-    if( inObject->GetDictionary().HasKey( "Parent" ) ) 
-    {
-        // CVE-2017-5852 - prevent stack overflow if Parent chain contains a loop, or is very long
-        // e.g. pObj->GetParent() == pObj or pObj->GetParent()->GetParent() == pObj
-        // default stack sizes
-        // Windows: 1 MB
-        // Linux: 2 MB
-        // macOS: 8 MB for main thread, 0.5 MB for secondary threads
-        // 0.5 MB is enough space for 1000 512 byte stack frames and 2000 256 byte stack frames
-        const int maxRecursionDepth = 1000;
-
-        if ( depth > maxRecursionDepth )
-            PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-
-        pObj = inObject->GetIndirectKey( "Parent" );
-        if( pObj == inObject )
-        {
-            std::ostringstream oss;
-            oss << "Object " << inObject->Reference().ObjectNumber() << " "
-                << inObject->Reference().GenerationNumber() << " references itself as Parent";
-            PODOFO_RAISE_ERROR_INFO( ePdfError_BrokenFile, oss.str().c_str() );
-        }
-
-        if( pObj )
-            pObj = GetInheritedKeyFromObject( inKey, pObj, depth + 1 );
-    }
-
-    return pObj;
-}
-
-const PdfRect PdfPage::GetPageBox( const char* inBox ) const
-{
-    PdfRect	 pageBox;
-    const PdfObject*   pObj;
-        
-    // Take advantage of inherited values - walking up the tree if necessary
-    pObj = GetInheritedKeyFromObject( inBox, this->GetObject() );
-    
-
-    // Sometime page boxes are defined using reference objects
-    while ( pObj && pObj->IsReference() )
-    {
-        pObj = this->GetObject()->GetOwner()->GetObject( pObj->GetReference() );
-    }
-
-    // assign the value of the box from the array
-    if ( pObj && pObj->IsArray() )
-    {
-        pageBox.FromArray( pObj->GetArray() );
-    }
-    else if ( strcmp( inBox, "ArtBox" ) == 0   ||
-              strcmp( inBox, "BleedBox" ) == 0 ||
-              strcmp( inBox, "TrimBox" ) == 0  )
-    {
-        // If those page boxes are not specified then
-        // default to CropBox per PDF Spec (3.6.2)
-        pageBox = GetPageBox( "CropBox" );
-    }
-    else if ( strcmp( inBox, "CropBox" ) == 0 )
-    {
-        // If crop box is not specified then
-        // default to MediaBox per PDF Spec (3.6.2)
-        pageBox = GetPageBox( "MediaBox" );
-    }
-    
-    return pageBox;
-}
-
-int PdfPage::GetRotation() const 
-{ 
-    int rot = 0;
-    
-    const PdfObject* pObj = GetInheritedKeyFromObject( "Rotate", this->GetObject() ); 
-    if ( pObj && pObj->IsNumber() )
-        rot = static_cast<int>(pObj->GetNumber());
-    
-    return rot;
-}
-
-void PdfPage::SetRotation(int nRotation)
-{
-    if( nRotation != 0 && nRotation != 90 && nRotation != 180 && nRotation != 270 )
-        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-
-    this->GetObject()->GetDictionary().AddKey( "Rotate", PdfVariant(static_cast<pdf_int64>(nRotation)) );
-}
-
-PdfObject* PdfPage::GetAnnotationsArray( bool bCreate ) const
-{
-    PdfObject* pObj;
-
-    // check for it in the object itself
-    if ( this->GetObject()->GetDictionary().HasKey( "Annots" ) ) 
-    {
-        pObj = this->GetObject()->GetIndirectKey( "Annots" );
-        if( pObj && pObj->IsArray() )
-            return pObj;
-    }
-    else if( bCreate ) 
-    {
-        PdfArray array;
-        this->GetNonConstObject()->GetDictionary().AddKey( "Annots", array );
-        return const_cast<PdfObject*>(this->GetObject()->GetDictionary().GetKey( "Annots" ));
-    }
-
-    return NULL;
-}
-
-int PdfPage::GetNumAnnots() const
-{
-    PdfObject* pObj = this->GetAnnotationsArray();
-
-    return pObj ? static_cast<int>(pObj->GetArray().size()) : 0;
-}
-
-PdfAnnotation* PdfPage::CreateAnnotation( EPdfAnnotation eType, const PdfRect & rRect )
-{
-    PdfAnnotation* pAnnot = new PdfAnnotation( this, eType, rRect, this->GetObject()->GetOwner() );
-    PdfObject*     pObj   = this->GetAnnotationsArray( true );
-    PdfReference   ref    = pAnnot->GetObject()->Reference();
-
-    pObj->GetArray().push_back( ref );
-    m_mapAnnotations[ref] = pAnnot;
-
-    return pAnnot;
-}
-
-PdfAnnotation* PdfPage::GetAnnotation( int index )
-{
-    PdfAnnotation* pAnnot;
-    PdfReference   ref;
-
-    PdfObject*     pObj   = this->GetAnnotationsArray( false );
-
-    if( !(pObj && pObj->IsArray()) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-    
-    if( index < 0 && static_cast<unsigned int>(index) >= pObj->GetArray().size() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-    }
-
-    ref    = pObj->GetArray()[index].GetReference();
-    pAnnot = m_mapAnnotations[ref];
-    if( !pAnnot )
-    {
-        pObj = this->GetObject()->GetOwner()->GetObject( ref );
-        if( !pObj )
-        {
-            PdfError::DebugMessage( "Error looking up object %i %i R\n", ref.ObjectNumber(), ref.GenerationNumber() );
-            PODOFO_RAISE_ERROR( ePdfError_NoObject );
-        }
-     
-        pAnnot = new PdfAnnotation( pObj, this );
-        m_mapAnnotations[ref] = pAnnot;
-    }
-
-    return pAnnot;
-}
-
-void PdfPage::DeleteAnnotation( int index )
-{
-    PdfReference   ref;
-    PdfObject*     pObj   = this->GetAnnotationsArray( false );
-    
-    if( !(pObj && pObj->IsArray()) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-    
-    if( index < 0 && static_cast<unsigned int>(index) >= pObj->GetArray().size() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-    }
-
-    ref    = pObj->GetArray()[index].GetReference();
-
-    this->DeleteAnnotation( ref );
-}
-
-void PdfPage::DeleteAnnotation( const PdfReference & ref )
-{
-    PdfAnnotation*     pAnnot;
-    PdfArray::iterator it;
-    PdfObject*         pObj   = this->GetAnnotationsArray( false );
-    bool               bFound = false;
-
-    // delete the annotation from the array
-
-    if( !(pObj && pObj->IsArray()) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    it = pObj->GetArray().begin();
-    while( it != pObj->GetArray().end() ) 
-    {
-        if( (*it).GetReference() == ref ) 
-        {
-            pObj->GetArray().erase( it );
-            bFound = true;
-            break;
-        }
-
-        ++it;
-    }
-
-    // if no such annotation was found
-    // throw an error instead of deleting
-    // another object with this reference
-    if( !bFound ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_NoObject );
-    }
-
-    // delete any cached PdfAnnotations
-    pAnnot = m_mapAnnotations[ref];
-    if( pAnnot )
-    {
-        delete pAnnot;
-        m_mapAnnotations.erase( ref );
-    }
-
-    // delete the PdfObject in the file
-    delete this->GetObject()->GetOwner()->RemoveObject( ref );
-}
-
-// added by Petr P. Petrov 21 Febrary 2010
-bool PdfPage::SetPageWidth(int newWidth)
-{
-    PdfObject*   pObjMediaBox;
-        
-    // Take advantage of inherited values - walking up the tree if necessary
-    pObjMediaBox = const_cast<PdfObject*>(GetInheritedKeyFromObject( "MediaBox", this->GetObject() ));
-    
-    // assign the value of the box from the array
-    if ( pObjMediaBox && pObjMediaBox->IsArray() )
-    {
-        pObjMediaBox->GetArray()[2].SetNumber(newWidth);
-
-        PdfObject*   pObjCropBox;
-
-        // Take advantage of inherited values - walking up the tree if necessary
-        pObjCropBox = const_cast<PdfObject*>(GetInheritedKeyFromObject( "CropBox", this->GetObject() ));
-
-        if ( pObjCropBox && pObjCropBox->IsArray() )
-        {
-            pObjCropBox->GetArray()[2].SetNumber(newWidth);
-            return true;
-        }else
-        {
-            return false;
-        }
-    }else
-    {
-        return false;
-    }
-}
-
-// added by Petr P. Petrov 21 Febrary 2010
-bool PdfPage::SetPageHeight(int newHeight)
-{
-    PdfObject*   pObj;
-        
-    // Take advantage of inherited values - walking up the tree if necessary
-    pObj = const_cast<PdfObject*>(GetInheritedKeyFromObject( "MediaBox", this->GetObject() ));
-    
-    // assign the value of the box from the array
-    if ( pObj && pObj->IsArray() )
-    {
-        pObj->GetArray()[3].SetNumber(newHeight);
-
-        PdfObject*   pObjCropBox;
-
-        // Take advantage of inherited values - walking up the tree if necessary
-        pObjCropBox = const_cast<PdfObject*>(GetInheritedKeyFromObject( "CropBox", this->GetObject() ));
-
-        if ( pObjCropBox && pObjCropBox->IsArray() )
-        {
-            pObjCropBox->GetArray()[3].SetNumber(newHeight);
-            return true;
-        }else
-        {
-            return false;
-        }
-    }else
-    {
-        return false;
-    }
-}
-
-void PdfPage::SetTrimBox( const PdfRect & rSize )
-{
-    PdfVariant trimbox;
-    rSize.ToVariant( trimbox );
-    this->GetObject()->GetDictionary().AddKey( "TrimBox", trimbox );
-}
-
-unsigned int PdfPage::GetPageNumber() const
-{
-    unsigned int        nPageNumber = 0;
-    PdfObject*          pParent     = this->GetObject()->GetIndirectKey( "Parent" );
-    PdfReference ref                = this->GetObject()->Reference();
-
-    while( pParent ) 
-    {
-        PdfObject* pKids = pParent->GetIndirectKey( "Kids" );
-        if ( pKids != NULL )
-        {
-            const PdfArray& kids        = pKids->GetArray();
-            PdfArray::const_iterator it = kids.begin();
-
-            while( it != kids.end() && (*it).GetReference() != ref )
-            {
-                PdfObject* pNode = this->GetObject()->GetOwner()->GetObject( (*it).GetReference() );
-
-                if( pNode->GetDictionary().GetKey( PdfName::KeyType ) != NULL 
-                    && pNode->GetDictionary().GetKey( PdfName::KeyType )->GetName() == PdfName( "Pages" ) )
-                {
-                    PdfObject* pCount = pNode->GetIndirectKey( "Count" );
-                    if( pCount != NULL ) {
-                        nPageNumber += static_cast<int>(pCount->GetNumber());
-                    }
-                } else {
-                    // if we do not have a page tree node, 
-                    // we most likely have a page object:
-                    // so the page count is 1
-                    ++nPageNumber;
-                }
-                ++it;
-            }
-        }
-
-        ref     = pParent->Reference();
-        pParent = pParent->GetIndirectKey( "Parent" );
-    }
-
-    return ++nPageNumber;
-}
-
-int PdfPage::GetNumFields() const
-{
-    int                  nCount  = 0;
-    int                  nAnnots = this->GetNumAnnots();
-    const PdfAnnotation* pAnnot  = NULL;
-    for( int i=0;i<nAnnots;i++ )
-    {
-        pAnnot = const_cast<PdfPage*>(this)->GetAnnotation( i );
-        // Count every widget annotation with a FieldType as PdfField
-        if( pAnnot->GetType() == ePdfAnnotation_Widget && 
-            pAnnot->GetObject()->GetDictionary().HasKey( PdfName("FT") ) )
-            ++nCount;
-    }
-
-    return nCount;
-}
-
-PdfField PdfPage::GetField( int index )
-{
-    int            nCount  = 0;
-    int            nAnnots = this->GetNumAnnots();
-    PdfAnnotation* pAnnot  = NULL;
-    for( int i=0;i<nAnnots;i++ )
-    {
-        pAnnot = this->GetAnnotation( i );
-        // Count every widget annotation with a FieldType as PdfField
-        if( pAnnot->GetType() == ePdfAnnotation_Widget && 
-            pAnnot->GetObject()->GetDictionary().HasKey( PdfName("FT") ) )
-        {
-            if( nCount == index )
-            {
-                return PdfField( pAnnot->GetObject(), pAnnot );
-            }
-            else
-                ++nCount;
-        }
-    }
-
-    PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-}
-
-const PdfField PdfPage::GetField( int index ) const
-{
-    PdfField field = const_cast<PdfPage*>(this)->GetField( index );
-    return field;
-}
-
-PdfObject* PdfPage::GetFromResources( const PdfName & rType, const PdfName & rKey )
-{
-    if( m_pResources == NULL ) // Fix CVE-2017-7381
-    {
-        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "No Resources" );
-    } 
-    if( m_pResources->GetDictionary().HasKey( rType ) ) 
-    {
-        // OC 15.08.2010 BugFix: Ghostscript creates here sometimes an indirect reference to a directory
-     // PdfObject* pType = m_pResources->GetDictionary().GetKey( rType );
-        PdfObject* pType = m_pResources->GetIndirectKey( rType );
-        if( pType && pType->IsDictionary() && pType->GetDictionary().HasKey( rKey ) )
-        {
-            const PdfReference & ref = pType->GetDictionary().GetKey( rKey )->GetReference();
-            return this->GetObject()->GetOwner()->GetObject( ref );
-        }
-    }
-    
-    return NULL;
-}
-
-};
--- src/doc/PdfPagesTree.cpp.orig	2024-06-29 17:32:05.125339629 +0000
+++ src/doc/PdfPagesTree.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,833 +0,0 @@
-/***************************************************************************
-*   Copyriht (C) 2006 by Dominik Seichter                                *
-*   domseichter@web.de                                                    *
-*                                                                         *
-*   This program is free software; you can redistribute it and/or modify  *
-*   it under the terms of the GNU Library General Public License as       *
-*   published by the Free Software Foundation; either version 2 of the    *
-*   License, or (at your option) any later version.                       *
-*                                                                         *
-*   This program is distributed in the hope that it will be useful,       *
-*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
-*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
-*   GNU General Public License for more details.                          *
-*                                                                         *
-*   You should have received a copy of the GNU Library General Public     *
-*   License along with this program; if not, write to the                 *
-*   Free Software Foundation, Inc.,                                       *
-*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
-***************************************************************************/
-
-#include "PdfPagesTree.h"
-
-#include "base/PdfDefinesPrivate.h"
-#include <algorithm>
-
-#include "base/PdfArray.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfObject.h"
-#include "base/PdfOutputDevice.h"
-#include "base/PdfVecObjects.h"
-
-#include "PdfPage.h"
-
-#include <iostream>
-namespace PoDoFo {
-
-PdfPagesTree::PdfPagesTree( PdfVecObjects* pParent )
-    : PdfElement( "Pages", pParent ),
-      m_cache( 0 )
-{
-    GetObject()->GetDictionary().AddKey( "Kids", PdfArray() ); // kids->Reference() 
-    GetObject()->GetDictionary().AddKey( "Count", PdfObject( static_cast<pdf_int64>(0LL) ) );
-}
-
-PdfPagesTree::PdfPagesTree( PdfObject* pPagesRoot )
-    : PdfElement( "Pages", pPagesRoot ),
-      m_cache( GetChildCount( pPagesRoot ) )
-{
-    if( !this->GetObject() ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-}
-
-PdfPagesTree::~PdfPagesTree() 
-{
-    m_cache.ClearCache();
-}
-
-int PdfPagesTree::GetTotalNumberOfPages() const
-{
-    return GetChildCount( GetObject() );
-}
-
-PdfPage* PdfPagesTree::GetPage( int nIndex )
-{
-    // if you try to get a page past the end, return NULL
-    // we use >= since nIndex is 0 based
-    if ( nIndex >= GetTotalNumberOfPages() )
-        return NULL;
-
-    // Take a look into the cache first
-    PdfPage* pPage = m_cache.GetPage( nIndex );
-    if( pPage )
-        return pPage;
-
-    // Not in cache -> search tree
-    PdfObjectList lstParents;
-    PdfObject* pObj = this->GetPageNode(nIndex, this->GetRoot(), lstParents);
-    if( pObj ) 
-    {
-        pPage = new PdfPage( pObj, lstParents );
-        m_cache.AddPageObject( nIndex, pPage );
-        return pPage;
-    }
-
-    return NULL;
-}
-
-PdfPage* PdfPagesTree::GetPage( const PdfReference & ref )
-{
-    // We have to search through all pages,
-    // as this is the only way
-    // to instantiate the PdfPage with a correct list of parents
-    for( int i=0;i<this->GetTotalNumberOfPages();i++ ) 
-    {
-        PdfPage* pPage = this->GetPage( i );
-        if( pPage && pPage->GetObject()->Reference() == ref ) 
-            return pPage;
-    }
-    
-    return NULL;
-}
-
-
-void PdfPagesTree::InsertPage( int nAfterPageIndex, PdfPage* inPage )
-{
-    this->InsertPage( nAfterPageIndex, inPage->GetObject() );
-}
-
-void PdfPagesTree::InsertPage( int nAfterPageIndex, PdfObject* pPage )
-{
-    bool bInsertBefore = false;
-
-    if( ePdfPageInsertionPoint_InsertBeforeFirstPage == nAfterPageIndex )
-    {
-        bInsertBefore = true;
-        nAfterPageIndex = 0;
-    }
-    else if( nAfterPageIndex < 0 ) 
-    {
-        // Only ePdfPageInsertionPoint_InsertBeforeFirstPage is valid here
-        PdfError::LogMessage( eLogSeverity_Information,
-                              "Invalid argument to PdfPagesTree::InsertPage: %i (Only ePdfPageInsertionPoint_InsertBeforeFirstPage is valid here).",
-                              nAfterPageIndex );
-        return;
-    }
-
-    //printf("Fetching page node: %i\n", nAfterPageIndex);
-    PdfObjectList lstParents;
-    //printf("Searching page=%i\n", nAfterPageIndex );
-    PdfObject* pPageBefore = this->GetPageNode( nAfterPageIndex, this->GetRoot(), lstParents );
-    
-    //printf("pPageBefore=%p lstParents=%i\n", pPageBefore,lstParents.size() );
-    if( !pPageBefore || lstParents.size() == 0 ) 
-    {
-        if( this->GetTotalNumberOfPages() != 0 ) 
-        {
-            PdfError::LogMessage( eLogSeverity_Critical,
-                                  "Cannot find page %i or page %i has no parents. Cannot insert new page.",
-                                  nAfterPageIndex, nAfterPageIndex );
-            return;
-        }
-        else
-        {
-            // We insert the first page into an empty pages tree
-            PdfObjectList lstPagesTree;
-            lstPagesTree.push_back( this->GetObject() );
-            // Use -1 as index to insert before the empty kids array
-            InsertPageIntoNode( this->GetObject(), lstPagesTree, -1, pPage );
-        }
-    }
-    else
-    {
-        PdfObject* pParent = lstParents.back();
-        //printf("bInsertBefore=%i\n", bInsertBefore );
-        int nKidsIndex = bInsertBefore  ? -1 : this->GetPosInKids( pPageBefore, pParent );
-        //printf("Inserting into node: %p at pos %i\n", pParent, nKidsIndex );
-
-        InsertPageIntoNode( pParent, lstParents, nKidsIndex, pPage );
-    }
-
-    m_cache.InsertPage( (bInsertBefore && nAfterPageIndex == 0) ? ePdfPageInsertionPoint_InsertBeforeFirstPage : nAfterPageIndex );
-}
-
-void PdfPagesTree::InsertPages( int nAfterPageIndex, const std::vector<PdfObject*>& vecPages )
-{
-    bool bInsertBefore = false;
-    if( ePdfPageInsertionPoint_InsertBeforeFirstPage == nAfterPageIndex )
-    {
-        bInsertBefore = true;
-        nAfterPageIndex = 0;
-    }
-    else if( nAfterPageIndex < 0 ) 
-    {
-        // Only ePdfPageInsertionPoint_InsertBeforeFirstPage is valid here
-        PdfError::LogMessage( eLogSeverity_Information,
-                              "Invalid argument to PdfPagesTree::InsertPage: %i (Only ePdfPageInsertionPoint_InsertBeforeFirstPage is valid here).",
-                              nAfterPageIndex );
-        return;
-    }
-
-    PdfObjectList lstParents;
-    PdfObject* pPageBefore = this->GetPageNode( nAfterPageIndex, this->GetRoot(), lstParents );
-    
-    if( !pPageBefore || lstParents.size() == 0 ) 
-    {
-        if( this->GetTotalNumberOfPages() != 0 ) 
-        {
-            PdfError::LogMessage( eLogSeverity_Critical,
-                                  "Cannot find page %i or page %i has no parents. Cannot insert new page.",
-                                  nAfterPageIndex, nAfterPageIndex );
-            return;
-        }
-        else
-        {
-            // We insert the first page into an empty pages tree
-            PdfObjectList lstPagesTree;
-            lstPagesTree.push_back( this->GetObject() );
-            // Use -1 as index to insert before the empty kids array
-            InsertPagesIntoNode( this->GetObject(), lstPagesTree, -1, vecPages );
-        }
-    }
-    else
-    {
-        PdfObject* pParent = lstParents.back();
-        int nKidsIndex = bInsertBefore  ? -1 : this->GetPosInKids( pPageBefore, pParent );
-
-        InsertPagesIntoNode( pParent, lstParents, nKidsIndex, vecPages );
-    }
-
-    m_cache.InsertPages( (bInsertBefore && nAfterPageIndex == 0) ? ePdfPageInsertionPoint_InsertBeforeFirstPage : nAfterPageIndex,  vecPages.size() );
-}
-
-PdfPage* PdfPagesTree::CreatePage( const PdfRect & rSize )
-{
-    PdfPage* pPage = new PdfPage( rSize, GetRoot()->GetOwner() );
-
-    InsertPage( this->GetTotalNumberOfPages() - 1, pPage );
-    m_cache.AddPageObject( this->GetTotalNumberOfPages(), pPage );
-    
-    return pPage;
-}
-
-void PdfPagesTree::CreatePages( const std::vector<PdfRect>& vecSizes )
-{
-    std::vector<PdfPage*> vecPages;
-    std::vector<PdfObject*> vecObjects;
-    for (std::vector<PdfRect>::const_iterator it = vecSizes.begin(); it != vecSizes.end(); ++it)
-    {
-        PdfPage* pPage = new PdfPage( (*it), GetRoot()->GetOwner() );
-        vecPages.push_back( pPage );
-        vecObjects.push_back( pPage->GetObject() );
-    }
-
-    InsertPages( this->GetTotalNumberOfPages() - 1, vecObjects );
-    m_cache.AddPageObjects( this->GetTotalNumberOfPages(), vecPages );
-}
-
-void PdfPagesTree::DeletePage( int nPageNumber )
-{
-    // Delete from cache
-    m_cache.DeletePage( nPageNumber );
-    
-    // Delete from pages tree
-    PdfObjectList lstParents;
-    PdfObject* pPageNode = this->GetPageNode( nPageNumber, this->GetRoot(), lstParents );
-
-    if( !pPageNode ) 
-    {
-        PdfError::LogMessage( eLogSeverity_Information,
-                              "Invalid argument to PdfPagesTree::DeletePage: %i - Page not found\n",
-                              nPageNumber );
-        PODOFO_RAISE_ERROR( ePdfError_PageNotFound );
-    }
-
-    if( lstParents.size() > 0 ) 
-    {
-        PdfObject* pParent = lstParents.back();
-        int nKidsIndex = this->GetPosInKids( pPageNode, pParent );
-        
-        DeletePageFromNode( pParent, lstParents, nKidsIndex, pPageNode );
-    }
-    else
-    {
-        PdfError::LogMessage( eLogSeverity_Error,
-                              "PdfPagesTree::DeletePage: Page %i has no parent - cannot be deleted.\n",
-                              nPageNumber );
-        PODOFO_RAISE_ERROR( ePdfError_PageNotFound );
-    }
-}
-
-
-////////////////////////////////////////////////////
-// Private methods
-////////////////////////////////////////////////////
-
-PdfObject* PdfPagesTree::GetPageNode( int nPageNum, PdfObject* pParent, 
-                                      PdfObjectList & rLstParents ) 
-{
-    if( !pParent ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    if( !pParent->GetDictionary().HasKey( PdfName("Kids") ) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidKey );
-    }
-
-    
-    const PdfObject* pObj = pParent->GetIndirectKey( "Kids" );
-    if( pObj == NULL || !pObj->IsArray() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    const PdfArray & rKidsArray = pObj->GetArray(); 
-    PdfArray::const_iterator it = rKidsArray.begin();
-
-    const size_t numDirectKids = rKidsArray.size();
-    const size_t numKids = GetChildCount(pParent);
-
-    // use <= since nPageNum is 0-based
-    if( static_cast<int>(numKids) <= nPageNum ) 
-    {
-        PdfError::LogMessage( eLogSeverity_Critical,
-	    "Cannot retrieve page %i from a document with only %i pages.",
-                              nPageNum, static_cast<int>(numKids) );
-        return NULL;
-    }
-
-    //printf("Fetching: %i %i %i\n", numDirectKids, numKids, nPageNum );
-    if( numDirectKids == numKids && static_cast<size_t>(nPageNum) < numDirectKids )
-    {
-        // This node has only page nodes as kids,
-        // so we can access the array directly
-        rLstParents.push_back( pParent );
-        return GetPageNodeFromArray( nPageNum, rKidsArray, rLstParents );
-    } 
-    else
-    {
-        // We have to traverse the tree
-        while( it != rKidsArray.end() ) 
-        {
-            if( (*it).IsArray() ) 
-            { // Fixes PDFs broken by having trees with arrays nested once
-                
-                rLstParents.push_back( pParent );
-
-                // the following code is to find the reference to log this with
-                const PdfReference & rIterArrayRef = (*it).Reference();
-                PdfReference refToLog;
-                bool isDirectObject // don't worry about 0-num. indirect ones
-                    = ( !(rIterArrayRef.ObjectNumber() ) );
-                if ( isDirectObject ) 
-		{
-                    if ( !(pObj->Reference().ObjectNumber() ) ) // rKidsArray's
-		    {
-                        refToLog = pParent->Reference();
-                    }
-		    else
-                    {
-                        refToLog = pObj->Reference();
-                    }
-                }
-                else
-                {
-                    refToLog = rIterArrayRef;
-                }
-                PdfError::LogMessage( eLogSeverity_Error,
-                                    "Entry in Kids array is itself an array"
-                    "%s reference: %s\n", isDirectObject ? " (direct object)"
-                    ", in object with" : ",", refToLog.ToString().c_str() );
-
-                    const PdfArray & rIterArray = (*it).GetArray();
-
-                    // is the array large enough to potentially have the page?
-                    if( static_cast<size_t>(nPageNum) < rIterArray.GetSize() )
-                    {
-                        PdfObject* pPageNode = GetPageNodeFromArray( nPageNum,
-                                                    rIterArray, rLstParents );
-                        if ( pPageNode ) // and if not, search further
-                            return pPageNode;
-                    }
-            }
-            else if( (*it).IsReference() ) 
-            {
-                PdfObject* pChild = GetRoot()->GetOwner()->GetObject( (*it).GetReference() );
-                if (!pChild) 
-                {
-                    PdfError::LogMessage( eLogSeverity_Critical, "Requesting page index %i. Child not found: %s\n", 
-                                          nPageNum, (*it).GetReference().ToString().c_str()); 
-                    return NULL;
-                }
-
-                if( this->IsTypePages(pChild) ) 
-                {
-                    int childCount = GetChildCount( pChild );
-                    if( childCount < nPageNum + 1 ) // Pages are 0 based, but count is not
-                    {
-                        // skip this page node
-                        // and go to the next one
-                        nPageNum -= childCount;
-                    }
-                    else
-                    {
-                        rLstParents.push_back( pParent );
-                        return this->GetPageNode( nPageNum, pChild, rLstParents );
-                    }
-                }
-                else if( this->IsTypePage(pChild) ) 
-                {
-                    if( 0 == nPageNum )
-                    {
-                        rLstParents.push_back( pParent );
-                        return pChild;
-                    } 
-
-                    // Skip a normal page
-                    if(nPageNum > 0 )
-                        nPageNum--;
-                }
-		else
-		{
-                    const PdfReference & rLogRef = pChild->Reference();
-                    pdf_objnum nLogObjNum = rLogRef.ObjectNumber();
-                    pdf_gennum nLogGenNum = rLogRef.GenerationNumber();
-		    PdfError::LogMessage( eLogSeverity_Critical,
-                                          "Requesting page index %i. "
-                        "Invalid datatype referenced in kids array: %s\n"
-                        "Reference to invalid object: %i %i R\n", nPageNum,
-                        pChild->GetDataTypeString(), nLogObjNum, nLogGenNum);
-                }
-            }
-            else
-            {
-                PdfError::LogMessage( eLogSeverity_Critical, "Requesting page index %i. Invalid datatype in kids array: %s\n", 
-                                      nPageNum, (*it).GetDataTypeString()); 
-                return NULL;
-            }
-            
-            ++it;
-        }
-    }
-
-    return NULL;
-}
-
-PdfObject* PdfPagesTree::GetPageNodeFromArray( int nPageNum, const PdfArray & rKidsArray, PdfObjectList & rLstParents )
-{
-    if( static_cast<size_t>(nPageNum) >= rKidsArray.GetSize() )
-    {
-        PdfError::LogMessage( eLogSeverity_Critical, "Requesting page index %i from array of size %i\n", 
-                              nPageNum, rKidsArray.size() );
-        return NULL;
-    }
-
-    // TODO: Fill cache immediately with all pages 
-    //       in this kids array
-    PdfVariant rVar = rKidsArray[nPageNum];
-    while( true ) 
-    {
-        if( rVar.IsArray() ) 
-        {
-            // Fixes some broken PDFs who have trees with 1 element kids arrays
-            // Recursive call removed to prevent stack overflow (CVE-2017-8054)
-            // replaced by the following inside this conditional incl. continue
-            const PdfArray & rVarArray = rVar.GetArray();
-            if (rVarArray.GetSize() == 0)
-            {
-                PdfError::LogMessage( eLogSeverity_Critical, "Trying to access"
-                    " first page index of empty array" );
-                return NULL;
-            }
-            PdfVariant rVarFirstEntry = rVarArray[0]; // avoids use-after-free
-            rVar = rVarFirstEntry; // in this line (rVar-ref'd array is freed)
-            continue;
-        }
-        else if( !rVar.IsReference() )
-        {
-            PODOFO_RAISE_ERROR_INFO( ePdfError_NotImplemented, "Cannot handle inline pages." );
-        }
-
-        PdfObject* pgObject = GetRoot()->GetOwner()->GetObject( rVar.GetReference() );
-		if(pgObject==NULL) {
-			PODOFO_RAISE_ERROR_INFO( ePdfError_PageNotFound, "Invalid reference." );
-		}
-        //printf("Reading %s\n", pgObject->Reference().ToString().c_str());
-        // make sure the object is a /Page and not a /Pages with a single kid
-        if( this->IsTypePage(pgObject) ) 
-        {
-            return pgObject;
-        }
-
-        // it's a /Pages with a single kid, so dereference and try again...
-        if (this->IsTypePages(pgObject) ) 
-        {
-            if( !pgObject->GetDictionary().HasKey( "Kids" ) )
-                return NULL;
-
-            if ( std::find( rLstParents.begin(), rLstParents.end(), pgObject )
-                != rLstParents.end() ) // cycle in parent list detected, fend
-            { // off security vulnerability CVE-2017-8054 (infinite recursion)
-                std::ostringstream oss;
-                oss << "Cycle in page tree: child in /Kids array of object "
-                    << ( *(rLstParents.rbegin()) )->Reference().ToString()
-                    << " back-references to object " << pgObject->Reference()
-                    .ToString() << " one of whose descendants the former is.";
-
-                PODOFO_RAISE_ERROR_INFO( ePdfError_PageNotFound, oss.str() );
-            }
-
-            rLstParents.push_back( pgObject );
-            rVar = *(pgObject->GetDictionary().GetKey( "Kids" ));
-        } else {
-	  // Reference to unexpected object
-	  PODOFO_RAISE_ERROR_INFO( ePdfError_PageNotFound, "Reference to unexpected object." );
-	}
-    }
-
-    return NULL;
-}
-
-bool PdfPagesTree::IsTypePage(const PdfObject* pObject) const 
-{
-    if( !pObject )
-        return false;
-
-    if( pObject->GetDictionary().GetKeyAsName( PdfName( "Type" ) ) == PdfName( "Page" ) )
-        return true;
-
-    return false;
-}
-
-bool PdfPagesTree::IsTypePages(const PdfObject* pObject) const 
-{
-    if( !pObject )
-        return false;
-
-    if( pObject->GetDictionary().GetKeyAsName( PdfName( "Type" ) ) == PdfName( "Pages" ) )
-        return true;
-
-    return false;
-}
-
-int PdfPagesTree::GetChildCount( const PdfObject* pNode ) const
-{
-    if( !pNode ) 
-        return 0;
-
-    const PdfObject *pCount = pNode->GetIndirectKey( "Count" );
-    if( pCount != 0 ) {
-        return (pCount->GetDataType() == PoDoFo::ePdfDataType_Number) ?  
-            static_cast<int>( pCount->GetNumber() ):0;
-    } else {
-        return 0;
-    }
-}
-
-int PdfPagesTree::GetPosInKids( PdfObject* pPageObj, PdfObject* pPageParent )
-{
-    if( !pPageParent )
-    {
-        //printf("pPageParent=%p\n", pPageParent );
-        return -1;
-    }
-
-    const PdfArray & rKids = pPageParent->GetDictionary().GetKey( PdfName("Kids") )->GetArray();
-    PdfArray::const_iterator it = rKids.begin();
-
-    int index = 0;
-    while( it != rKids.end() ) 
-    {
-        if( (*it).GetReference() == pPageObj->Reference() )
-        {
-            //printf("Found at: %i \n", index );
-            return index;
-        }
-
-        ++index;
-        ++it;
-    }
-
-    //printf("Not found %i 0 R in %i 0 R\n", pPageObj->Reference().ObjectNumber(),
-    //       pPageParent->Reference().ObjectNumber());
-    return -1;
-}
-
-void PdfPagesTree::InsertPageIntoNode( PdfObject* pParent, const PdfObjectList & rlstParents, 
-                                       int nIndex, PdfObject* pPage )
-{
-    if( !pParent || !pPage ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // 1. Add the reference of the new page to the kids array of pParent
-    // 2. Increase count of every node in lstParents (which also includes pParent)
-    // 3. Add Parent key to the page
-
-    // 1. Add reference
-    const PdfArray oldKids = pParent->GetDictionary().GetKey( PdfName("Kids") )->GetArray();
-    PdfArray::const_iterator it = oldKids.begin();
-    PdfArray newKids;
-
-    newKids.reserve( oldKids.GetSize() + 1 );
-
-    if( nIndex < 0 ) 
-    {
-        newKids.push_back( pPage->Reference() );
-    }
-
-    int i = 0;
-    while( it != oldKids.end() ) 
-    {
-        newKids.push_back( *it );
-
-        if( i == nIndex ) 
-            newKids.push_back( pPage->Reference() );
-
-        ++i;
-        ++it;
-    }
-
-    /*
-    PdfVariant var2( newKids );
-    std::string str2;
-    var2.ToString(str2);
-    printf("newKids= %s\n", str2.c_str() );
-    */
-
-    pParent->GetDictionary().AddKey( PdfName("Kids"), newKids );
- 
-    // 2. increase count
-    PdfObjectList::const_reverse_iterator itParents = rlstParents.rbegin();
-    while( itParents != rlstParents.rend() )
-    {
-        this->ChangePagesCount( *itParents, 1 );
-
-        ++itParents;
-    } 
-
-    // 3. add parent key to the page
-    pPage->GetDictionary().AddKey( PdfName("Parent"), pParent->Reference() );
-}
-
-void PdfPagesTree::InsertPagesIntoNode( PdfObject* pParent, const PdfObjectList & rlstParents, 
-                                       int nIndex, const std::vector<PdfObject*>& vecPages )
-{
-    if( !pParent || !vecPages.size() ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // 1. Add the reference of the new page to the kids array of pParent
-    // 2. Increase count of every node in lstParents (which also includes pParent)
-    // 3. Add Parent key to the page
-
-    // 1. Add reference
-    const PdfArray oldKids = pParent->GetDictionary().GetKey( PdfName("Kids") )->GetArray();
-    PdfArray newKids;
-    newKids.reserve( oldKids.GetSize() + vecPages.size() );
-
-    bool bIsPushedIn = false;
-    int i=0;
-    for (PdfArray::const_iterator it=oldKids.begin(); it!=oldKids.end(); ++it, ++i ) 
-    {
-        if ( !bIsPushedIn && (nIndex < i) )    // Pushing before
-        {
-            for (std::vector<PdfObject*>::const_iterator itPages=vecPages.begin(); itPages!=vecPages.end(); ++itPages)
-            {
-                newKids.push_back( (*itPages)->Reference() );    // Push all new kids at once
-            }
-            bIsPushedIn = true;
-        }
-        newKids.push_back( *it );    // Push in the old kids
-    }
-
-    // If new kids are still not pushed in then they may be appending to the end
-    if ( !bIsPushedIn && ( (nIndex + 1) == static_cast<int>(oldKids.size())) ) 
-    {
-        for (std::vector<PdfObject*>::const_iterator itPages=vecPages.begin(); itPages!=vecPages.end(); ++itPages)
-        {
-            newKids.push_back( (*itPages)->Reference() );    // Push all new kids at once
-        }
-        bIsPushedIn = true;
-    }
-
-    pParent->GetDictionary().AddKey( PdfName("Kids"), newKids );
- 
-
-    // 2. increase count
-    for ( PdfObjectList::const_reverse_iterator itParents = rlstParents.rbegin(); itParents != rlstParents.rend(); ++itParents )
-    {
-        this->ChangePagesCount( *itParents, vecPages.size() );
-    } 
-
-    // 3. add parent key to each of the pages
-    for (std::vector<PdfObject*>::const_iterator itPages=vecPages.begin(); itPages!=vecPages.end(); ++itPages)
-    {
-        (*itPages)->GetDictionary().AddKey( PdfName("Parent"), pParent->Reference() );
-    }
-}
-
-void PdfPagesTree::DeletePageFromNode( PdfObject* pParent, const PdfObjectList & rlstParents, 
-                                       int nIndex, PdfObject* pPage )
-{
-    if( !pParent || !pPage ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // 1. Delete the reference from the kids array of pParent
-    // 2. Decrease count of every node in lstParents (which also includes pParent)
-    // 3. Remove empty page nodes
-
-    // TODO: Tell cache to free page object
-
-    // 1. Delete reference
-    this->DeletePageNode( pParent, nIndex ) ;
-
-    // 2. Decrease count
-    PdfObjectList::const_reverse_iterator itParents = rlstParents.rbegin();
-    while( itParents != rlstParents.rend() )
-    {
-        this->ChangePagesCount( *itParents, -1 );
-
-        ++itParents;
-    } 
-
-    // 3. Remove empty pages nodes
-    itParents = rlstParents.rbegin();
-    while( itParents != rlstParents.rend() )
-    {
-        // Never delete root node
-        if( IsEmptyPageNode( *itParents ) && *itParents != GetRoot() ) 
-        {
-            PdfObject* pParentOfNode = *(itParents + 1);
-            int nKidsIndex = this->GetPosInKids( *itParents, pParentOfNode );
-            DeletePageNode( pParentOfNode, nKidsIndex );
-
-            // Delete empty page nodes
-            delete this->GetObject()->GetOwner()->RemoveObject( (*itParents)->Reference() );
-        }
-
-        ++itParents;
-    } 
-}
-
-void PdfPagesTree::DeletePageNode( PdfObject* pParent, int nIndex ) 
-{
-    PdfArray kids = pParent->GetDictionary().GetKey( PdfName("Kids") )->GetArray();
-    kids.erase( kids.begin() + nIndex );
-    pParent->GetDictionary().AddKey( PdfName("Kids"), kids );
-}
-
-int PdfPagesTree::ChangePagesCount( PdfObject* pPageObj, int nDelta )
-{
-    // Increment or decrement inPagesDict's Count by inDelta, and return the new count.
-    // Simply return the current count if inDelta is 0.
-    int	cnt = GetChildCount( pPageObj );
-    if( 0 != nDelta ) 
-    {
-        cnt += nDelta ;
-        pPageObj->GetDictionary().AddKey( "Count", PdfVariant( static_cast<pdf_int64>(cnt) ) );
-    }
-
-    return cnt ;
-}
-
-bool PdfPagesTree::IsEmptyPageNode( PdfObject* pPageNode ) 
-{
-    long lCount = GetChildCount( pPageNode );
-    bool bKidsEmpty = true;
-
-    if( pPageNode->GetDictionary().HasKey( PdfName("Kids") ) )
-    {
-        bKidsEmpty = pPageNode->GetDictionary().GetKey( PdfName("Kids") )->GetArray().empty();
-    }
-
-    return ( lCount == 0L || bKidsEmpty );
-}
-
-/*
-PdfObject* PdfPagesTree::GetPageNode( int nPageNum, PdfObject* pPagesObject, 
-                                      std::deque<PdfObject*> & rListOfParents )
-{
-    // recurse through the pages tree nodes
-    PdfObject* pObj            = NULL;
-
-    if( !pPagesObject->GetDictionary().HasKey( "Kids" ) )
-        return NULL;
-
-    pObj = pPagesObject->GetDictionary().GetKey( "Kids" );
-    if( !pObj->IsArray() )
-        return NULL;
-
-    PdfArray&	kidsArray = pObj->GetArray();
-    size_t	numKids   = kidsArray.size();
-    size_t      kidsCount = GetChildCount( pPagesObject );
-
-    // All parents of the page node will be added to this lists,
-    // so that the PdfPage can later access inherited attributes
-    rListOfParents.push_back( pPagesObject );
-
-    // the pages tree node represented by pPagesObject has only page nodes in its kids array,
-    // or pages nodes with a kid count of 1, so we can speed things up
-    // by going straight to the desired node
-    if ( numKids == kidsCount )
-    {
-        if( nPageNum >= static_cast<int>(kidsArray.size()) )
-        {
-            PdfError::LogMessage( eLogSeverity_Critical, "Requesting page index %i from array of size %i\n", nPageNum, kidsArray.size() );
-            nPageNum--;
-        }
-
-        PdfVariant pgVar = kidsArray[ nPageNum ];
-        while ( true ) 
-        {
-            if ( pgVar.IsArray() ) 
-            {
-                // Fixes some broken PDFs who have trees with 1 element kids arrays
-                return GetPageNodeFromTree( nPageNum, pgVar.GetArray(), rListOfParents );
-            }
-            else if ( !pgVar.IsReference() )
-                return NULL;	// can't handle inline pages just yet...
-
-            PdfObject* pgObject = GetRoot()->GetOwner()->GetObject( pgVar.GetReference() );
-            // make sure the object is a /Page and not a /Pages with a single kid
-            if ( pgObject->GetDictionary().GetKeyAsName( PdfName( "Type" ) ) == PdfName( "Page" ) )
-                return pgObject;
-
-            // it's a /Pages with a single kid, so dereference and try again...
-            if( !pgObject->GetDictionary().HasKey( "Kids" ) )
-                return NULL;
-
-            rListOfParents.push_back( pgObject );
-            pgVar = *(pgObject->GetDictionary().GetKey( "Kids" ));
-        }
-    } 
-    else 
-    {
-        return GetPageNodeFromTree( nPageNum, kidsArray, rListOfParents );
-    }
-
-    // we should never exit from here - we should always have been able to return a page from above
-    // PODOFO_ASSERT( false ) ;
-    return NULL;
-}
-*/
-
-};
--- src/doc/PdfPainter.cpp.orig	2024-06-29 17:32:05.028340067 +0000
+++ src/doc/PdfPainter.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,1770 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200
-#pragma warning(disable: 4786)
-#endif
-
-#include <iostream>
-#include <iomanip>
-#include <vector>
-
-#include "PdfPainter.h"
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfColor.h"
-#include "base/PdfDictionary.h"
-#include "base/PdfFilter.h"
-#include "base/PdfName.h"
-#include "base/PdfRect.h"
-#include "base/PdfStream.h"
-#include "base/PdfString.h"
-#include "base/PdfLocale.h"
-
-#include "PdfContents.h"
-#include "PdfExtGState.h"
-#include "PdfFont.h"
-#include "PdfFontMetrics.h"
-#include "PdfImage.h"
-#include "PdfMemDocument.h"
-#include "PdfShadingPattern.h"
-#include "PdfXObject.h"
-
-
-#include <stdlib.h>
-
-#define BEZIER_POINTS 13
-
-/* 4/3 * (1-cos 45�)/sin 45� = 4/3 * sqrt(2) - 1 */
-#define ARC_MAGIC    0.552284749f
-#define PI           3.141592654f
-
-namespace PoDoFo {
-
-static const long clPainterHighPrecision    = 15L;
-static const long clPainterDefaultPrecision = 3L;
-
-static inline void CheckDoubleRange( double val, double min, double max )
-{
-    if( val < min || val > max )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_ValueOutOfRange );
-    }
-}
-
-static inline unsigned short SwapBytes(unsigned short val)
-{
-	return ((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8);
-}
-
-static inline unsigned short SwapCharBytesIfRequired(pdf_utf16be ch)
-{
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-	return SwapBytes(ch);
-#else
-	return ch;
-#endif
-}
-
-static inline bool IsNewLineChar(pdf_utf16be ch)
-{
-	return SwapCharBytesIfRequired(ch) == '\n';
-}
-
-static inline bool IsSpaceChar(pdf_utf16be ch)
-{
-	return isspace( SwapCharBytesIfRequired(ch) & 0x00FF ) != 0;
-}
-
-PdfPainter::PdfPainter()
-: m_pCanvas( NULL ), m_pPage( NULL ), m_pFont( NULL ), m_nTabWidth( 4 ),
-  m_curColor( PdfColor( 0.0, 0.0, 0.0 ) ),
-  m_isTextOpen( false ), m_oss()
-{
-    m_oss.flags( std::ios_base::fixed );
-    m_oss.precision( clPainterDefaultPrecision );
-    PdfLocaleImbue(m_oss);
-
-    lpx  = 
-    lpy  = 
-    lpx2 = 
-    lpy2 = 
-    lpx3 = 
-    lpy3 = 
-    lcx  =
-    lcy  = 
-    lrx  = 
-    lry  = 0.0;
-}
-
-PdfPainter::~PdfPainter()
-{
-	// Throwing exceptions in C++ destructors is not allowed.
-	// Just log the error.
-    // PODOFO_RAISE_LOGIC_IF( m_pCanvas, "FinishPage() has to be called after a page is completed!" );
-    // Note that we can't do this for the user, since FinishPage() might
-    // throw and we can't safely have that in a dtor. That also means
-    // we can't throw here, but must abort.
-    if( m_pCanvas )
-        PdfError::LogMessage( eLogSeverity_Error, 
-                              "PdfPainter::~PdfPainter(): FinishPage() has to be called after a page is completed!" );
-
-    PODOFO_ASSERT( !m_pCanvas );
-}
-
-void PdfPainter::SetPage( PdfCanvas* pPage )
-{
-    // Ignore setting the same page twice
-    if( m_pPage == pPage )
-        return;
-
-    if( m_pCanvas )
-        m_pCanvas->EndAppend();
-
-    m_pPage   = pPage;
-
-    m_pCanvas = pPage ? pPage->GetContentsForAppending()->GetStream() : NULL;
-    if ( m_pCanvas ) 
-    {
-		// GetLength() must be called before BeginAppend()
-        if ( m_pCanvas->GetLength() ) 
-		{
-	        m_pCanvas->BeginAppend( false );
-            // there is already content here - so let's assume we are appending
-            // as such, we MUST put in a "space" to separate whatever we do.
-            m_pCanvas->Append( " " );
-        }
-		else
-	        m_pCanvas->BeginAppend( false );
-    } 
-    else 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-}
-
-void PdfPainter::FinishPage()
-{
-	try { 
-		if( m_pCanvas )
-			m_pCanvas->EndAppend();
-	} catch( PdfError & e ) {
-	    // clean up, even in case of error
-		m_pCanvas = NULL;
-		m_pPage   = NULL;
-
-		throw e;
-	}
-
-    m_pCanvas = NULL;
-    m_pPage   = NULL;
-}
-
-void PdfPainter::SetStrokingGray( double g )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    CheckDoubleRange( g, 0.0, 1.0 );
-
-    this->SetStrokingColor( PdfColor( g ) );
-}
-
-void PdfPainter::SetGray( double g )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    CheckDoubleRange( g, 0.0, 1.0 );
-
-    this->SetColor( PdfColor( g ) );
-}
-
-void PdfPainter::SetStrokingColor( double r, double g, double b )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    CheckDoubleRange( r, 0.0, 1.0 );
-    CheckDoubleRange( g, 0.0, 1.0 );
-    CheckDoubleRange( b, 0.0, 1.0 );
-
-    this->SetStrokingColor( PdfColor( r, g, b ) );
-}
-
-void PdfPainter::SetColor( double r, double g, double b )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    CheckDoubleRange( r, 0.0, 1.0 );
-    CheckDoubleRange( g, 0.0, 1.0 );
-    CheckDoubleRange( b, 0.0, 1.0 );
-
-    this->SetColor( PdfColor( r, g, b ) );
-}
-
-void PdfPainter::SetStrokingColorCMYK( double c, double m, double y, double k )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    CheckDoubleRange( c, 0.0, 1.0 );
-    CheckDoubleRange( m, 0.0, 1.0 );
-    CheckDoubleRange( y, 0.0, 1.0 );
-    CheckDoubleRange( k, 0.0, 1.0 );
-
-    this->SetStrokingColor( PdfColor( c, m, y, k ) );
-}
-
-void PdfPainter::SetColorCMYK( double c, double m, double y, double k )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-    CheckDoubleRange( c, 0.0, 1.0 );
-    CheckDoubleRange( m, 0.0, 1.0 );
-    CheckDoubleRange( y, 0.0, 1.0 );
-    CheckDoubleRange( k, 0.0, 1.0 );
-
-    this->SetColor( PdfColor( c, m, y, k ) );
-}
-
-void PdfPainter::SetStrokingShadingPattern( const PdfShadingPattern & rPattern )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    this->AddToPageResources( rPattern.GetIdentifier(), rPattern.GetObject()->Reference(), PdfName("Pattern") );
-
-    m_oss.str("");
-    m_oss << "/Pattern CS /" << rPattern.GetIdentifier().GetName() << " SCN" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetShadingPattern( const PdfShadingPattern & rPattern )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    this->AddToPageResources( rPattern.GetIdentifier(), rPattern.GetObject()->Reference(), PdfName("Pattern") );
-
-    m_oss.str("");
-    m_oss << "/Pattern cs /" << rPattern.GetIdentifier().GetName() << " scn" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetStrokingColor( const PdfColor & rColor )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-
-    switch( rColor.GetColorSpace() ) 
-    {
-        default: 
-        case ePdfColorSpace_DeviceRGB:
-            m_oss << rColor.GetRed()   << " "
-                  << rColor.GetGreen() << " "
-                  << rColor.GetBlue() 
-                  << " RG" << std::endl;
-            break;
-        case ePdfColorSpace_DeviceCMYK:
-            m_oss << rColor.GetCyan()    << " " 
-                  << rColor.GetMagenta() << " " 
-                  << rColor.GetYellow()  << " " 
-                  << rColor.GetBlack() 
-                  << " K" << std::endl;
-            break;
-        case ePdfColorSpace_DeviceGray:
-            m_oss << rColor.GetGrayScale() << " G" << std::endl;
-            break;
-        case ePdfColorSpace_Separation:
-			m_pPage->AddColorResource( rColor );
-			m_oss << "/ColorSpace" << PdfName( rColor.GetName() ).GetEscapedName() << " CS " << rColor.GetDensity() << " SCN" << std::endl;
-            break;
-        case ePdfColorSpace_CieLab:
-			m_pPage->AddColorResource( rColor );
-			m_oss << "/ColorSpaceCieLab" << " CS " 
-				  << rColor.GetCieL() << " " 
-                  << rColor.GetCieA() << " " 
-                  << rColor.GetCieB() <<
-				  " SCN" << std::endl;
-            break;
-        case ePdfColorSpace_Unknown:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-        }
-    }
-
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetColor( const PdfColor & rColor )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-
-    m_curColor = rColor;
-    switch( rColor.GetColorSpace() ) 
-    {
-        default: 
-        case ePdfColorSpace_DeviceRGB:
-            m_oss << rColor.GetRed()   << " "
-                  << rColor.GetGreen() << " "
-                  << rColor.GetBlue() 
-                  << " rg" << std::endl;
-            break;
-        case ePdfColorSpace_DeviceCMYK:
-            m_oss << rColor.GetCyan()    << " " 
-                  << rColor.GetMagenta() << " " 
-                  << rColor.GetYellow()  << " " 
-                  << rColor.GetBlack() 
-                  << " k" << std::endl;
-            break;
-        case ePdfColorSpace_DeviceGray:
-            m_oss << rColor.GetGrayScale() << " g" << std::endl;
-            break;
-        case ePdfColorSpace_Separation:
-			m_pPage->AddColorResource( rColor );
-            m_oss << "/ColorSpace" << PdfName( rColor.GetName() ).GetEscapedName() << " cs " << rColor.GetDensity() << " scn" << std::endl;
-            break;
-        case ePdfColorSpace_CieLab:
-			m_pPage->AddColorResource( rColor );
-			m_oss << "/ColorSpaceCieLab" << " cs " 
-				  << rColor.GetCieL() << " " 
-                  << rColor.GetCieA() << " " 
-                  << rColor.GetCieB() <<
-				  " scn" << std::endl;
-			break;
-        case ePdfColorSpace_Unknown:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_CannotConvertColor );
-        }
-    }
-
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetStrokeWidth( double dWidth )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-    m_oss << dWidth << " w" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetStrokeStyle( EPdfStrokeStyle eStyle, const char* pszCustom )
-{
-    const char* pszCurStroke = NULL;
-
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    // TODO: fix the stroking styles
-    switch( eStyle )
-    {
-        case ePdfStrokeStyle_Solid:
-            pszCurStroke = "[] 0";
-            break;
-        case ePdfStrokeStyle_Dash:
-            pszCurStroke = "[3] 0";
-            break;
-        case ePdfStrokeStyle_Dot:
-            pszCurStroke = "[1] 0";
-            break;
-        case ePdfStrokeStyle_DashDot:
-            pszCurStroke = "[3 1 1] 0";
-            break;
-        case ePdfStrokeStyle_DashDotDot:
-            pszCurStroke = "[3 1 1 1 1] 0";
-            break;
-        case ePdfStrokeStyle_Custom:
-            pszCurStroke = pszCustom;
-            break;
-        default:
-        {
-            PODOFO_RAISE_ERROR( ePdfError_InvalidStrokeStyle );
-        }
-    }
-
-    if( !pszCurStroke )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidStrokeStyle );
-    }
-    
-    m_oss.str("");
-    m_oss << pszCurStroke << " d" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetLineCapStyle( EPdfLineCapStyle eCapStyle )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-    m_oss << static_cast<int>(eCapStyle) << " J" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetLineJoinStyle( EPdfLineJoinStyle eJoinStyle )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-    m_oss << static_cast<int>(eJoinStyle) << "j" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetFont( PdfFont* pFont )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    if( !pFont )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_pFont = pFont;
-}
-
-void PdfPainter::SetClipRect( double dX, double dY, double dWidth, double dHeight )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-    m_oss << dX << " "
-          << dY << " "
-          << dWidth << " "
-          << dHeight        
-          << " re W n" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::DrawLine( double dStartX, double dStartY, double dEndX, double dEndY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    m_oss.str("");
-    m_oss << dStartX << " "
-          << dStartY
-          << " m "
-          << dEndX << " "
-          << dEndY        
-          << " l S" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::DrawRect( double dX, double dY, double dWidth, double dHeight,
-                           double dRoundX, double dRoundY )
-{ 
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );    
-
-    if ( static_cast<int>(dRoundX) || static_cast<int>(dRoundY) ) 
-    {
-        double x = dX, y = dY, 
-               w = dWidth, h = dHeight,
-               rx= dRoundX, ry = dRoundY;
-        double b = 0.4477f;
-
-        MoveTo(x + rx, y);
-        LineTo(x + w - rx, y);
-        CubicBezierTo(x + w - rx * b, y, x + w, y + ry * b, x + w, y + ry);
-        LineTo(x + w, y + h - ry);
-        CubicBezierTo(x + w, y + h - ry * b, x + w - rx * b, y + h, x + w - rx, y + h);
-        LineTo(x + rx, y + h);
-        CubicBezierTo(x + rx * b, y + h, x, y + h - ry * b, x, y + h - ry);
-        LineTo(x, y + ry);
-        CubicBezierTo(x, y + ry * b, x + rx * b, y, x + rx, y);
-        m_pCanvas->Append( "S\n" );
-    } 
-    else 
-    {
-        m_oss.str("");
-        m_oss << dX << " "
-              << dY << " "
-              << dWidth << " "
-              << dHeight        
-              << " re S" << std::endl;
-        m_pCanvas->Append( m_oss.str() );
-    }
-}
-
-void PdfPainter::FillRect( double dX, double dY, double dWidth, double dHeight,
-                           double dRoundX, double dRoundY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    m_oss.str("");
-
-    if ( static_cast<int>(dRoundX) || static_cast<int>(dRoundY) ) 
-    {
-        double    x = dX, y = dY, 
-            w = dWidth, h = dHeight,
-            rx = dRoundX, ry = dRoundY;
-        double b = 0.4477f;
-
-        MoveTo(x + rx, y);
-        LineTo(x + w - rx, y);
-        CubicBezierTo(x + w - rx * b, y, x + w, y + ry * b, x + w, y + ry);
-        LineTo(x + w, y + h - ry);
-        CubicBezierTo(x + w, y + h - ry * b, x + w - rx * b, y + h, x + w - rx, y + h);
-        LineTo(x + rx, y + h);
-        CubicBezierTo(x + rx * b, y + h, x, y + h - ry * b, x, y + h - ry);
-        LineTo(x, y + ry);
-        CubicBezierTo(x, y + ry * b, x + rx * b, y, x + rx, y);
-        m_pCanvas->Append( "f\n" );
-    }
-    else 
-    {
-        m_oss << dX << " "
-            << dY << " "
-            << dWidth << " "
-            << dHeight        
-            << " re f" << std::endl;
-    }
-
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::DrawEllipse( double dX, double dY, double dWidth, double dHeight )
-{
-    double dPointX[BEZIER_POINTS];
-    double dPointY[BEZIER_POINTS];
-    int    i;
-
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    ConvertRectToBezier( dX, dY, dWidth, dHeight, dPointX, dPointY );
-
-
-    m_oss.str("");
-    m_oss << dPointX[0] << " "
-          << dPointY[0]
-          << " m" << std::endl;
-
-    for( i=1;i<BEZIER_POINTS; i+=3 )
-    {
-        m_oss << dPointX[i] << " "
-              << dPointY[i] << " "
-              << dPointX[i+1] << " "
-              << dPointY[i+1] << " "
-              << dPointX[i+2] << " "
-              << dPointY[i+2]    
-              << " c" << std::endl;
-    }
-
-    m_pCanvas->Append( m_oss.str() );
-    m_pCanvas->Append( "S\n" );
-}
-
-void PdfPainter::FillEllipse( double dX, double dY, double dWidth, double dHeight )
-{
-    double dPointX[BEZIER_POINTS];
-    double dPointY[BEZIER_POINTS];
-    int    i;
-
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    ConvertRectToBezier( dX, dY, dWidth, dHeight, dPointX, dPointY );
-
-    m_oss.str("");
-    m_oss << dPointX[0] << " "
-          << dPointY[0]
-          << " m" << std::endl;
-
-    for( i=1;i<BEZIER_POINTS; i+=3 )
-    {
-        m_oss << dPointX[i] << " "
-              << dPointY[i] << " "
-              << dPointX[i+1] << " "
-              << dPointY[i+1] << " "
-              << dPointX[i+2] << " "
-              << dPointY[i+2]    
-              << " c" << std::endl;
-    }
-
-    m_pCanvas->Append( m_oss.str() );
-    m_pCanvas->Append( "f\n" );
-}
-
-void PdfPainter::FillCircle( double dX, double dY, double dRadius )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    /* draw four Bezier curves to approximate a circle */
-    MoveTo( dX + dRadius, dY );
-    CubicBezierTo( dX + dRadius, dY + dRadius*ARC_MAGIC,
-             dX + dRadius*ARC_MAGIC, dY + dRadius,
-             dX, dY + dRadius );
-    CubicBezierTo( dX - dRadius*ARC_MAGIC, dY + dRadius,
-            dX - dRadius, dY + dRadius*ARC_MAGIC,
-            dX - dRadius, dY );
-    CubicBezierTo( dX - dRadius, dY - dRadius*ARC_MAGIC,
-            dX - dRadius*ARC_MAGIC, dY - dRadius,
-            dX, dY - dRadius );
-    CubicBezierTo( dX + dRadius*ARC_MAGIC, dY - dRadius,
-            dX + dRadius, dY - dRadius*ARC_MAGIC,
-            dX + dRadius, dY );
-    Close();
-
-    m_pCanvas->Append( "f\n" );
-}
-
-void PdfPainter::DrawCircle( double dX, double dY, double dRadius )
-{
-    if( !m_pCanvas )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    /* draw four Bezier curves to approximate a circle */
-    MoveTo( dX + dRadius, dY );
-    CubicBezierTo( dX + dRadius, dY + dRadius*ARC_MAGIC,
-             dX + dRadius*ARC_MAGIC, dY + dRadius,
-             dX, dY + dRadius );
-    CubicBezierTo( dX - dRadius*ARC_MAGIC, dY + dRadius,
-            dX - dRadius, dY + dRadius*ARC_MAGIC,
-            dX - dRadius, dY );
-    CubicBezierTo( dX - dRadius, dY - dRadius*ARC_MAGIC,
-            dX - dRadius*ARC_MAGIC, dY - dRadius,
-            dX, dY - dRadius );
-    CubicBezierTo( dX + dRadius*ARC_MAGIC, dY - dRadius,
-            dX + dRadius, dY - dRadius*ARC_MAGIC,
-            dX + dRadius, dY );
-    Close();
-
-    m_pCanvas->Append( "S\n" );
-}
-
-void PdfPainter::DrawText( double dX, double dY, const PdfString & sText )
-{
-    this->DrawText( dX, dY, sText, static_cast<long>(sText.GetCharacterLength()) );
-}
-
-void PdfPainter::DrawText( double dX, double dY, const PdfString & sText, long lStringLen )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !sText.IsValid() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // Peter Petrov 25 September 2008
-    //m_pFont->EmbedFont();
-
-    PdfString sString = this->ExpandTabs( sText, lStringLen );
-    this->AddToPageResources( m_pFont->GetIdentifier(), m_pFont->GetObject()->Reference(), PdfName("Font") );
-    if( m_pFont->IsSubsetting() )
-    {
-        m_pFont->AddUsedSubsettingGlyphs( sText, lStringLen );
-    }
-
-    if( m_pFont->IsUnderlined() || m_pFont->IsStrikeOut())
-    {
-        this->Save();
-        this->SetCurrentStrokingColor();
-		
-        // Draw underline
-        this->SetStrokeWidth( m_pFont->GetFontMetrics()->GetUnderlineThickness() );
-        if( m_pFont->IsUnderlined() )
-        {
-            if (sString.IsUnicode())
-                this->DrawLine( dX,
-                                dY + m_pFont->GetFontMetrics()->GetUnderlinePosition(),
-                                dX + m_pFont->GetFontMetrics()->StringWidth( sString.GetUnicode() ),
-                                dY + m_pFont->GetFontMetrics()->GetUnderlinePosition() );
-            else
-                this->DrawLine( dX,
-                                dY + m_pFont->GetFontMetrics()->GetUnderlinePosition(),
-                                dX + m_pFont->GetFontMetrics()->StringWidth( sString.GetString() ),
-                                dY + m_pFont->GetFontMetrics()->GetUnderlinePosition() );
-        }
-
-        // Draw strikeout
-        this->SetStrokeWidth( m_pFont->GetFontMetrics()->GetStrikeoutThickness() );
-        if( m_pFont->IsStrikeOut() )
-        {
-            if (sString.IsUnicode())
-                this->DrawLine( dX,
-                                dY + m_pFont->GetFontMetrics()->GetStrikeOutPosition(),
-                                dX + m_pFont->GetFontMetrics()->StringWidth( sString.GetUnicode() ),
-                                dY + m_pFont->GetFontMetrics()->GetStrikeOutPosition() );
-            else
-                this->DrawLine( dX,
-                                dY + m_pFont->GetFontMetrics()->GetStrikeOutPosition(),
-                                dX + m_pFont->GetFontMetrics()->StringWidth( sString.GetString() ),
-                                dY + m_pFont->GetFontMetrics()->GetStrikeOutPosition() );
-        }
-
-        this->Restore();
-    }
-    
-
-
-
-    m_oss.str("");
-    m_oss << "BT" << std::endl << "/" << m_pFont->GetIdentifier().GetName()
-          << " "  << m_pFont->GetFontSize()
-          << " Tf" << std::endl;
-
-    //if( m_pFont->GetFontScale() != 100.0F ) - this value is kept between text blocks
-    m_oss << m_pFont->GetFontScale() << " Tz" << std::endl;
-
-    //if( m_pFont->GetFontCharSpace() != 0.0F )  - this value is kept between text blocks
-    m_oss << m_pFont->GetFontCharSpace() * m_pFont->GetFontSize() / 100.0 << " Tc" << std::endl;
-
-    m_oss << dX << std::endl
-          << dY << std::endl << "Td ";
-
-    m_pCanvas->Append( m_oss.str() );
-    m_pFont->WriteStringToStream( sString, m_pCanvas );
-
-    /*
-    char* pBuffer;
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );
-    pFilter->Encode( sString.GetString(), sString.GetLength(), &pBuffer, &lLen );
-
-    m_pCanvas->Append( pBuffer, lLen );
-    free( pBuffer );
-    */
-
-    m_pCanvas->Append( " Tj\nET\n" );
-}
-
-void PdfPainter::BeginText( double dX, double dY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage ||  m_isTextOpen)
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    this->AddToPageResources( m_pFont->GetIdentifier(), m_pFont->GetObject()->Reference(), PdfName("Font") );
-
-    m_oss.str("");
-    m_oss << "BT" << std::endl << "/" << m_pFont->GetIdentifier().GetName()
-          << " "  << m_pFont->GetFontSize()
-          << " Tf" << std::endl;
-
-    //if( m_pFont->GetFontScale() != 100.0F ) - this value is kept between text blocks
-    m_oss << m_pFont->GetFontScale() << " Tz" << std::endl;
-
-    //if( m_pFont->GetFontCharSpace() != 0.0F )  - this value is kept between text blocks
-    m_oss << m_pFont->GetFontCharSpace() * m_pFont->GetFontSize() / 100.0 << " Tc" << std::endl;
-
-    m_oss << dX << " " << dY << " Td" << std::endl ;
-
-    m_pCanvas->Append( m_oss.str() );
-
-	m_isTextOpen = true;
-}
-
-void PdfPainter::MoveTextPos( double dX, double dY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !m_isTextOpen )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_oss.str("");
-    m_oss << dX << " " << dY << " Td" << std::endl ;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::AddText( const PdfString & sText )
-{
-	AddText( sText, sText.GetCharacterLength() );
-}
-
-void PdfPainter::AddText( const PdfString & sText, pdf_long lStringLen )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !sText.IsValid() || !m_isTextOpen )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    PdfString sString = this->ExpandTabs( sText, lStringLen );
-    if( m_pFont->IsSubsetting() )
-    {
-        m_pFont->AddUsedSubsettingGlyphs( sText, lStringLen );
-    }
-
-	// TODO: Underline and Strikeout not yet supported
-    
-	m_pFont->WriteStringToStream( sString, m_pCanvas );
-
-    m_pCanvas->Append( " Tj\n" );
-}
-
-void PdfPainter::EndText()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !m_isTextOpen )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_pCanvas->Append( "ET\n" );
-	m_isTextOpen = false;
-}
-
-void PdfPainter::DrawMultiLineText( double dX, double dY, double dWidth, double dHeight, const PdfString & rsText, 
-                                    EPdfAlignment eAlignment, EPdfVerticalAlignment eVertical, bool bClip )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !rsText.IsValid() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // Peter Petrov 25 September 2008
-    //m_pFont->EmbedFont();
-    
-    if( dWidth <= 0.0 || dHeight <= 0.0 ) // nonsense arguments
-        return;
-
-    this->Save();
-    if( bClip ) 
-    {
-        this->SetClipRect( dX, dY, dWidth, dHeight );
-    }
-
-    PdfString   sString  = this->ExpandTabs( rsText, rsText.GetCharacterLength() );
-
-	std::vector<PdfString> vecLines = GetMultiLineTextAsLines(dWidth, sString);
-
-    // Do vertical alignment
-    switch( eVertical ) 
-    {
-        default:
-        case ePdfVerticalAlignment_Top:
-            dY += dHeight; break;
-        case ePdfVerticalAlignment_Bottom:
-            dY += m_pFont->GetFontMetrics()->GetLineSpacing() * vecLines.size(); break;
-        case ePdfVerticalAlignment_Center:
-            dY += (dHeight - 
-                   ((dHeight - (m_pFont->GetFontMetrics()->GetLineSpacing() * vecLines.size()))/2.0)); 
-            break;
-    }
-
-    std::vector<PdfString>::const_iterator it = vecLines.begin();
-    while( it != vecLines.end() )
-    {
-        dY -= m_pFont->GetFontMetrics()->GetLineSpacing();
-		if( (*it).GetCharacterLength() )
-            this->DrawTextAligned( dX, dY, dWidth, *it, eAlignment );
-
-        ++it;
-    }
-    this->Restore();
-}
-
-std::vector<PdfString> PdfPainter::GetMultiLineTextAsLines( double dWidth, const PdfString & rsText)
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !rsText.IsValid() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-     
-    if( dWidth <= 0.0 ) // nonsense arguments
-	    return std::vector<PdfString>();
-    
-    if( rsText.GetCharacterLength() == 0 ) // empty string
-        return std::vector<PdfString>(1, rsText);
-	        
-    // We will work with utf16 encoded string because it allows us 
-    // fast and easy individual characters access    
-    const std::string& stringUtf8 = rsText.GetStringUtf8();
-    std::vector<pdf_utf16be> stringUtf16(stringUtf8.length() + 1, 0);
-    PODOFO_ASSERT( stringUtf16.size() > 0 );
-    const pdf_long converted = PdfString::ConvertUTF8toUTF16(
-	    reinterpret_cast<const pdf_utf8*>(stringUtf8.c_str()), &stringUtf16[0], stringUtf16.size());
-	//const pdf_long len = rsText.GetCharacterLength();
-    PODOFO_ASSERT( converted == (rsText.GetCharacterLength() + 1) );
-
-	const pdf_utf16be* const stringUtf16Begin = &stringUtf16[0];
-    const pdf_utf16be* pszLineBegin = stringUtf16Begin;
-    const pdf_utf16be* pszCurrentCharacter = stringUtf16Begin;
-    const pdf_utf16be* pszStartOfCurrentWord  = stringUtf16Begin;
-    bool startOfWord = true;
-    double dCurWidthOfLine = 0.0;
-	std::vector<PdfString> vecLines;
-
-    // do simple word wrapping
-    while( *pszCurrentCharacter ) 
-    {
-        if( IsNewLineChar( *pszCurrentCharacter ) ) // hard-break! 
-        {
-            vecLines.push_back( PdfString( pszLineBegin, pszCurrentCharacter - pszLineBegin ) );
-            ++pszCurrentCharacter; // skip the line feed
-            pszLineBegin = pszCurrentCharacter;
-            startOfWord = true;
-            dCurWidthOfLine = 0.0;
-        }
-        else if( IsSpaceChar( *pszCurrentCharacter ) )
-        {
-            if( dCurWidthOfLine > dWidth )
-            {
-                // The previous word does not fit in the current line.
-                // -> Move it to the next one.
-                vecLines.push_back( PdfString( pszLineBegin, pszStartOfCurrentWord - pszLineBegin ) );
-                pszLineBegin = pszStartOfCurrentWord;
-
-                if (!startOfWord)
-                {
-                    dCurWidthOfLine = m_pFont->GetFontMetrics()->StringWidth( 
-						pszStartOfCurrentWord, pszCurrentCharacter - pszStartOfCurrentWord );
-                }
-                else
-                {
-                    dCurWidthOfLine = 0.0;
-                }
-            }
-            else 
-            {           
-                dCurWidthOfLine += m_pFont->GetFontMetrics()->UnicodeCharWidth( SwapCharBytesIfRequired( *pszCurrentCharacter ) );
-            }
-
-            startOfWord = true;
-        }
-        else
-        {
-            if (startOfWord)
-            {
-                pszStartOfCurrentWord = pszCurrentCharacter;
-                startOfWord = false;
-            }
-            //else do nothing
-
-            if ((dCurWidthOfLine + m_pFont->GetFontMetrics()->UnicodeCharWidth( SwapCharBytesIfRequired( *pszCurrentCharacter ))) > dWidth)
-            {
-                if ( pszLineBegin == pszStartOfCurrentWord )
-                {
-                    // This word takes up the whole line.
-                    // Put as much as possible on this line.                    
-                    vecLines.push_back( PdfString( pszLineBegin, pszCurrentCharacter - pszLineBegin ) );
-                    pszLineBegin = pszCurrentCharacter;
-                    pszStartOfCurrentWord = pszCurrentCharacter;
-                    dCurWidthOfLine = m_pFont->GetFontMetrics()->UnicodeCharWidth( SwapCharBytesIfRequired( *pszCurrentCharacter ) );
-                }
-                else
-                {
-                    // The current word does not fit in the current line.
-                    // -> Move it to the next one.                    
-                    vecLines.push_back( PdfString( pszLineBegin, pszStartOfCurrentWord - pszLineBegin ) );
-                    pszLineBegin = pszStartOfCurrentWord;
-                    dCurWidthOfLine = m_pFont->GetFontMetrics()->StringWidth( pszStartOfCurrentWord, (pszCurrentCharacter-pszStartOfCurrentWord) + 1 );
-                }
-            }
-            else 
-            {
-                dCurWidthOfLine += m_pFont->GetFontMetrics()->UnicodeCharWidth( SwapCharBytesIfRequired( *pszCurrentCharacter ) );
-            }
-        }
-        ++pszCurrentCharacter;
-    }
-
-    if( (pszCurrentCharacter - pszLineBegin) > 0 ) 
-    {
-        if( dCurWidthOfLine > dWidth )
-        {
-            // The previous word does not fit in the current line.
-            // -> Move it to the next one.
-            vecLines.push_back( PdfString( pszLineBegin, pszStartOfCurrentWord - pszLineBegin) );
-            pszLineBegin = pszStartOfCurrentWord;
-        }
-        //else do nothing
-
-        if( pszCurrentCharacter - pszLineBegin > 0 ) 
-        {
-            vecLines.push_back( PdfString( pszLineBegin, pszCurrentCharacter - pszLineBegin) );
-        }
-        //else do nothing
-    }
-
-    return vecLines;
-}
-
-void PdfPainter::DrawTextAligned( double dX, double dY, double dWidth, const PdfString & rsText, EPdfAlignment eAlignment )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !m_pFont || !m_pPage || !rsText.IsValid() )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // Peter Petrov 25 Septemer 2008
-    //m_pFont->EmbedFont();
-
-    if( dWidth <= 0.0 ) // nonsense arguments
-        return;
-
-    switch( eAlignment ) 
-    {
-        default:
-        case ePdfAlignment_Left:
-            break;
-        case ePdfAlignment_Center:
-            dX += (dWidth - m_pFont->GetFontMetrics()->StringWidth( rsText ) ) / 2.0;
-            break;
-        case ePdfAlignment_Right:
-            dX += (dWidth - m_pFont->GetFontMetrics()->StringWidth( rsText ) );
-            break;
-    }
-
-    this->DrawText( dX, dY, rsText );
-}
-
-void PdfPainter::DrawGlyph( PdfMemDocument* pDocument, double dX, double dY, const char* pszGlyphname)
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-    if( !m_pFont || !m_pPage || !pszGlyphname )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-	// search for a copy of this font to enter difference-encoding, create a new one if not found
-	PdfFont* pGlyphFont = pDocument->CreateDuplicateFontType1( m_pFont, "Glyph1" );
-
-	// select identical sizes
-	pGlyphFont->SetFontSize( m_pFont->GetFontSize() );
-	pGlyphFont->SetFontCharSpace( m_pFont->GetFontCharSpace() );
-	pGlyphFont->SetFontScale( m_pFont->GetFontScale() );
-	PdfObject* pGlyphFontObj = pGlyphFont->GetObject();
-
-	// get width of glyph
-	int width = static_cast<int>(pGlyphFont->GetFontMetrics()->GetGlyphWidth( pszGlyphname ) );
-
-	// change encoding to difference-encoding and adapt width
-	PdfObject* pEncoding = pGlyphFontObj->GetDictionary().GetKey( "Encoding" );
-
-	int code = 32;
-	if ( pEncoding == NULL  ||  pEncoding->IsReference() == false )
-	{
-		// first time: create difference-encoding as reference, enter glyph
-		pEncoding = pDocument->GetObjects().CreateObject( "Encoding" );
-        
-		code++;
-        
-		PdfArray diffs;
-		diffs.push_back( PdfVariant( static_cast<pdf_int64>( code ) ) );
-		diffs.push_back( PdfName( pszGlyphname ) );
-        
-		pEncoding->GetDictionary().AddKey( "Differences", diffs );
-		pGlyphFontObj->GetDictionary().AddKey("Encoding", pEncoding->Reference() );
-
-		// clear Widths-array and enter width of this glyph
-		PdfObject* pWidthObj = pGlyphFontObj->GetIndirectKey( "Widths" );
-		PdfArray & rWidthArr = pWidthObj->GetArray();
-		for ( unsigned int i = 0; i < rWidthArr.size(); i++ )
-        {
-			rWidthArr[i] = PdfVariant( static_cast<pdf_int64>( 0 ) );
-        }
-        rWidthArr[code] = PdfVariant( static_cast<pdf_int64>( width ) );
-    }
-	else
-	{
-		// search glyph in existing Encoding/Difference, create if not found
-		pEncoding = pDocument->GetObjects().GetObject( pEncoding->GetReference() );
-        
-		PODOFO_ASSERT( pEncoding != NULL ); // paranoia
-
-		PdfArray diffs;
-		diffs = pEncoding->GetDictionary().GetKey( "Differences" )->GetArray();
-
-		bool foundIt = false;
-
-		TCIVariantList it = diffs.begin();
-		while( it != diffs.end() )
-		{
-			if( (*it).GetDataType() == ePdfDataType_Name )
-			{
-				code++;
-				if ( (*it).GetName().GetName() == pszGlyphname )
-				{
-					foundIt = true;
-					break;
-				}
-			}
-				
-			++it;
-		}
-
-		// TODO: if code exceeds 255, create a new font-copy and start again with code 33
-		PODOFO_ASSERT( code <= 255 );
-
-		if ( foundIt == false )
-		{
-			code++;
-			diffs.push_back( PdfName( pszGlyphname ) );
-
-			pEncoding->GetDictionary().AddKey( "Differences", diffs );
-
-			// enter width of glyph
-			PdfObject* pWidthObj = pGlyphFontObj->GetIndirectKey( "Widths" );
-			PdfArray & rWidthArr = pWidthObj->GetArray();
-			rWidthArr[code] = PdfVariant( static_cast<pdf_int64>( width ) );
-		}
-	}
-
-	// mark glyph as used in basefont (needed for subsetting)
-	m_pFont->AddUsedGlyphname( pszGlyphname );
-    
-    // output
-	SetFont( pGlyphFont );
-	char temp[2];
-	temp[0] = code;
-	temp[1] = '\0';
-    DrawText( dX, dY, PdfString( temp ) );
-	SetFont( m_pFont );
-}
-
-void PdfPainter::DrawImage( double dX, double dY, PdfImage* pObject, double dScaleX, double dScaleY )
-{
-    this->DrawXObject( dX, dY, reinterpret_cast<PdfXObject*>(pObject), 
-                       dScaleX * pObject->GetPageSize().GetWidth(), 
-                       dScaleY * pObject->GetPageSize().GetHeight() );
-}
-
-void PdfPainter::DrawXObject( double dX, double dY, PdfXObject* pObject, double dScaleX, double dScaleY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    if( !pObject )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    // use OriginalReference() as the XObject might have been written to disk
-    // already and is not in memory anymore in this case.
-    this->AddToPageResources( pObject->GetIdentifier(), pObject->GetObjectReference(), "XObject" );
-
-	std::streamsize oldPrecision = m_oss.precision(clPainterHighPrecision);
-    m_oss.str("");
-    m_oss << "q" << std::endl
-          << dScaleX << " 0 0 "
-          << dScaleY << " "
-          << dX << " " 
-          << dY << " cm" << std::endl
-          << "/" << pObject->GetIdentifier().GetName() << " Do" << std::endl << "Q" << std::endl;
-	m_oss.precision(oldPrecision);
-    
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::ClosePath()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    m_pCanvas->Append( "h\n" );
-}
-
-void PdfPainter::LineTo( double dX, double dY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-    m_oss.str("");
-    m_oss << dX << " "
-          << dY
-          << " l" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::MoveTo( double dX, double dY )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-    m_oss.str("");
-    m_oss << dX << " "
-          << dY
-          << " m" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::CubicBezierTo( double dX1, double dY1, double dX2, double dY2, double dX3, double dY3 )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    m_oss.str("");
-    m_oss << dX1 << " "
-          << dY1 << " "
-          << dX2 << " "
-          << dY2 << " "
-          << dX3 << " "
-          << dY3 
-          << " c" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::HorizonalLineTo( double inX )
-{
-    LineTo( inX, lpy3 );
-}
-
-void PdfPainter::VerticalLineTo( double inY )
-{
-    LineTo( lpx3, inY );
-}
-
-void PdfPainter::SmoothCurveTo( double inX2, double inY2, double inX3, double inY3 )
-{
-    double    px, py, px2 = inX2, 
-            py2 = inY2, 
-            px3 = inX3, py3 = inY3;
-
-    // compute the reflective points (thanks Raph!)
-    px = 2 * lcx - lrx;
-    py = 2 * lcy - lry;
-
-    lpx = px; lpy = py; lpx2 = px2; lpy2 = py2; lpx3 = px3; lpy3 = py3;
-    lcx = px3;    lcy = py3;    lrx = px2;    lry = py2;    // thanks Raph!
-
-    CubicBezierTo( px, py, px2, py2, px3, py3 );
-}
-
-void PdfPainter::QuadCurveTo( double inX1, double inY1, double inX3, double inY3 )
-{
-    double px = inX1, py = inY1, 
-           px2, py2, 
-           px3 = inX3, py3 = inY3;
-
-    /* raise quadratic bezier to cubic    - thanks Raph!
-        http://www.icce.rug.nl/erikjan/bluefuzz/beziers/beziers/beziers.html
-    */
-    px = (lcx + 2 * px) * (1.0 / 3.0);
-    py = (lcy + 2 * py) * (1.0 / 3.0);
-    px2 = (px3 + 2 * px) * (1.0 / 3.0);
-    py2 = (py3 + 2 * py) * (1.0 / 3.0);
-
-    lpx = px; lpy = py; lpx2 = px2; lpy2 = py2; lpx3 = px3; lpy3 = py3;
-    lcx = px3;    lcy = py3;    lrx = px2;    lry = py2;    // thanks Raph!
-
-    CubicBezierTo( px, py, px2, py2, px3, py3 );
-}
-
-void PdfPainter::SmoothQuadCurveTo( double inX3, double inY3 )
-{
-    double px, py, px2, py2, 
-           px3 = inX3, py3 = inY3;
-
-    double xc, yc; /* quadratic control point */
-    xc = 2 * lcx - lrx;
-    yc = 2 * lcy - lry;
-
-    /* generate a quadratic bezier with control point = xc, yc */
-    px = (lcx + 2 * xc) * (1.0 / 3.0);
-    py = (lcy + 2 * yc) * (1.0 / 3.0);
-    px2 = (px3 + 2 * xc) * (1.0 / 3.0);
-    py2 = (py3 + 2 * yc) * (1.0 / 3.0);
-
-    lpx = px; lpy = py; lpx2 = px2; lpy2 = py2; lpx3 = px3; lpy3 = py3;
-    lcx = px3;    lcy = py3;    lrx = xc;    lry = yc;    // thanks Raph!
-
-    CubicBezierTo( px, py, px2, py2, px3, py3 );
-}
-
-void PdfPainter::ArcTo( double inX, double inY, double inRadiusX, double inRadiusY,
-                       double    inRotation, bool inLarge, bool inSweep)
-{
-    double px = inX, py = inY;
-    double rx = inRadiusX, ry = inRadiusY, rot = inRotation;
-    int    large = ( inLarge ? 1 : 0 ),
-           sweep = ( inSweep ? 1 : 0 );
-
-    double sin_th, cos_th;
-    double a00, a01, a10, a11;
-    double x0, y0, x1, y1, xc, yc;
-    double d, sfactor, sfactor_sq;
-    double th0, th1, th_arc;
-    int i, n_segs;
-
-    sin_th     = sin (rot * (PI / 180.0));
-    cos_th     = cos (rot * (PI / 180.0));
-    a00     = cos_th / rx;
-    a01     = sin_th / rx;
-    a10     = -sin_th / ry;
-    a11     = cos_th / ry;
-    x0         = a00 * lcx + a01 * lcy;
-    y0         = a10 * lcx + a11 * lcy;
-    x1         = a00 * px + a01 * py;
-    y1         = a10 * px + a11 * py;
-    /* (x0, y0) is current point in transformed coordinate space.
-     (x1, y1) is new point in transformed coordinate space.
-
-     The arc fits a unit-radius circle in this space.
-    */
-    d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
-    sfactor_sq = 1.0 / d - 0.25;
-    if (sfactor_sq < 0) sfactor_sq = 0;
-    sfactor = sqrt (sfactor_sq);
-    if (sweep == large) sfactor = -sfactor;
-    xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
-    yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
-    /* (xc, yc) is center of the circle. */
-
-    th0 = atan2 (y0 - yc, x0 - xc);
-    th1 = atan2 (y1 - yc, x1 - xc);
-
-    th_arc = th1 - th0;
-    if (th_arc < 0 && sweep)        th_arc += 2 * PI;
-    else if (th_arc > 0 && !sweep)    th_arc -= 2 * PI;
-
-    n_segs = static_cast<int>(ceil (fabs (th_arc / (PI * 0.5 + 0.001))));
-
-    for (i = 0; i < n_segs; i++) {
-        double nth0 = th0 + static_cast<double>(i) * th_arc / n_segs,
-               nth1 = th0 + static_cast<double>(i + 1) * th_arc / n_segs;
-        double nsin_th = 0.0,
-                ncos_th = 0.0;
-        double na00 = 0.0, 
-               na01 = 0.0, 
-               na10 = 0.0, 
-               na11 = 0.0;
-        double nx1 = 0.0, 
-               ny1 = 0.0, 
-               nx2 = 0.0, 
-               ny2 = 0.0, 
-               nx3 = 0.0,
-               ny3 = 0.0;
-        double t   = 0.0;
-        double th_half = 0.0;
-
-        nsin_th = sin (rot * (PI / 180.0));
-        ncos_th = cos (rot * (PI / 180.0)); 
-        /* inverse transform compared with rsvg_path_arc */
-        na00 = ncos_th * rx;
-        na01 = -nsin_th * ry;
-        na10 = nsin_th * rx;
-        na11 = ncos_th * ry;
-
-        th_half = 0.5 * (nth1 - nth0);
-        t = (8.0 / 3.0) * sin (th_half * 0.5) * sin (th_half * 0.5) / sin (th_half);
-        nx1 = xc + cos (nth0) - t * sin (nth0);
-        ny1 = yc + sin (nth0) + t * cos (nth0);
-        nx3 = xc + cos (nth1);
-        ny3 = yc + sin (nth1);
-        nx2 = nx3 + t * sin (nth1);
-        ny2 = ny3 - t * cos (nth1);
-        nx1 = na00 * nx1 + na01 * ny1;
-        ny1 = na10 * nx1 + na11 * ny1;
-        nx2 = na00 * nx2 + na01 * ny2;
-        ny2 = na10 * nx2 + na11 * ny2;
-        nx3 = na00 * nx3 + na01 * ny3;
-        ny3 = na10 * nx3 + na11 * ny3;
-        CubicBezierTo( nx1, 
-                       ny1,
-                       nx2, 
-                       ny2, 
-                       nx3, 
-                       ny3 );
-    }
-
-    lpx = lpx2 = lpx3 = px; lpy = lpy2 = lpy3 = py;
-    lcx = px;    lcy = py;    lrx = px;    lry = py;    // thanks Raph!
-}
-
-// Peter Petrov 5 January 2009 was delivered from libHaru
-bool PdfPainter::DrawArc(double dX, double dY, double dRadius, double dAngle1, double dAngle2)
-{
-    bool cont_flg = false;
-
-    bool ret = true;
-
-    if (dAngle1 >= dAngle2 || (dAngle2 - dAngle1) >= 360.0f)
-        return false;
-
-    while (dAngle1 < 0.0f || dAngle2 < 0.0f) {
-        dAngle1 = dAngle1 + 360.0f;
-        dAngle2 = dAngle2 + 360.0f;
-    }
-
-    for (;;) {
-        if (dAngle2 - dAngle1 <= 90.0f)
-            return InternalArc (dX, dY, dRadius, dAngle1, dAngle2, cont_flg);
-        else {
-            double tmp_ang = dAngle1 + 90.0f;
-
-            ret = InternalArc (dX, dY, dRadius, dAngle1, tmp_ang, cont_flg);
-            if (!ret)
-                return ret;
-
-            dAngle1 = tmp_ang;
-        }
-
-        if (dAngle1 >= dAngle2)
-            break;
-
-        cont_flg = true;
-    }
-
-    return true;
-}
-
-bool PdfPainter::InternalArc(
-              double    x,
-              double    y,
-              double    ray,
-              double    ang1,
-              double    ang2,
-              bool      cont_flg)
-{
-    bool ret = true;
-
-    double rx0, ry0, rx1, ry1, rx2, ry2, rx3, ry3;
-    double x0, y0, x1, y1, x2, y2, x3, y3;
-    double delta_angle = (90.0f - static_cast<double>(ang1 + ang2) / 2.0f) / 180.0f * PI;
-    double new_angle = static_cast<double>(ang2 - ang1) / 2.0f / 180.0f * PI;
-
-    rx0 = ray * cos (new_angle);
-    ry0 = ray * sin (new_angle);
-    rx2 = (ray * 4.0f - rx0) / 3.0f;
-    ry2 = ((ray * 1.0f - rx0) * (rx0 - ray * 3.0f)) / (3.0 * ry0);
-    rx1 = rx2;
-    ry1 = -ry2;
-    rx3 = rx0;
-    ry3 = -ry0;
-
-    x0 = rx0 * cos (delta_angle) - ry0 * sin (delta_angle) + x;
-    y0 = rx0 * sin (delta_angle) + ry0 * cos (delta_angle) + y;
-    x1 = rx1 * cos (delta_angle) - ry1 * sin (delta_angle) + x;
-    y1 = rx1 * sin (delta_angle) + ry1 * cos (delta_angle) + y;
-    x2 = rx2 * cos (delta_angle) - ry2 * sin (delta_angle) + x;
-    y2 = rx2 * sin (delta_angle) + ry2 * cos (delta_angle) + y;
-    x3 = rx3 * cos (delta_angle) - ry3 * sin (delta_angle) + x;
-    y3 = rx3 * sin (delta_angle) + ry3 * cos (delta_angle) + y;
-
-    if (!cont_flg) {
-        MoveTo(x0,y0);
-    }
-
-    CubicBezierTo( x1, 
-                   y1,
-                   x2, 
-                   y2, 
-                   x3, 
-                   y3 );
-
-    //attr->cur_pos.x = (HPDF_REAL)x3;
-    //attr->cur_pos.y = (HPDF_REAL)y3;
-    lcx = x3;
-    lcy = y3;
-
-    lpx = lpx2 = lpx3 = x3; 
-    lpy = lpy2 = lpy3 = y3;
-    lcx = x3;   
-    lcy = y3;    
-    lrx = x3;    
-    lry = y3;   
-
-    return ret;
-}
-
-void PdfPainter::Close()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-    m_pCanvas->Append( "h\n" );
-}
-
-void PdfPainter::Stroke()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-    m_pCanvas->Append( "S\n" );
-}
-
-void PdfPainter::Fill()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-    m_pCanvas->Append( "f\n" );
-}
-
-void PdfPainter::Clip( bool useEvenOddRule )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-    
-	if ( useEvenOddRule )
-	    m_pCanvas->Append( "W* n\n" );
-	else
-	    m_pCanvas->Append( "W n\n" );
-}
-
-void PdfPainter::Save()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    m_pCanvas->Append( "q\n" );
-}
-
-void PdfPainter::Restore()
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    m_pCanvas->Append( "Q\n" );
-}
-
-void PdfPainter::AddToPageResources( const PdfName & rIdentifier, const PdfReference & rRef, const PdfName & rName )
-{
-    if( !m_pPage )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    m_pPage->AddResource( rIdentifier, rRef, rName );
-}
-
-void PdfPainter::ConvertRectToBezier( double dX, double dY, double dWidth, double dHeight, double pdPointX[], double pdPointY[] )
-{
-    // this function is based on code from:
-    // http://www.codeguru.com/Cpp/G-M/gdi/article.php/c131/
-    // (Llew Goodstadt)
-
-    // MAGICAL CONSTANT to map ellipse to beziers
-    //                          2/3*(sqrt(2)-1) 
-    const double dConvert =     0.2761423749154;
-
-    double dOffX    = dWidth  * dConvert;
-    double dOffY    = dHeight * dConvert;
-    double dCenterX = dX + (dWidth / 2.0); 
-    double dCenterY = dY + (dHeight / 2.0); 
-
-    pdPointX[0]  =                            //------------------------//
-    pdPointX[1]  =                            //                        //
-    pdPointX[11] =                            //        2___3___4       //
-    pdPointX[12] = dX;                        //     1             5    //
-    pdPointX[5]  =                            //     |             |    //
-    pdPointX[6]  =                            //     |             |    //
-    pdPointX[7]  = dX + dWidth;               //     0,12          6    //
-    pdPointX[2]  =                            //     |             |    //
-    pdPointX[10] = dCenterX - dOffX;          //     |             |    //
-    pdPointX[4]  =                            //    11             7    //
-    pdPointX[8]  = dCenterX + dOffX;          //       10___9___8       //
-    pdPointX[3]  =                            //                        //
-    pdPointX[9]  = dCenterX;                  //------------------------//
-
-    pdPointY[2]  =
-    pdPointY[3]  =
-    pdPointY[4]  = dY;
-    pdPointY[8]  =
-    pdPointY[9]  =
-    pdPointY[10] = dY + dHeight;
-    pdPointY[7]  =
-    pdPointY[11] = dCenterY + dOffY;
-    pdPointY[1]  =
-    pdPointY[5]  = dCenterY - dOffY;
-    pdPointY[0]  =
-    pdPointY[12] =
-    pdPointY[6]  = dCenterY;
-}
-
-void PdfPainter::SetCurrentStrokingColor()
-{
-	SetStrokingColor( m_curColor );
-}
-
-void PdfPainter::SetTransformationMatrix( double a, double b, double c, double d, double e, double f )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-	// Need more precision for transformation-matrix !!
-	std::streamsize oldPrecision = m_oss.precision(clPainterHighPrecision);
-    m_oss.str("");
-    m_oss << a << " "
-          << b << " "
-          << c << " "
-          << d << " "
-          << e << " "
-          << f << " cm" << std::endl;
-	m_oss.precision(oldPrecision);
-
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetExtGState( PdfExtGState* inGState )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    this->AddToPageResources( inGState->GetIdentifier(), inGState->GetObject()->Reference(), PdfName("ExtGState") );
-    
-    m_oss.str("");
-    m_oss << "/" << inGState->GetIdentifier().GetName()
-          << " gs" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-void PdfPainter::SetRenderingIntent( char* intent )
-{
-    PODOFO_RAISE_LOGIC_IF( !m_pCanvas, "Call SetPage() first before doing drawing operations." );
-
-    m_oss.str("");
-    m_oss << "/" << intent
-          << " ri" << std::endl;
-    m_pCanvas->Append( m_oss.str() );
-}
-
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200	// MSC 6.0 has a template-bug
-PdfString PdfPainter::ExpandTabs_char( const char* pszText, long lStringLen, int nTabCnt, const char cTab, const char cSpace ) const
-{
-    long lLen    = lStringLen + nTabCnt*(m_nTabWidth-1) + sizeof(char);
-    char*   pszTab  = static_cast<char*>(malloc( sizeof( char ) * lLen ));
-
-    if( !pszTab )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-    
-    int i = 0;
-    while( lStringLen-- )
-    {
-        if( *pszText == cTab )
-        {
-            for( int z=0;z<m_nTabWidth; z++ )
-                pszTab[i+z] = cSpace;
-            
-            i+=m_nTabWidth;
-        }
-        else
-            pszTab[i++] = *pszText;
-        
-        ++pszText;
-    }
-    
-    pszTab[i]  = 0;
-    PdfString str( pszTab );
-    free( pszTab );
-    
-    return str;
-}
-
-PdfString PdfPainter::ExpandTabs_pdf_utf16be( const pdf_utf16be* pszText, long lStringLen, int nTabCnt, const pdf_utf16be cTab, const pdf_utf16be cSpace ) const
-{
-    long lLen    = lStringLen + nTabCnt*(m_nTabWidth-1) + sizeof(pdf_utf16be);
-    pdf_utf16be*   pszTab  = static_cast<pdf_utf16be*>(malloc( sizeof( pdf_utf16be ) * lLen ));
-
-    if( !pszTab )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-    
-    int i = 0;
-    while( lStringLen-- )
-    {
-        if( *pszText == cTab )
-        {
-            for( int z=0;z<m_nTabWidth; z++ )
-                pszTab[i+z] = cSpace;
-            
-            i+=m_nTabWidth;
-        }
-        else
-            pszTab[i++] = *pszText;
-        
-        ++pszText;
-    }
-    
-    pszTab[i]  = 0;
-
-    PdfString str( pszTab );
-    free( pszTab );
-    
-    return str;
-}
-#else
-template<typename C>
-PdfString PdfPainter::ExpandTabsPrivate( const C* pszText, pdf_long lStringLen, int nTabCnt, const C cTab, const C cSpace ) const
-{
-    pdf_long lLen    = lStringLen + nTabCnt*(m_nTabWidth-1) + sizeof(C);
-    C*   pszTab  = static_cast<C*>(malloc( sizeof( C ) * lLen ));
-
-    if( !pszTab )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
-    }
-    
-    int i = 0;
-    while( lStringLen-- )
-    {
-        if( *pszText == cTab )
-        {
-            for( int z=0;z<m_nTabWidth; z++ )
-                pszTab[i+z] = cSpace;
-            
-            i+=m_nTabWidth;
-        }
-        else
-            pszTab[i++] = *pszText;
-        
-        ++pszText;
-    }
-    
-    pszTab[i]  = 0;
-
-    PdfString str( pszTab );
-    free( pszTab );
-    
-    return str;
-}
-#endif
-
-PdfString PdfPainter::ExpandTabs( const PdfString & rsString, pdf_long lStringLen ) const
-{
-    int               nTabCnt  = 0;
-    int               i;
-    bool              bUnicode = rsString.IsUnicode();
-    const pdf_utf16be cTab     = 0x0900;
-    const pdf_utf16be cSpace   = 0x2000;
-
-    // count the number of tabs in the string
-    if( bUnicode ) 
-    {
-        for( i=0;i<=lStringLen;i++ )
-            if( rsString.GetUnicode()[i] == cTab ) 
-                ++nTabCnt;
-    }
-    else
-    {
-        for( i=0;i<=lStringLen;i++ )
-            if( rsString.GetString()[i] == '\t' )
-                ++nTabCnt;
-    }
-
-    // if no tabs are found: bail out!
-    if( !nTabCnt )
-        return rsString;
-    
-#if defined(_MSC_VER)  &&  _MSC_VER <= 1200	// MSC 6.0 has a template-bug
-    if( rsString.IsUnicode() )
-        return ExpandTabs_pdf_utf16be( rsString.GetUnicode(), lStringLen, nTabCnt, cTab, cSpace );
-    else
-        return ExpandTabs_char( rsString.GetString(), lStringLen, nTabCnt, '\t', ' ' );
-#else
-    if( rsString.IsUnicode() )
-        return ExpandTabsPrivate<pdf_utf16be>( rsString.GetUnicode(), lStringLen, nTabCnt, cTab, cSpace );
-    else
-        return ExpandTabsPrivate<char>( rsString.GetString(), lStringLen, nTabCnt, '\t', ' ' );
-#endif
-}
-
-} /* namespace PoDoFo */
-
-
--- src/doc/PdfXObject.cpp.orig	2010-10-21 17:09:00.000000000 +0000
+++ src/doc/PdfXObject.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,260 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "PdfXObject.h" 
-
-#include "base/PdfDefinesPrivate.h"
-
-#include "base/PdfDictionary.h"
-#include "base/PdfLocale.h"
-#include "base/PdfRect.h"
-#include "base/PdfVariant.h"
-
-#include "PdfImage.h"
-#include "PdfPage.h"
-#include "PdfMemDocument.h"
-#include "PdfDocument.h"
-
-#include <sstream>
-
-#define PI           3.141592654f
-
-using namespace std;
-
-namespace PoDoFo {
-
-PdfArray PdfXObject::s_matrix;
-
-PdfXObject::PdfXObject( const PdfRect & rRect, PdfDocument* pParent, const char* pszPrefix )
-    : PdfElement( "XObject", pParent ), PdfCanvas(), m_rRect( rRect )
-{
-    InitXObject( rRect, pszPrefix );
-}
-
-PdfXObject::PdfXObject( const PdfRect & rRect, PdfVecObjects* pParent, const char* pszPrefix )
-    : PdfElement( "XObject", pParent ), PdfCanvas(), m_rRect( rRect )
-{
-    InitXObject( rRect, pszPrefix );
-}
-
-PdfXObject::PdfXObject( const PdfMemDocument & rDoc, int nPage, PdfDocument* pParent, const char* pszPrefix, bool bUseTrimBox )
-    : PdfElement( "XObject", pParent ), PdfCanvas()
-{
-    m_rRect = PdfRect();
-
-    InitXObject( m_rRect, pszPrefix );
-
-    // Implementation note: source document must be different from distination
-    if ( pParent == reinterpret_cast<const PdfDocument*>(&rDoc) )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-    }
-
-    // After filling set correct BBox, independent of rotation
-    m_rRect = pParent->FillXObjectFromDocumentPage( this, rDoc, nPage, bUseTrimBox );
-
-    PdfVariant    var;
-    m_rRect.ToVariant( var );
-    this->GetObject()->GetDictionary().AddKey( "BBox", var );
-
- 	int rotation = rDoc.GetPage( nPage )->GetRotation();
-	// correct negative rotation
-	if ( rotation < 0 )
-		rotation = 360 + rotation;
-
-	// Swap offsets/width/height for vertical rotation
- 	switch ( rotation )
- 	{
- 		case 90:
- 		case 270:
- 		{
- 			double temp;
-			
-			temp = m_rRect.GetWidth();
- 			m_rRect.SetWidth( m_rRect.GetHeight() );
- 			m_rRect.SetHeight( temp );
-
-			temp = m_rRect.GetLeft();
- 			m_rRect.SetLeft( m_rRect.GetBottom() );
- 			m_rRect.SetBottom( temp );
- 		}
- 		break;
-        
- 		default:
-            break;
- 	}
- 
- 	// Build matrix for rotation and cropping
- 	double alpha = -rotation / 360.0 * 2.0 * PI;
-    
- 	double a, b, c, d, e, f;
-    
- 	a = cos( alpha );
- 	b = sin( alpha );
- 	c = -sin( alpha );
- 	d = cos( alpha );
- 
- 	switch ( rotation )
- 	{
- 		case 90:
- 			e = - m_rRect.GetLeft();
-			f = m_rRect.GetBottom() + m_rRect.GetHeight();
-            break;
-  
-  		case 180:
- 			e = m_rRect.GetLeft() + m_rRect.GetWidth();
- 			f = m_rRect.GetBottom() + m_rRect.GetHeight();
-            break;
-            
- 		case 270:
- 			e = m_rRect.GetLeft() + m_rRect.GetWidth();
- 			f = - m_rRect.GetBottom();
-            break;
- 
- 		case 0:
- 		default:
- 			e = - m_rRect.GetLeft();
- 			f = - m_rRect.GetBottom();
-            break;
- 	}
-
-    PdfArray      matrix;
-    matrix.push_back( PdfVariant( a ) );
-    matrix.push_back( PdfVariant( b ) );
-    matrix.push_back( PdfVariant( c ) );
-    matrix.push_back( PdfVariant( d ) );
-    matrix.push_back( PdfVariant( e ) );
-    matrix.push_back( PdfVariant( f ) );
-    
-    this->GetObject()->GetDictionary().AddKey( "Matrix", matrix );
-}
-
-PdfXObject::PdfXObject( PdfObject* pObject )
-    : PdfElement( "XObject", pObject ), PdfCanvas()
-{
-    ostringstream out;
-    PdfLocaleImbue(out);
-    // Implementation note: the identifier is always
-    // Prefix+ObjectNo. Prefix is /XOb for XObject.
-    out << "XOb" << this->GetObject()->Reference().ObjectNumber();
-
-    
-    m_pResources = pObject->GetIndirectKey( "Resources" );
-    m_Identifier = PdfName( out.str().c_str() );
-    m_rRect      = PdfRect( this->GetObject()->GetIndirectKey( "BBox" )->GetArray() );
-    m_Reference  = this->GetObject()->Reference();
-}
-
-void PdfXObject::InitXObject( const PdfRect & rRect, const char* pszPrefix )
-{
-    PdfVariant    var;
-    ostringstream out;
-    PdfLocaleImbue(out);
-
-    // Initialize static data
-    if( s_matrix.empty() )
-    {
-        // This matrix is the same for all PdfXObjects so cache it
-        s_matrix.push_back( PdfVariant( static_cast<pdf_int64>(1LL) ) );
-        s_matrix.push_back( PdfVariant( static_cast<pdf_int64>(0LL) ) );
-        s_matrix.push_back( PdfVariant( static_cast<pdf_int64>(0LL) ) );
-        s_matrix.push_back( PdfVariant( static_cast<pdf_int64>(1LL) ) );
-        s_matrix.push_back( PdfVariant( static_cast<pdf_int64>(0LL) ) );
-        s_matrix.push_back( PdfVariant( static_cast<pdf_int64>(0LL) ) );
-    }
-
-    rRect.ToVariant( var );
-    this->GetObject()->GetDictionary().AddKey( "BBox", var );
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, PdfName("Form") );
-    this->GetObject()->GetDictionary().AddKey( "FormType", PdfVariant( static_cast<pdf_int64>(1LL) ) ); // only 1 is only defined in the specification.
-    this->GetObject()->GetDictionary().AddKey( "Matrix", s_matrix );
-
-    // The PDF specification suggests that we send all available PDF Procedure sets
-    this->GetObject()->GetDictionary().AddKey( "Resources", PdfObject( PdfDictionary() ) );
-    m_pResources = this->GetObject()->GetDictionary().GetKey( "Resources" );
-    m_pResources->GetDictionary().AddKey( "ProcSet", PdfCanvas::GetProcSet() );
-
-    // Implementation note: the identifier is always
-    // Prefix+ObjectNo. Prefix is /XOb for XObject.
-	if ( pszPrefix == NULL )
-	    out << "XOb" << this->GetObject()->Reference().ObjectNumber();
-	else
-	    out << pszPrefix << this->GetObject()->Reference().ObjectNumber();
-
-    m_Identifier = PdfName( out.str().c_str() );
-    m_Reference  = this->GetObject()->Reference();
-}
-
-PdfXObject::PdfXObject( const char* pszSubType, PdfDocument* pParent, const char* pszPrefix )
-    : PdfElement( "XObject", pParent ) 
-{
-    ostringstream out;
-    PdfLocaleImbue(out);
-    // Implementation note: the identifier is always
-    // Prefix+ObjectNo. Prefix is /XOb for XObject.
-	if ( pszPrefix == NULL )
-	    out << "XOb" << this->GetObject()->Reference().ObjectNumber();
-	else
-	    out << pszPrefix << this->GetObject()->Reference().ObjectNumber();
-
-    m_Identifier = PdfName( out.str().c_str() );
-    m_Reference  = this->GetObject()->Reference();
-
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, PdfName( pszSubType ) );
-}
-
-PdfXObject::PdfXObject( const char* pszSubType, PdfVecObjects* pParent, const char* pszPrefix )
-    : PdfElement( "XObject", pParent ) 
-{
-    ostringstream out;
-    PdfLocaleImbue(out);
-    // Implementation note: the identifier is always
-    // Prefix+ObjectNo. Prefix is /XOb for XObject.
-	if ( pszPrefix == NULL )
-	    out << "XOb" << this->GetObject()->Reference().ObjectNumber();
-	else
-	    out << pszPrefix << this->GetObject()->Reference().ObjectNumber();
-
-    m_Identifier = PdfName( out.str().c_str() );
-    m_Reference  = this->GetObject()->Reference();
-
-    this->GetObject()->GetDictionary().AddKey( PdfName::KeySubtype, PdfName( pszSubType ) );
-}
-
-PdfXObject::PdfXObject( const char* pszSubType, PdfObject* pObject )
-    : PdfElement( "XObject", pObject ) 
-{
-    ostringstream out;
-    PdfLocaleImbue(out);
-
-    if( this->GetObject()->GetDictionary().GetKeyAsName( PdfName::KeySubtype ) != pszSubType ) 
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
-    }
-
-    // Implementation note: the identifier is always
-    // Prefix+ObjectNo. Prefix is /XOb for XObject.
-    out << "XOb" << this->GetObject()->Reference().ObjectNumber();
-
-    m_Identifier = PdfName( out.str().c_str() );
-    m_Reference  = this->GetObject()->Reference();
-}
-
-};
--- test/CreationTest/CreationTest.cpp.orig	2011-10-10 18:43:04.000000000 +0000
+++ test/CreationTest/CreationTest.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,878 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2005 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "../PdfTest.h"
-
-#include <stdlib.h>
-#include <cstdio>
-
-using namespace PoDoFo;
-
-#define CONVERSION_CONSTANT 0.002834645669291339
-
-const char* pszLoremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse lacinia sollicitudin viverra. Praesent augue tellus, feugiat vel tempus ac, semper in tellus. Maecenas et vehicula urna. Suspendisse ullamcorper molestie leo id aliquet. Mauris ultricies porttitor lectus vel facilisis. Integer euismod libero ut lectus mattis sed venenatis metus molestie. Aliquam feugiat, dolor a adipiscing ullamcorper, sapien orci ultrices erat, eget porttitor ipsum purus id magna. Morbi malesuada malesuada sagittis. Curabitur viverra posuere sem, quis condimentum eros viverra et. Pellentesque tristique aliquam orci a aliquam.\n\nIn hac habitasse platea dictumst. Maecenas vitae lorem velit. Donec at ultrices arcu. Phasellus et justo in quam fermentum volutpat. Nam vestibulum tempus lorem nec lacinia. Cras ac dignissim tortor. Morbi pellentesque, nisi sit amet sollicitudin accumsan, ante quam egestas lorem, a dapibus quam orci quis nulla. Donec quis orci ut lacus dictum sollicitudin at eget turpis. Nam condimentum iaculis enim, id volutpat est dapibus id. Quisque sed enim in est condimentum convallis. Cras at posuere ipsum. Cras tempor dui nunc, vel malesuada odio.";
-
-void WriteStringToStream( const PdfString & rsString, std::ostringstream & oss, PdfFont* pFont )
-{
-    PdfEncoding* pEncoding = new PdfIdentityEncoding( 0, 0xffff, true );
-    PdfRefCountedBuffer buffer = pEncoding->ConvertToEncoding( rsString, pFont );
-    pdf_long  lLen    = 0;
-    char* pBuffer = NULL;
-
-    std::auto_ptr<PdfFilter> pFilter = PdfFilterFactory::Create( ePdfFilter_ASCIIHexDecode );    
-    pFilter->Encode( buffer.GetBuffer(), buffer.GetSize(), &pBuffer, &lLen );
-
-    oss << "<";
-    oss << std::string( pBuffer, lLen );
-    oss << ">";
-    free( pBuffer );
-    delete pEncoding;
-}
-
-void CreateUnicodeAnnotationText( PdfPage* pPage, PdfDocument* pDocument )
-{
-    PdfString sJap(reinterpret_cast<const pdf_utf8*>("「PoDoFo」は今から日本語も話せます。"));
-    PdfAnnotation* pAnnotation = 
-        pPage->CreateAnnotation( ePdfAnnotation_Text, PdfRect( 400.0, 200.0, 20.0, 20.0 ) );
-
-    PdfString sGerman(reinterpret_cast<const pdf_utf8*>("Unicode Umlauts: ÄÖÜß"));
-    pAnnotation->SetTitle( sGerman );
-    pAnnotation->SetContents( sJap );
-    pAnnotation->SetOpen( true );
-}
-
-void CreateUnicodeAnnotationFreeText( PdfPage* pPage, PdfDocument* pDocument )
-{
-    PdfString sJap(reinterpret_cast<const pdf_utf8*>("「PoDoFo」は今から日本語も話せます。"));
-    PdfFont* pFont = pDocument->CreateFont( "Arial Unicode MS", new PdfIdentityEncoding( 0, 0xffff, true ) ); 
-
-    PdfRect rect( 200.0, 200.0, 200.0, 200.0 );
-    /*
-    PdfXObject xObj( rect, pDocument );
-    
-    PdfPainter painter;
-    painter.SetPage( &xObj );
-    painter.SetFont( pFont );
-    painter.SetColor( 1.0, 0.0, 0.0 );
-    painter.DrawRect( 10.0, 10.0, 100.0, 100.0 );
-    painter.DrawText( 100.0, 100.0, sJap );
-    painter.FinishPage();
-    */
-
-    std::ostringstream  oss;
-    oss << "BT" << std::endl << "/" <<   pFont->GetIdentifier().GetName()
-        << " "  <<   pFont->GetFontSize()
-        << " Tf " << std::endl;
-
-    WriteStringToStream( sJap, oss, pFont );
-    oss << "Tj ET" << std::endl;
-
-    PdfDictionary fonts;
-    fonts.AddKey(pFont->GetIdentifier().GetName(), pFont->GetObject()->Reference());
-    PdfDictionary resources;
-    resources.AddKey( PdfName("Fonts"), fonts );
-
-    PdfAnnotation* pAnnotation = 
-        pPage->CreateAnnotation( ePdfAnnotation_FreeText, rect );
-
-    PdfString sGerman(reinterpret_cast<const pdf_utf8*>("Unicode Umlauts: ÄÖÜß"));
-    pAnnotation->SetTitle( sGerman );
-    pAnnotation->SetContents( sJap );
-    //pAnnotation->SetAppearanceStream( &xObj );
-    pAnnotation->GetObject()->GetDictionary().AddKey( PdfName("DA"), PdfString(oss.str()) );
-    pAnnotation->GetObject()->GetDictionary().AddKey( PdfName("DR"), resources );
-    
-
-}
-
-void LineTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    double     x     = 10000 * CONVERSION_CONSTANT;
-    double     y     = pPage->GetPageSize().GetHeight() - 10000 * CONVERSION_CONSTANT;
-    PdfFont* pFont;
-
-    const double dLineLength = 50000 * CONVERSION_CONSTANT; // 5cm
-    double h;
-    double w;
-    int    i;
-
-	/*
-    pFont = pDocument->CreateFont( "Arial Unicode MS", new PdfIdentityEncoding( 0, 0xffff, true ) );
-    printf("GOT: %s\n", pFont->GetFontMetrics()->GetFontname() );
-    PdfString sJap(reinterpret_cast<const pdf_utf8*>("「Po\tDoFo」は今から日本語も話せます。"));
-    const long     lUtf8BufferLen = 256;
-    pdf_utf8 pUtf8Buffer[lUtf8BufferLen];
-
-
-    PdfString::ConvertUTF16toUTF8( sJap.GetUnicode(), sJap.GetUnicodeLength(), pUtf8Buffer, lUtf8BufferLen  );
-    printf("UNIC: %s\n", pUtf8Buffer );
-
-    pFont->SetFontSize( 8.0 );
-    pPainter->SetFont( pFont );
-    pPainter->DrawText( 100.0, 100.0, sJap );
-	*/
-
-    std::vector<int> vecCharacters;
-    vecCharacters.push_back( static_cast<int>('C') );
-    vecCharacters.push_back( static_cast<int>('G') );
-    vecCharacters.push_back( static_cast<int>('a') );
-    vecCharacters.push_back( static_cast<int>('c') );
-    vecCharacters.push_back( static_cast<int>('e') );
-    vecCharacters.push_back( static_cast<int>('l') );
-    vecCharacters.push_back( static_cast<int>('o') );
-    vecCharacters.push_back( static_cast<int>('p') );
-    vecCharacters.push_back( static_cast<int>('s') );
-    vecCharacters.push_back( static_cast<int>('r') );
-    vecCharacters.push_back( static_cast<int>('y') );
-    vecCharacters.push_back( static_cast<int>(' ') );
-    vecCharacters.push_back( static_cast<int>('-') );
-
-    pFont = pDocument->CreateFont( "Comic Sans MS", false, false ); //, vecCharacters );
-    if( !pFont )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pFont->SetFontSize( 16.0 );
-
-
-    const wchar_t* msg = L"Grayscale - Colorspace";
-    h = pFont->GetFontMetrics()->GetLineSpacing();
-    w = pFont->GetFontMetrics()->StringWidth( msg );
-
-    pPainter->SetFont( pFont );
-    pPainter->DrawText( 120000 * CONVERSION_CONSTANT, y - pFont->GetFontMetrics()->GetLineSpacing(), msg  );
-    pPainter->DrawRect( 120000 * CONVERSION_CONSTANT, y - pFont->GetFontMetrics()->GetLineSpacing(), w, h );
-
-    // Draw 10 lines in gray scale
-    for( i = 0; i < 10; i++ )
-    {
-        x += (10000 * CONVERSION_CONSTANT);
-
-        pPainter->SetStrokeWidth( (i*1000) * CONVERSION_CONSTANT );
-        pPainter->SetStrokingGray( static_cast<double>(i)/10.0 );
-        pPainter->DrawLine( x, y, x, y - dLineLength );
-    }
-
-    x = 10000 * CONVERSION_CONSTANT;
-    y -= dLineLength;
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pFont = pDocument->CreateFont( "Arial", true, false ); // arial bold - not italic
-    if( !pFont )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pFont->SetFontSize( 16.0 );
-    pPainter->SetFont( pFont );
-    pPainter->DrawText( 120000 * CONVERSION_CONSTANT, y - pFont->GetFontMetrics()->GetLineSpacing(), "RGB Colorspace" );
-
-    // Draw 10 lines in rgb
-    for( i = 0; i < 10; i++ )
-    {
-        x += (10000 * CONVERSION_CONSTANT);
-
-        pPainter->SetStrokeWidth( (i*1000) * CONVERSION_CONSTANT );
-        pPainter->SetStrokingColor( static_cast<double>(i)/10.0, 0.0, static_cast<double>(10-i)/10.0 );
-        pPainter->DrawLine( x, y, x, y - dLineLength );
-    }
-
-    x = 10000 * CONVERSION_CONSTANT;
-    y -= dLineLength;
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pFont = pDocument->CreateFont( "Arial", false, true ); // arial italic - not bold
-    if( !pFont )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pFont->SetFontSize( 16.0 );
-    pPainter->SetFont( pFont );
-    pPainter->DrawText( 120000 * CONVERSION_CONSTANT, y - pFont->GetFontMetrics()->GetLineSpacing(), "CMYK Colorspace" );
-
-    // Draw 10 lines in cmyk
-    for( i = 0; i < 10; i++ )
-    {
-        x += (10000 * CONVERSION_CONSTANT);
-
-        pPainter->SetStrokeWidth( (i*1000) * CONVERSION_CONSTANT );
-        pPainter->SetStrokingColorCMYK( static_cast<double>(i)/10.0, 0.0, static_cast<double>(10-i)/10.0, 0.0 );
-        pPainter->DrawLine( x, y, x, y - dLineLength );
-    }
-
-    x = 20000 * CONVERSION_CONSTANT;
-    y -= 60000 * CONVERSION_CONSTANT;
-
-    pPainter->SetStrokeWidth( 1000 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-
-    pPainter->SetStrokeStyle( ePdfStrokeStyle_Solid );
-    pPainter->DrawLine( x, y, x + (100000 * CONVERSION_CONSTANT), y );
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pPainter->SetStrokeStyle( ePdfStrokeStyle_Dash );
-    pPainter->DrawLine( x, y, x + (100000 * CONVERSION_CONSTANT), y );
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pPainter->SetStrokeStyle( ePdfStrokeStyle_Dot );
-    pPainter->DrawLine( x, y, x + (100000 * CONVERSION_CONSTANT), y );
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pPainter->SetStrokeStyle( ePdfStrokeStyle_DashDot );
-    pPainter->DrawLine( x, y, x + (100000 * CONVERSION_CONSTANT), y );
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pPainter->SetStrokeStyle( ePdfStrokeStyle_DashDotDot );
-    pPainter->DrawLine( x, y, x + (100000 * CONVERSION_CONSTANT), y );
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    pPainter->SetStrokeStyle( ePdfStrokeStyle_Custom, "[7 9 2] 4" );
-    pPainter->DrawLine( x, y, x + (100000 * CONVERSION_CONSTANT), y );
-    y -= (10000 * CONVERSION_CONSTANT);
-
-    //CreateUnicodeAnnotationText( pPage, pDocument );
-    CreateUnicodeAnnotationFreeText( pPage, pDocument );
-
-    return;
-    ///////////////////////
-    pPage = pDocument->CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    pPainter->SetPage( pPage );
-
-    x     = 10000 * CONVERSION_CONSTANT;
-    y     = pPage->GetPageSize().GetHeight() - 10000 * CONVERSION_CONSTANT;
-    char buffer[1024];
-
-    double dStroke = 0.01;
-    double dLine   = pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    for( int i=0;i<23; i++ ) 
-    {
-        sprintf( buffer, "Linewidth: %.3fpt", dStroke );
-        pPainter->DrawText( x, y, PdfString( buffer ) ); 
-
-        pPainter->Save();
-        pPainter->SetStrokeWidth( dStroke );
-        pPainter->DrawLine( x + 60000 * CONVERSION_CONSTANT, y + dLine/2.0, x + 140000 * CONVERSION_CONSTANT, y + dLine/2.0 );
-        pPainter->DrawLine( x + 60000 * CONVERSION_CONSTANT, y, x + 140000 * CONVERSION_CONSTANT, y  );
-        pPainter->DrawLine( x + 60000 * CONVERSION_CONSTANT, y + dLine, x + 140000 * CONVERSION_CONSTANT, y + dLine );
-
-        pPainter->DrawLine( x + 60000 * CONVERSION_CONSTANT, y, x + 60000 * CONVERSION_CONSTANT, y + dLine );
-        pPainter->DrawLine( x + 140000 * CONVERSION_CONSTANT, y, x + 140000 * CONVERSION_CONSTANT, y + dLine );
-
-        pPainter->Restore();
-        dStroke += 0.05;
- 
-        y -= dLine*2.0;
-    }
-}
-
-void RectTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    double     x     = 10000 * CONVERSION_CONSTANT;
-    double     y     = pPage->GetPageSize().GetHeight() - 10000 * CONVERSION_CONSTANT;
-    PdfFont* pFont;
-
-    const double dWidth  = 50000 * CONVERSION_CONSTANT; // 5cm
-	const double dHeight = 30000 * CONVERSION_CONSTANT; // 3cm
-
-	y -= dHeight;
-
-    pFont = pDocument->CreateFont( "Arial" );
-    if( !pFont )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pFont->SetFontSize( 16.0 );
-    pPainter->SetFont( pFont );
-
-    pPainter->DrawText( 125000 * CONVERSION_CONSTANT, y - pFont->GetFontMetrics()->GetLineSpacing(), "Rectangles" );
-
-    pPainter->SetStrokeWidth( 100 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawRect( x, y, dWidth, dHeight );
-
-    PdfString sMultiLine("Hello World! We try to draw text using PdfPainter and DrawMultiLineText into an rectangle - including wordwrapping.");
-    pPainter->DrawMultiLineText( x, y, dWidth, dHeight, sMultiLine );
-
-    x += dWidth;
-    x += 10000 * CONVERSION_CONSTANT;
-
-    pPainter->SetStrokeWidth( 1000 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawRect( x, y, dWidth, dHeight );
-
-    y -= dHeight;
-    y -= 10000 * CONVERSION_CONSTANT;
-    x = 10000 * CONVERSION_CONSTANT;
-
-    pPainter->SetStrokeWidth( 100 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 1.0, 0.0, 0.0 );
-    pPainter->DrawRect( x, y, dWidth, dHeight );
-
-    x += dWidth;
-    x += 10000 * CONVERSION_CONSTANT;
-    pPainter->SetStrokeWidth( 1000 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 0.0, 1.0, 0.0 );
-    pPainter->DrawRect( x, y, dWidth, dHeight );
-
-    y -= dHeight;
-    y -= 10000 * CONVERSION_CONSTANT;
-    x = 10000 * CONVERSION_CONSTANT;
-
-    pPainter->SetStrokeWidth( 100 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-    pPainter->SetColor( 1.0, 0.0, 0.0 );
-    pPainter->FillRect( x, y, dWidth, dHeight );
-    pPainter->DrawRect( x, y, dWidth, dHeight );
-
-    x += dWidth;
-    x += 10000 * CONVERSION_CONSTANT;
-    pPainter->SetStrokeWidth( 100 * CONVERSION_CONSTANT );
-    pPainter->SetStrokingColor( 0.0, 1.0, 0.0 );
-    pPainter->SetColor( 0.0, 0.0, 1.0 );
-	x = 0.0;
-	y = 0.0;
-    pPainter->FillRect( x, y, 50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT);
-    pPainter->DrawRect( x, y, 50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT);
-
-    y -= dHeight;
-    y -= 10000 * CONVERSION_CONSTANT;
-    x = (10000 * CONVERSION_CONSTANT) + dWidth;
-
-    pPainter->DrawText( 120000 * CONVERSION_CONSTANT, y - pFont->GetFontMetrics()->GetLineSpacing(), "Triangles" );
-
-    // Draw a triangle at the current position
-    pPainter->SetColor( 0.0, 1.0, 1.0 );
-    pPainter->MoveTo( x, y );
-    pPainter->LineTo( x+dWidth, y-dHeight );
-    pPainter->LineTo( x-dWidth, y-dHeight );
-    pPainter->ClosePath();
-    pPainter->Fill();
-
-    y -= dHeight;
-    y -= 10000 * CONVERSION_CONSTANT;
-    x = (10000 * CONVERSION_CONSTANT) + dWidth;
-
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-    pPainter->MoveTo( x, y );
-    pPainter->LineTo( x+dWidth, y-dHeight );
-    pPainter->LineTo( x-dWidth, y-dHeight );
-    pPainter->ClosePath();
-    pPainter->Stroke();
-}
-
-void TextTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    double x = 10000 * CONVERSION_CONSTANT;
-    double y = pPage->GetPageSize().GetHeight() - 10000 * CONVERSION_CONSTANT;
-
-    printf("Embedding Font\n");
-    printf("!!!!!!!!!!!!!!!\n");
-    pPainter->SetFont( pDocument->CreateFont( "Times New Roman" ) );
-    pPainter->GetFont()->SetFontSize( 24.0 );
-    printf("!!!!!!!!!!!!!!!\n");
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->SetColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawText( x, y, "Hallo Welt!" );
-    
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->SetStrokingColor( 1.0, 0.0, 0.0 );
-    pPainter->DrawText( x, y, "Underlined text in the same font!" );
-
-    pPainter->GetFont()->SetUnderlined( false );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    pPainter->DrawText( x, y, "Disabled the underline again..." );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    
-    PdfFont* pFont = pDocument->CreateFont( "Arial" );
-    pFont->SetFontSize( 12.0 );
-    
-    pPainter->SetFont( pFont );
-
-    pPainter->DrawText( x, y, "Normal" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->DrawText( x, y, "Normal+underlinded" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->GetFont()->SetUnderlined( false );
-    pFont->SetFontCharSpace( 100.0 );
-    pPainter->DrawText( x, y, "Mormal+spaced" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-	
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->DrawText( x, y, "Normal+underlined+spaced" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    pPainter->GetFont()->SetUnderlined( false );
-    pFont->SetFontCharSpace( 0.0 );
-
-
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-
-    pFont->SetFontScale( 50.0 );
-    pPainter->DrawText( x, y, "Condensed" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pFont->SetFontCharSpace( 0.0 );
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->DrawText( x, y, "Condensed+underlinded" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->GetFont()->SetUnderlined( false );
-    pFont->SetFontCharSpace( 100.0 );
-    pPainter->DrawText( x, y, "Condensed+spaced" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->DrawText( x, y, "Condensed+underlined+spaced" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    pPainter->GetFont()->SetUnderlined( false );
-    pFont->SetFontCharSpace( 0.0 );
-
-
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pFont->SetFontScale( 200.0 );
-    pPainter->DrawText( x, y, "Expanded" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->DrawText( x, y, "Expanded+underlinded" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    
-    pPainter->GetFont()->SetUnderlined( false );
-    pFont->SetFontCharSpace( 100.0 );
-    pPainter->DrawText( x, y, "Expanded+spaced" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->GetFont()->SetUnderlined( true );
-    pPainter->DrawText( x, y, "Expanded+underlined+spaced" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    pPainter->GetFont()->SetUnderlined( false );
-    pFont->SetFontCharSpace( 0.0 );
-    pFont->SetFontScale( 100.0 );
-
-
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-
-    pPainter->GetFont()->SetStrikeOut( true );
-    pPainter->DrawText( x, y, "Strikeout" );
-    y -= pPainter->GetFont()->GetFontMetrics()->GetLineSpacing();
-    pPainter->GetFont()->SetUnderlined( false );
-
-
-    pPainter->DrawText( x, y, "PoDoFo rocks!" );
-}
-
-void ImageTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    double        y      = pPage->GetPageSize().GetHeight() - 60000 * CONVERSION_CONSTANT;
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-    PdfImage image( pDocument );
-#endif // PODOFO_HAVE_JPEG_LIB
-
-    PdfRect        rect( 0, 0, 50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT );
-    PdfRect        rect1( 80000 * CONVERSION_CONSTANT, 3000 * CONVERSION_CONSTANT, 20000 * CONVERSION_CONSTANT, 20000 * CONVERSION_CONSTANT );
-    PdfRect        rect2( 40000 * CONVERSION_CONSTANT, y, 50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT );
-    PdfXObject     xObj( rect, pDocument );
-    PdfPainter     pnt;    // XObject painter
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-    image.LoadFromFile( "resources/lena.jpg" );
-#endif // PODOFO_HAVE_JPEG_LIB
-
-    pnt.SetPage( &xObj );
-    // Draw onto the XObject
-    pnt.SetFont( pDocument->CreateFont( "Comic Sans MS" ) );
-
-    pnt.GetFont()->SetFontSize( 8.0 );
-    pnt.SetStrokingColor( 1.0, 1.0, 1.0 );
-    pnt.SetColor( 1.0, 1.0, 0.0 );
-    pnt.FillRect( 0, 0, xObj.GetPageSize().GetWidth(), xObj.GetPageSize().GetHeight()  );
-    pnt.SetColor( 0.0, 0.0, 0.0 );
-    pnt.DrawRect( 0, 1000 * CONVERSION_CONSTANT, 1000 * CONVERSION_CONSTANT, 1000 * CONVERSION_CONSTANT );
-    pnt.DrawText( 0, 1000 * CONVERSION_CONSTANT, "I am a XObject." );
-    pnt.FinishPage();
-
-    printf("Drawing on the page!\n");
-    // Draw onto the page 
-
-#ifdef PODOFO_HAVE_JPEG_LIB
-	/*
-    pPainter->DrawImage( 40000 * CONVERSION_CONSTANT, y, &image, 0.3, 0.3 );
-    pPainter->DrawImage( 40000 * CONVERSION_CONSTANT, y - (100000 * CONVERSION_CONSTANT), &image, 0.2, 0.5 );
-    pPainter->DrawImage( 40000 * CONVERSION_CONSTANT, y - (200000 * CONVERSION_CONSTANT), &image, 0.3, 0.3 );
-	*/
-	pPainter->DrawImage( 0.0, pPage->GetPageSize().GetHeight() - image.GetHeight(), &image );
-#endif // PODOFO_HAVE_JPEG_LIB
-
-    pPainter->DrawXObject( 120000 * CONVERSION_CONSTANT, y - (50000 * CONVERSION_CONSTANT), &xObj );
-	pPainter->FillRect( 120000 * CONVERSION_CONSTANT, y - (50000 * CONVERSION_CONSTANT), 1000 * CONVERSION_CONSTANT, 1000 * CONVERSION_CONSTANT ); 
-
-    PdfAnnotation* pAnnot1 = pPage->CreateAnnotation( ePdfAnnotation_Widget, rect1 );
-    PdfAnnotation* pAnnot2 = pPage->CreateAnnotation( ePdfAnnotation_Link, rect2 );
-    PdfAnnotation* pAnnot3 = pPage->CreateAnnotation( ePdfAnnotation_Text, PdfRect( 20.0, 20.0, 20.0, 20.0 ) );
-    PdfAnnotation* pAnnot4 = pPage->CreateAnnotation( ePdfAnnotation_FreeText, PdfRect( 70.0, 20.0, 250.0, 50.0 ) );
-    PdfAnnotation* pAnnot5 = pPage->CreateAnnotation( ePdfAnnotation_Popup, PdfRect( 300.0, 20.0, 250.0, 50.0 ) );
-
-    pAnnot1->SetTitle( PdfString("Author: Dominik Seichter") );
-    pAnnot1->SetContents( PdfString("Hallo Welt!") );
-    pAnnot1->SetAppearanceStream( &xObj );
-
-    PdfAction action( ePdfAction_URI, pDocument );
-    action.SetURI( PdfString("http://podofo.sf.net") );
-
-    //pAnnot2->SetDestination( pPage );
-    pAnnot2->SetAction( action );
-    pAnnot2->SetFlags( ePdfAnnotationFlags_NoZoom );
-
-    pAnnot3->SetTitle( "A text annotation" );
-    pAnnot3->SetContents( "Lorum ipsum dolor..." );
-
-    pAnnot4->SetContents( "An annotation of type ePdfAnnotation_FreeText." );
-
-    pAnnot5->SetContents( "A popup annotation." );
-    pAnnot5->SetOpen( true );
-}
-
-void EllipseTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    PdfAnnotation* pFileAnnotation;
-
-    double        dX     = 10000 * CONVERSION_CONSTANT;
-    double        dY     = pPage->GetPageSize().GetHeight() - 40000 * CONVERSION_CONSTANT;
-
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawEllipse( dX, dY, 20000 * CONVERSION_CONSTANT, 20000 * CONVERSION_CONSTANT );
-
-    dY -= 30000 * CONVERSION_CONSTANT;
-    pPainter->SetColor( 1.0, 0.0, 0.0 );
-    pPainter->FillEllipse( dX, dY, 20000 * CONVERSION_CONSTANT, 20000 * CONVERSION_CONSTANT );
-
-    PdfFileSpec file( "resources/lena.jpg", true, pDocument );
-    pFileAnnotation =  pPage->CreateAnnotation( ePdfAnnotation_FileAttachement, PdfRect( 300.0, 400.0, 250.0, 50.0 ) );
-    pFileAnnotation->SetContents( "A JPEG image of Lena" );
-    pFileAnnotation->SetFileAttachement( file );
-}
-
-void XObjectTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    double     x     = 10000 * CONVERSION_CONSTANT;
-    double     y     = pPage->GetPageSize().GetHeight() - 10000 * CONVERSION_CONSTANT;
-    const double dWidth  = 180000 * CONVERSION_CONSTANT; // 18cm
-    const double dHeight = 270000 * CONVERSION_CONSTANT; // 27cm
-
-    pPainter->SetColor( 1.0, 0.8, 0.8 );
-    pPainter->FillRect( x, y - dHeight, dWidth, dHeight );
-    
-    // Das funktioniert immer
-    PdfXObject xObj1( "resources/Illust.pdf", 0, pDocument );
-    pPainter->DrawXObject( x + 90000 * CONVERSION_CONSTANT, 
-                           y - dHeight,
-						   &xObj1 );
-    pPainter->SetColor( 1.0, 0.0, 0.0 );
-    pPainter->FillRect( x + 90000 * CONVERSION_CONSTANT, 
-                        y - dHeight,
-                        1000 * CONVERSION_CONSTANT,
-                        1000 * CONVERSION_CONSTANT );
-    
-    
-
-    // Test XObject in XObject
-    PdfRect        rectX( 0, 0, 50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT );
-    PdfXObject     xObj3( rectX, pDocument );
-    PdfXObject     xObj4( rectX, pDocument );
-    
-    // Draw text onto the XObject3
-    pPainter->SetPage( &xObj3 );
-    pPainter->SetColor( 0.0, 1.0, 0.0 );
-    pPainter->FillRect( 0.0, 0.0, rectX.GetWidth(), rectX.GetHeight() );
-    pPainter->SetFont( pDocument->CreateFont( "Comic Sans MS" ) );
-    pPainter->SetColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawText( 0, 1000 * CONVERSION_CONSTANT, "I am XObject 3." );
-    pPainter->FinishPage();
-    
-    // Draw text and pdf onto the XObject4
-    pPainter->SetPage( &xObj4 );
-    pPainter->SetColor( 0.0, 1.0, 0.0 );
-    pPainter->FillRect( 0.0, 0.0, rectX.GetWidth(), rectX.GetHeight() );
-    pPainter->SetFont( pDocument->CreateFont( "Comic Sans MS" ) );
-    pPainter->SetColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawText( 0, 1000 * CONVERSION_CONSTANT, "I am XObject 4." );
-    PdfXObject xObj5( "resources/Illust.pdf", 0, pDocument );
-    pPainter->DrawXObject( 5000 * CONVERSION_CONSTANT, 
-                           5000 * CONVERSION_CONSTANT, 
-                           &xObj5, 
-                           0.1, 
-                           0.1 );
-    pPainter->FinishPage();
-    
-    
-    // Switch back to page and draw Xobject 3+4
-    pPainter->SetPage( pPage );
-    pPainter->DrawXObject( 20000 * CONVERSION_CONSTANT, 
-                           y - 60000 * CONVERSION_CONSTANT, 
-                           &xObj3 );
-    pPainter->DrawXObject( 120000 * CONVERSION_CONSTANT, 
-						   y - 60000 * CONVERSION_CONSTANT, 
-                           &xObj4 );
-}
-
-void MMTest( PdfPainterMM* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    long        lX     = 10000;
-    long        lY     = static_cast<long>(pPage->GetPageSize().GetHeight()/CONVERSION_CONSTANT) - 40000;
-
-    pPainter->SetStrokingColor( 0.0, 0.0, 0.0 );
-    pPainter->DrawEllipseMM( lX, lY, 20000, 20000 );
-
-    lY -= 30000;
-
-    pPainter->SetColor( 1.0, 0.0, 0.0 );
-    pPainter->FillEllipseMM( lX, lY, 20000, 20000 );
-
-    lY -= 60000;
-
-    // let's test out the opacity features
-    PdfExtGState	trans( pDocument );
-    trans.SetFillOpacity( 0.5 );
-    pPainter->SetExtGState( &trans );
-    pPainter->SetColor( 1.0, 0.0, 0.0 );
-    pPainter->FillEllipseMM( lX, lY, 20000, 20000 );
-    pPainter->SetColor( 0.0, 1.0, 0.0 );
-    pPainter->FillEllipseMM( lX+20000, lY, 20000, 20000 );
-    pPainter->SetColor( 0.0, 0.0, 1.0 );
-    pPainter->FillEllipseMM( lX+10000, lY-10000, 20000, 20000 );
-
-
-}
-
-void TableTest( PdfPainter* pPainter, PdfPage* pPage, PdfDocument* pDocument )
-{
-    int i,z;
-    double        dX     = 10000 * CONVERSION_CONSTANT;
-    double        dY     = (pPage->GetPageSize().GetHeight() - 40000 * CONVERSION_CONSTANT);
-
-    PdfFont* pFont = pDocument->CreateFont( "Comic Sans MS" );
-    pFont->SetFontSize( 12.0f );
-    pPainter->SetFont( pFont );
-
-    const int nCols = 3;
-    const int nRows = 10;
-    PdfSimpleTableModel model( nCols, nRows );
-    for(i=0;i<nCols;i++)
-        for(z=0;z<nRows;z++) 
-        {
-            std::ostringstream oss;
-            oss << "Cell " << i << " " << z;
-            model.SetText( i, z, PdfString( oss.str() ) );
-        }
-
-    PdfTable table1( nCols, nRows );
-    table1.SetTableWidth ( 80000 * CONVERSION_CONSTANT );
-    table1.SetTableHeight( 120000 * CONVERSION_CONSTANT );
-    table1.SetModel( &model );
-    table1.Draw( dX, dY, pPainter );
-
-
-    dY = pPage->GetPageSize().GetHeight()/2.0 - 30000 * CONVERSION_CONSTANT;
-    dX = 2000.0 * CONVERSION_CONSTANT;
-
-    const int nCols2 = 5;
-    const int nRows2 = 4;
-    PdfSimpleTableModel model2( nCols2, nRows2 );
-    model2.SetAlignment( ePdfAlignment_Center );
-    model2.SetBackgroundColor( PdfColor( 0.3 ) );
-    model2.SetBackgroundEnabled( true );
-    for(i=0;i<nCols2;i++)
-        for(z=0;z<nRows2;z++) 
-        {
-            std::ostringstream oss;
-            oss << rand();
-            model2.SetText( i, z, PdfString( oss.str() ) );
-        }
-
-    PdfTable table2( nCols2, nRows2 );
-    table2.SetModel( &model2 );
-    table2.Draw( dX, dY, pPainter );
-
-    
-}
-
-int main( int argc, char* argv[] ) 
-{
-    PdfMemDocument  writer;
-    //PdfStreamedDocument  writer ( argv[1], ePdfVersion_1_5, &PdfEncrypt( "dominik", "owner" ) );
-    PdfPage*        pPage;
-    PdfPainter      painter;
-    PdfPainterMM    painterMM;
-    PdfOutlines*    outlines;
-    PdfOutlineItem* pRoot;
-    if( argc != 2 )
-    {
-        printf("Usage: CreationTest [output_filename]\n");
-        return 0;
-    }
-
-    printf("This test tests the PdfWriter and PdfDocument classes.\n");
-    printf("It creates a new PdfFile from scratch.\n");
-    printf("---\n");
-
-    printf("PoDoFo DataType Size Information:\n");
-    printf("---\n");
-    printf("sizeof variant=%lu\n", sizeof(PdfVariant) );
-    printf("sizeof object=%lu\n", sizeof(PdfObject) );
-    printf("sizeof reference=%lu\n", sizeof(PdfReference) );
-    printf("---\n\n");
- 
-    outlines = writer.GetOutlines();
-    pRoot = outlines->CreateRoot("PoDoFo Test Document" );
-
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painter.SetPage( pPage );
-    pRoot->CreateChild( "Line Test", PdfDestination( pPage ) );
-
-    printf("Drawing the first page with various lines.\n");
-    TEST_SAFE_OP( LineTest( &painter, pPage, &writer ) );
-
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_Letter ) );
-    painter.SetPage( pPage );
-
-    PdfString sLoremIpsum( pszLoremIpsum );
-
-    painter.DrawMultiLineText( 50.0, 50.0,
-                               pPage->GetMediaBox().GetWidth() - 100.0,
-                               pPage->GetMediaBox().GetHeight() - 100.0, sLoremIpsum );
-    painter.FinishPage();
-    /*
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_Letter ) );
-    painter.SetPage( pPage );
-    pRoot->Last()->CreateNext( "Rectangles Test", PdfDestination( pPage ) );
-
-    printf("Drawing the second page with various rectangle and triangles.\n");
-    TEST_SAFE_OP( RectTest( &painter, pPage, &writer ) );
-
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painter.SetPage( pPage );
-    pRoot->Last()->CreateNext( "Text Test", PdfDestination( pPage ) );
-
-    printf("Drawing some text.\n");
-    TEST_SAFE_OP( TextTest( &painter, pPage, &writer ) );
-
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painter.SetPage( pPage );
-    pRoot->Last()->CreateNext( "Image Test", PdfDestination( pPage ) );
-
-    printf("Drawing some images.\n");
-    TEST_SAFE_OP( ImageTest( &painter, pPage, &writer ) );
-
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painter.SetPage( pPage );
-    pRoot->Last()->CreateNext( "Circle Test", PdfDestination( pPage ) );
-
-    printf("Drawing some circles and ellipsis.\n");
-    TEST_SAFE_OP( EllipseTest( &painter, pPage, &writer ) );
-    painter.FinishPage();
-
-    printf("Drawing some XObject's.\n");
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painter.SetPage( pPage );
-    TEST_SAFE_OP( XObjectTest( &painter, pPage, &writer ) );
-    painter.FinishPage();
-
-    printf("Drawing using PdfTable.\n");
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painter.SetPage( pPage );
-    pRoot->Last()->CreateNext( "PdfTable Test", PdfDestination( pPage ) );
-    TEST_SAFE_OP( TableTest( &painter, pPage, &writer ) );
-    painter.FinishPage();
-
-    printf("Drawing using PdfPainterMM.\n");
-    pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    painterMM.SetPage( pPage );
-    pRoot->Last()->CreateNext( "MM Test", PdfDestination( pPage ) );
-
-    TEST_SAFE_OP( MMTest( &painterMM, pPage, &writer ) );
-
-    painterMM.FinishPage();
-    */
-#if 0
-    /** Create a really large name tree to test the name tree implementation
-     */
-    for( int zz=1;zz<500;zz++ ) 
-    {
-        std::ostringstream oss;
-        oss << "A" << zz;
-
-        writer.GetNamesTree()->AddValue( "TestDict", PdfString( oss.str() ), PdfVariant( static_cast<long>(zz) )  );
-    }
-
-    writer.GetNamesTree()->AddValue( "TestDict", PdfString( "Berta" ), PdfVariant( 42L )  );
-#endif
-
-    printf("Setting document informations.\n\n");
-    // Setup the document information dictionary
-    TEST_SAFE_OP( writer.GetInfo()->SetCreator ( PdfString("CreationTest - A simple test application") ) );
-    TEST_SAFE_OP( writer.GetInfo()->SetAuthor  ( PdfString("Dominik Seichter") ) );
-    TEST_SAFE_OP( writer.GetInfo()->SetTitle   ( PdfString("Test Document") ) );
-    //TEST_SAFE_OP( writer.GetInfo()->SetSubject ( PdfString("Testing the PDF Library") ) );
-    TEST_SAFE_OP( writer.GetInfo()->SetSubject ( 
-                      PdfString(reinterpret_cast<const pdf_utf8*>("「PoDoFo」は今から日本語も話せます。") ) ) );
-    TEST_SAFE_OP( writer.GetInfo()->SetKeywords( PdfString("Test;PDF;") ) );
-
-    //xTEST_SAFE_OP( writer.AttachFile( PdfFileSpec("../../../podofo/test/CreationTest/CreationTest.cpp", true, &writer ) ) );
-
-    TEST_SAFE_OP( writer.Write( argv[1] ) );
-    //TEST_SAFE_OP( writer.Close() );
-
-#ifdef TEST_MEM_BUFFER
-    // ---
-    const char*   pszMemFile = "./mem_out.pdf";
-    FILE*         hFile;
-
-    PdfRefCountedBuffer buffer;
-    PdfOutputDevice device( &buffer );
-    printf("Writing document from a memory buffer to: %s\n", pszMemFile );
-    TEST_SAFE_OP( writer.Write( &device ) );
-
-    hFile = fopen( pszMemFile, "wb" );
-    if( !hFile )
-    {
-        fprintf( stderr, "Cannot open file %s for writing.\n", pszMemFile );
-        return ePdfError_InvalidHandle;
-    }
-
-    long lBufferLen = device.GetLength();
-    printf("lBufferLen=%li\n", lBufferLen );
-    printf("Wrote=%i\n", static_cast<int>(fwrite( buffer.GetBuffer(), lBufferLen, sizeof( char ), hFile )) );
-    fclose( hFile );
-#endif
-
-    return 0;
-}
--- test/FormTest/FormTest.cpp.orig	2010-08-17 12:38:10.000000000 +0000
+++ test/FormTest/FormTest.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,341 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2007 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "../../src/podofo.h"
-
-#include "../PdfTest.h"
-
-#include <iostream>
-#include <cstdio>
-
-using namespace PoDoFo;
-
-#define CONVERSION_CONSTANT 0.002834645669291339
-
-void CreateComplexForm( PdfPage* pPage, PdfStreamedDocument* pDoc )
-{
-    PdfRect rect = pPage->GetPageSize();
-
-    PdfPainter painter;
-    PdfFont*   pFont = pDoc->CreateFont( "Courier" );
-
-    painter.SetPage( pPage );
-    painter.SetFont( pFont );
-
-    const char* pszTitle = "PoDoFo Sample Feedback Form";
-    pFont->SetFontSize( 18.0 );
-
-    double x = (rect.GetWidth() - pFont->GetFontMetrics()->StringWidth( pszTitle )) / 2.0;
-    double y = rect.GetHeight() - (20000.0 * CONVERSION_CONSTANT);
-
-    painter.DrawText( x, y, pszTitle );
-    pFont->SetFontSize( 10.0 );
-
-    y -= 10000.0 * CONVERSION_CONSTANT;
-    x  = 10000.0 * CONVERSION_CONSTANT;
-
-    double h = 10000.0 * CONVERSION_CONSTANT;
-    // Name
-    y -= 10000.0 * CONVERSION_CONSTANT;
-    painter.DrawText( x, y, "Your Name:" );
-    PdfTextField textName( pPage, PdfRect( 80000.0 * CONVERSION_CONSTANT, y - 2500.0 * CONVERSION_CONSTANT, 
-                                           80000.0 * CONVERSION_CONSTANT, h ), pDoc );
-    textName.SetFieldName("field_name");
-    textName.SetBorderColor( 1.0 );
-
-    // E-Mail
-    y -= 10000.0 * CONVERSION_CONSTANT;
-    painter.DrawText( x, y, "E-Mail Address:" );
-    PdfTextField textMail( pPage, PdfRect( 80000.0 * CONVERSION_CONSTANT, y - 2500.0 * CONVERSION_CONSTANT, 
-                                           80000.0 * CONVERSION_CONSTANT, h ), pDoc );
-    textMail.SetFieldName("field_mail");
-    textMail.SetBorderColor( 1.0 );
-    
-    // Interest
-    y -= 10000.0 * CONVERSION_CONSTANT;
-    painter.DrawText( x, y, "Job:" );
-
-    PdfComboBox comboJob( pPage, PdfRect( 80000.0 * CONVERSION_CONSTANT, y - 2500.0 * CONVERSION_CONSTANT, 
-                                          80000.0 * CONVERSION_CONSTANT, h ), pDoc );
-    comboJob.SetFieldName("field_combo");
-    comboJob.SetBorderColor( 1.0 );
-
-    comboJob.InsertItem( "Software Engineer" );
-    comboJob.InsertItem( "Student" );
-    comboJob.InsertItem( "Publisher" );
-    comboJob.InsertItem( "Other" );
-
-    // Open Source
-    y -= 11000.0 * CONVERSION_CONSTANT;
-    painter.DrawText( x, y, "I wan't to use PoDoFo in an Open Source application" );
-    PdfCheckBox checkOpenSource( pPage, PdfRect( 120000.0 * CONVERSION_CONSTANT, y - 2500.0 * CONVERSION_CONSTANT, 
-                                                 h, h ), pDoc );
-    checkOpenSource.SetFieldName("field_check_oss");
-
-    // Commercial
-    y -= 11000.0 * CONVERSION_CONSTANT;
-    painter.DrawText( x, y, "I wan't to use PoDoFo in a commercial application" );
-    PdfCheckBox checkCom( pPage, PdfRect( 120000.0 * CONVERSION_CONSTANT, y - 2500.0 * CONVERSION_CONSTANT, 
-                                          h, h ), pDoc );
-    checkCom.SetFieldName("field_check_com");
-
-    y -= 10000.0 * CONVERSION_CONSTANT;
-    painter.DrawText( x, y, "Some comments you want to send to the PoDoFo developers:" );
-    PdfTextField textComment( pPage, PdfRect( 20000.0 * CONVERSION_CONSTANT, y - 120000.0 * CONVERSION_CONSTANT,
-                                              160000.0 * CONVERSION_CONSTANT, 100000.0 * CONVERSION_CONSTANT ), pDoc );
-    textComment.SetFieldName("field_comment");
-    textComment.SetMultiLine( true );
-    textComment.SetRichText( true );
-    textComment.SetText( "<?xml version=\"1.0\"?><body xmlns=\"http://www.w3.org/1999/xtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:contentType=\"text/html\" xfa:APIVersion=\"Acrobat:8.0.0\" xfa:spec=\"2.4\"><p style=\"text-align:left\"><b><i>Here is some bold italic text</i></b></p><p style=\"font-size:16pt\">This text uses default text state parameters but changes the font size to 16.</p></body>");
-
-    PdfPushButton buttonSend( pPage, PdfRect( 10000 * CONVERSION_CONSTANT, 10000 * CONVERSION_CONSTANT,
-                                              25000 * CONVERSION_CONSTANT, 25000 * CONVERSION_CONSTANT ), pDoc );
-    buttonSend.SetFieldName("field_send");
-    buttonSend.SetCaption("Send");
-    buttonSend.SetBackgroundColor( 0.5 );
-
-    PdfPushButton buttonClear( pPage, PdfRect( 40000 * CONVERSION_CONSTANT, 10000 * CONVERSION_CONSTANT,
-                                               25000 * CONVERSION_CONSTANT, 25000 * CONVERSION_CONSTANT ), pDoc );
-    buttonClear.SetFieldName("field_clear");
-    buttonClear.SetCaption("Clear");
-    buttonClear.SetBackgroundColor( 0.5 );
-
-    PdfAction actionClear( ePdfAction_JavaScript, pDoc );
-    actionClear.SetScript( 
-        PdfString("this.getField(\"field_name\").value = \"\";" \
-                  "this.getField(\"field_mail\").value = \"\";" \
-                  "this.getField(\"field_combo\").value = \"\";" 
-                  "this.getField(\"field_check_oss.\").checkThisBox( 0, false );" \
-                  "this.getField(\"field_check_com.\").checkThisBox( 0, false );" \
-                  "this.getField(\"field_comment\").value = \"\";" ) );
-
-
-    buttonClear.SetMouseDownAction( actionClear );
-                  
-    PdfAction actionSubmit( ePdfAction_SubmitForm, pDoc );
-
-    buttonSend.SetMouseDownAction( actionSubmit );
-    
-    painter.FinishPage();
-}
-
-void CreateSimpleForm( PdfPage* pPage, PdfStreamedDocument* pDoc )
-{
-    PdfPainter painter;
-    PdfFont*   pFont = pDoc->CreateFont( "Courier" );
-
-    painter.SetPage( pPage );
-    painter.SetFont( pFont );
-    painter.DrawText( 10000 * CONVERSION_CONSTANT, 280000 * CONVERSION_CONSTANT, "PoDoFo Interactive Form Fields Test" );
-    painter.FinishPage();
-
-    PdfPushButton button( pPage, PdfRect( 10000 * CONVERSION_CONSTANT, 10000 * CONVERSION_CONSTANT,
-                                          50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT ), pDoc );
-
-    button.SetFieldName("ButtonFieldName");
-    button.SetAlternateName("ButtonAlternateName");
-    button.SetMappingName("ButtonMappingName");
-    button.SetCaption("Hallo Welt");
-
-
-    PdfAction action( ePdfAction_JavaScript, pDoc );
-    action.SetScript( 
-        PdfString("var str = this.getField(\"TextFieldName\").value;" \
-                  "var j = 4*5;" \
-                  "app.alert(\"Hello World! 4 * 5 = \" + j + \" Text Field: \" + str );") );
-
-    button.SetMouseDownAction( action );
-
-    PdfTextField text( pPage, PdfRect( 70000 * CONVERSION_CONSTANT, 10000 * CONVERSION_CONSTANT,
-                                       50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT ), pDoc );
-
-    text.SetFieldName("TextFieldName");
-    text.SetMultiLine( true );
-    text.SetMultiLine( false );
-
-
-    text.SetFileField( true );
-    printf("Text IsMultiLine: %i\n", text.IsMultiLine() );
-
-    PdfComboBox combo( pPage, PdfRect( 10000 * CONVERSION_CONSTANT, 250000 * CONVERSION_CONSTANT,
-                                         50000 * CONVERSION_CONSTANT, 10000 * CONVERSION_CONSTANT ), pDoc );
-
-    combo.SetFieldName("ComboFieldName");
-    combo.InsertItem( "Value1" );
-    combo.InsertItem( "Value2" );
-    combo.InsertItem( "Value3" );
-    combo.InsertItem( "XXXX", "Displayed Text" );
-    combo.SetEditable( true );
-    combo.SetSelectedItem( 1 );
-
-    printf("IsComboBox: %i\n", combo.IsComboBox() );
-    printf("Count     : %i\n", static_cast<int>(combo.GetItemCount()) );
-    printf("Selected  : %i\n", combo.GetSelectedItem() );
-
-    PdfListBox listBox( pPage, PdfRect( 70000 * CONVERSION_CONSTANT, 200000 * CONVERSION_CONSTANT,
-                                        50000 * CONVERSION_CONSTANT, 50000 * CONVERSION_CONSTANT ), pDoc );
-
-    listBox.SetFieldName("ListBoxFieldName");
-    listBox.InsertItem( "Value1", "Display 1" );
-    listBox.InsertItem( "Value2", "Display 2" );
-    listBox.InsertItem( "Value3", "Display 3" );
-    //listBox.InsertItem( "XXXX", "Displayed Text" );
-    listBox.SetMultiSelect( true );
-    listBox.SetSelectedItem( 2 );
-}
-
-void FillTextField( PdfTextField & rField ) 
-{
-    const char* pszCur = rField.GetText().GetString();
-    std::cout << "  Current value:" << (pszCur ? pszCur : "") << std::endl;
-
-    std::string value;
-    std::cout << "  Enter new value (if empty value is unchanged):" << std::endl;
-    getline( std::cin, value );
-
-    if( value.length() )
-    {
-        rField.SetText( value );
-    }
-}
-
-void FillListField( PdfListField & rField ) 
-{
-    const char* pszCur = ( rField.GetSelectedItem() == -1 ? NULL : 
-                           rField.GetItemDisplayText( rField.GetSelectedItem() ).GetString() );
-    std::cout << "  Current value:" << (pszCur ? pszCur : "") << std::endl;
-    std::cout << "  Values:" << std::endl;
-    
-    for( int i=0;i<static_cast<int>(rField.GetItemCount());i++ )
-    {
-        pszCur = rField.GetItemDisplayText( i ).GetString();
-        std::cout << "     " << i << " " << (pszCur ? pszCur : "") << std::endl;
-    }
-
-    int nValue;
-    std::cout << "  Enter index of new value:" << std::endl;
-    std::cin >> nValue;
-
-    if( nValue >= 0 && nValue < static_cast<int>(rField.GetItemCount()) )
-        rField.SetSelectedItem( nValue );
-}
-
-void FillForm( const char* pszFilename, const char* pszOutput ) 
-{
-    PdfMemDocument doc( pszFilename );
-    PdfPage*       pPage;
-    int            nPageCount = doc.GetPageCount();
-    int            nFieldCount;
-
-    for( int i=0;i<nPageCount;i++ )
-    {
-        pPage       = doc.GetPage( i );
-        nFieldCount = pPage->GetNumFields();
-
-        std::cout << "Page " << i + 1 << " contains " << nFieldCount << " fields." << std::endl;
-
-        for( int n=0;n<nFieldCount;n++ )
-        {
-            PdfField  field = pPage->GetField( n );
-            EPdfField eType = field.GetType();
-
-            std::cout << "  Field: " << field.GetFieldName().GetString() << std::endl;
-            std::cout << "  Type : ";
-
-            switch( eType )
-            {
-                case ePdfField_PushButton:
-                    std::cout << "PushButton" << std::endl;
-                    break;
-                case ePdfField_CheckBox:
-                    std::cout << "CheckBox" << std::endl;
-                    break;
-                case ePdfField_RadioButton:
-                    std::cout << "RadioButton" << std::endl;
-                    break;
-                case ePdfField_TextField:
-                {
-                    std::cout << "TextField" << std::endl;
-                    PdfTextField text( field ); 
-                    FillTextField( text );
-                    break;
-                }
-                case ePdfField_ComboBox:
-                {
-                    std::cout << "ComboBox" << std::endl;
-                    PdfListField lst( field );
-                    FillListField( lst ); 
-                    break;
-                }
-                case ePdfField_ListBox:
-                {
-                    std::cout << "ListBox" << std::endl;
-                    PdfListField lst( field );
-                    FillListField( lst ); 
-                    break;
-                }
-                case ePdfField_Signature:
-                    std::cout << "Signature" << std::endl;
-                    break;
-                case ePdfField_Unknown:
-                default:
-                    std::cout << "Unknown" << std::endl;
-                    break;
-            }
-
-            std::cout << std::endl;
-        }
-    }
-
-    doc.Write( pszOutput );
-}
-
-int main( int argc, char* argv[] ) 
-{
-    PdfPage*            pPage;
-
-    if( argc != 2 && argc != 3 )
-    {
-        printf("Usage: FormTest [output_filename]\n");
-        printf("       - Create a new example PDF form\n");
-        printf("       Formtest [input_filename] [output_filename]\n"); 
-        printf("       - Fill out an existing form and save it to a PDF file\n");
-        return 0;
-    }
-
-    if( argc == 3 )
-    {
-        TEST_SAFE_OP( FillForm( argv[1], argv[2] ) );
-    }
-    else
-    {
-        PdfStreamedDocument writer( argv[1] );
-
-        pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-        TEST_SAFE_OP( CreateComplexForm( pPage, &writer ) );
-
-        pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-        TEST_SAFE_OP( CreateSimpleForm( pPage, &writer ) );
-
-        TEST_SAFE_OP( writer.Close() );
-    }
-
-    return 0;
-}
--- test/LargeTest/LargeTest.cpp.orig	2009-08-24 15:27:45.000000000 +0000
+++ test/LargeTest/LargeTest.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,204 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2006 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include <podofo.h>
-#include <fontconfig/fontconfig.h>
-#include <cstdio>
-
-using namespace PoDoFo;
-
-#define MIN_PAGES 100
-
-bool writeImmediately = true;
-
-void AddPage( PdfDocument* pDoc, const char* pszFontName, const char* pszImagePath )
-{
-    PdfPainter painter;
-    PdfPage*   pPage;
-    PdfFont*   pFont;
-    PdfFont*   pArial;
-    PdfImage*  pImage;
-    PdfRect    rect;
- 
-    try {
-        pFont  = pDoc->CreateFont( pszFontName );
-    } catch ( const PdfError & e ) {
-        e.PrintErrorMsg();
-        return;
-    }
-    pPage  = pDoc->CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    pArial = pDoc->CreateFont( "Arial" );
-    pImage = new PdfImage( pDoc );
-
-    rect   = pPage->GetMediaBox();
-
-    const char* pszText = "The red brown fox jumps over the lazy dog!";
-    double     dX       = rect.GetLeft() + 20.0;
-    double     dY       = rect.GetBottom() + rect.GetHeight() - 20.0;
-    double     dW, dH;
-
-    pFont->SetFontSize( 16.0 );
-    pArial->SetFontSize( 24.0 );
-
-    painter.SetPage( pPage );
-    painter.SetFont( pFont );
-
-    dW = pFont->GetFontMetrics()->StringWidth( pszText );
-    dH = -pFont->GetFontMetrics()->GetDescent(); // GetDescent is usually negative!
-
-    pFont->SetFontSize( 24.0 );
-    dH += pFont->GetFontMetrics()->GetLineSpacing() * 2.0;
-
-    painter.DrawRect( dX, dY, dW, dH );
-
-    dY -= pFont->GetFontMetrics()->GetLineSpacing();
-    painter.DrawText( dX, dY, "Hello World!" );
-    dY -= pFont->GetFontMetrics()->GetLineSpacing();
-    pFont->SetFontSize( 16.0 );
-    painter.DrawText( dX, dY, pszText );
-
-    painter.SetFont( pArial );
-    dY -= pArial->GetFontMetrics()->GetLineSpacing();
-    painter.DrawText( dX, dY, "The font used in this example is:" );
-    dY -= pArial->GetFontMetrics()->GetLineSpacing();
-    painter.DrawText( dX, dY, pszFontName );
-    dY -= pArial->GetFontMetrics()->GetLineSpacing();
-
-#if defined PODOFO_HAVE_JPEG_LIB || defined PODOFO_HAVE_TIFF_LIB
-    try {
-        pImage->LoadFromFile( pszImagePath );
-    }
-    catch( const PdfError & e ) 
-    {
-        e.PrintErrorMsg();
-    }
-
-    dY -= (pImage->GetHeight() * 0.5);
-    dX = ((rect.GetWidth() - (pImage->GetWidth()*0.5))/2.0);
-    painter.DrawImage( dX, dY, pImage, 0.5, 0.5 );
-    delete pImage; // delete image right after drawing
-#endif
-
-    painter.FinishPage();
-}
-
-void CreateLargePdf( const char* pszFilename, const char* pszImagePath )
-{
-    PdfDocument*         pDoc = NULL;
-    FcObjectSet*         pObjectSet;
-    FcFontSet*           pFontSet;
-    FcPattern*           pPattern;
-
-    if( !FcInit() ) 
-    {
-        fprintf( stderr, "Cannot load fontconfig!\n");
-        return;
-    }
-
-    pPattern   = FcPatternCreate();
-    pObjectSet = FcObjectSetBuild( FC_FAMILY, FC_STYLE, NULL );
-    pFontSet   = FcFontList( 0, pPattern, pObjectSet );
-
-    FcObjectSetDestroy( pObjectSet );
-    FcPatternDestroy( pPattern );
-
-    if( writeImmediately ) 
-        pDoc = new PdfStreamedDocument( pszFilename );
-    else 
-        pDoc = new PdfMemDocument();
-
-    if( pFontSet )
-    {
-        for( int i=0; i< (pFontSet->nfont > MIN_PAGES ? MIN_PAGES : pFontSet->nfont );i++ )
-        {
-            FcValue v;
-
-            //FcPatternPrint( pFontSet->fonts[i] );
-            FcPatternGet( pFontSet->fonts[i], FC_FAMILY, 0, &v );
-            //font = FcNameUnparse( pFontSet->fonts[i] );
-            printf(" -> Drawing with font: %s\n", reinterpret_cast<const char*>(v.u.s) );
-            AddPage( pDoc, reinterpret_cast<const char*>(v.u.s), pszImagePath );
-        }
-
-        FcFontSetDestroy( pFontSet );
-    }
-    
-
-    if( writeImmediately )
-        static_cast<PdfStreamedDocument*>(pDoc)->Close();
-    else
-        static_cast<PdfMemDocument*>(pDoc)->Write( pszFilename );
-    delete pDoc;
-}
-
-void usage()
-{
-    printf("Usage: LargetTest [-m] output_filename image_file\n"
-           "       output_filename: filename to write produced pdf to\n"
-           "       image_file:      An image to embed in the PDF file\n"
-           "Options:\n"
-           "       -m               Build entire document in memory before writing\n"
-           "\n"
-           "Note that output should be the same with and without the -m option.\n");
-}
-
-int main( int argc, char* argv[] ) 
-{
-    if( argc < 3 || argc > 4 )
-    {
-        usage();
-        return 1;
-    }
-    else if ( argc == 4)
-    {
-        // Handle options
-        // Is this argument an option?
-        if (argv[1][0] != '-')
-        {
-            usage();
-            return 1;
-        }
-        // Is it a recognised option?
-        if (argv[1][1] == 'm')
-        {
-            // User wants us to build the whole doc in RAM before writing it out.
-            writeImmediately = false;
-            ++argv;
-        }
-        else
-        {
-            printf("Unrecognised argument: %s", argv[1]);
-            usage();
-            return 1;
-        }
-    }
-
-    try {
-        CreateLargePdf( argv[1], argv[2] );
-
-        printf("\nWrote the PDF file %s successfully\n", argv[1] ); 
-
-    } catch( PdfError & e ) {
-        e.PrintErrorMsg();
-        return e.GetError();
-    }
-
-    return 0;
-}
--- test/unit/EncodingTest.cpp.orig	2012-12-12 22:55:46.000000000 +0000
+++ test/unit/EncodingTest.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,392 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include <podofo.h>
-
-#include <ostream>
-
-using namespace PoDoFo;
-
-inline std::ostream& operator<<(std::ostream& o, const PdfVariant& s)
-{
-    std::string str;
-    s.ToString(str);
-    return o << str;
-}
-
-// Needs to be included after the redifition of operator<<
-// or it won't compile using clang
-#include "EncodingTest.h"
-
-// Registers the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION( EncodingTest );
-
-void EncodingTest::setUp()
-{
-}
-
-void EncodingTest::tearDown()
-{
-}
-
-void EncodingTest::testDifferences()
-{
-    PdfEncodingDifference difference;
-
-    // Newly created encoding should be empty
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(difference.GetCount()), 0 );
-
-
-    // Adding 0 should work
-    difference.AddDifference( 0, PdfName("A") );
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(difference.GetCount()), 1 );
-
-    // Adding 255 should work
-    difference.AddDifference( 255, PdfName("B") );
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(difference.GetCount()), 2 );
-
-    // Adding out of range should throw exception
-    CPPUNIT_ASSERT_THROW( difference.AddDifference( -1, PdfName("C") );, PdfError );
-    CPPUNIT_ASSERT_THROW( difference.AddDifference( 256, PdfName("D") );, PdfError );
-
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(difference.GetCount()), 2 );
-
-    // Convert to array
-    PdfArray data;
-    PdfArray expected;
-    expected.push_back( static_cast<pdf_int64>(0LL) );
-    expected.push_back( PdfName("A") );
-    expected.push_back( static_cast<pdf_int64>(255LL) );
-    expected.push_back( PdfName("B") );
-
-    difference.ToArray( data );
-
-    CPPUNIT_ASSERT_EQUAL( data.GetSize(), expected.GetSize() );
-    for( unsigned int i=0;i<data.GetSize(); i++ )
-        CPPUNIT_ASSERT_EQUAL( data[i], expected[i] );
-
-
-    // Test replace
-    expected.Clear();
-    expected.push_back( static_cast<pdf_int64>(0LL) );
-    expected.push_back( PdfName("A") );
-    expected.push_back( static_cast<pdf_int64>(255LL) );
-    expected.push_back( PdfName("X") );
-
-    difference.AddDifference( 255, PdfName("X") );
-
-    difference.ToArray( data );
-
-    CPPUNIT_ASSERT_EQUAL( data.GetSize(), expected.GetSize() );
-    for( unsigned int i=0;i<data.GetSize(); i++ )
-        CPPUNIT_ASSERT_EQUAL( data[i], expected[i] );
-
-
-    // Test more complicated array
-    expected.Clear();
-    expected.push_back( static_cast<pdf_int64>(0LL) );
-    expected.push_back( PdfName("A") );
-    expected.push_back( PdfName("B") );
-    expected.push_back( PdfName("C") );
-    expected.push_back( static_cast<pdf_int64>(4LL) );
-    expected.push_back( PdfName("D") );
-    expected.push_back( PdfName("E") );
-    expected.push_back( static_cast<pdf_int64>(9LL) );
-    expected.push_back( PdfName("F") );
-    expected.push_back( static_cast<pdf_int64>(255LL) );
-    expected.push_back( PdfName("X") );
-
-    difference.AddDifference( 1, PdfName("B") );
-    difference.AddDifference( 2, PdfName("C") );
-    difference.AddDifference( 4, PdfName("D") );
-    difference.AddDifference( 5, PdfName("E") );
-    difference.AddDifference( 9, PdfName("F") );
-
-    difference.ToArray( data );
-
-    CPPUNIT_ASSERT_EQUAL( data.GetSize(), expected.GetSize() );
-    for( unsigned int i=0;i<data.GetSize(); i++ )
-        CPPUNIT_ASSERT_EQUAL( data[i], expected[i] );
-
-
-    // Test if contains works correctly
-    PdfName name;
-    pdf_utf16be value;
-    CPPUNIT_ASSERT_EQUAL( difference.Contains( 0, name, value ), true );
-    CPPUNIT_ASSERT_EQUAL( name, PdfName("A") ); 
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(value), 0x4100 ); 
-#else
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(value), 0x0041 ); 
-#endif //PODOFO_IS_LITTLE_ENDIAN
-
-    CPPUNIT_ASSERT_EQUAL( difference.Contains( 9, name, value ), true );
-    CPPUNIT_ASSERT_EQUAL( name, PdfName("F") ); 
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(value), 0x4600 ); 
-#else
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(value), 0x0046 ); 
-#endif //PODOFO_IS_LITTLE_ENDIAN
-
-    CPPUNIT_ASSERT_EQUAL( difference.Contains( 255, name, value ), true );
-    CPPUNIT_ASSERT_EQUAL( name, PdfName("X") ); 
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(value), 0x5800 ); 
-#else
-    CPPUNIT_ASSERT_EQUAL( static_cast<int>(value), 0x0058 ); 
-#endif //PODOFO_IS_LITTLE_ENDIAN
-
-    CPPUNIT_ASSERT_EQUAL( difference.Contains( 100, name,value ), false );
-   
-}
-
-void EncodingTest::testDifferencesObject()
-{
-    PdfMemDocument doc;
-    PdfEncodingDifference difference;
-    difference.AddDifference( 1, PdfName("B") );
-    difference.AddDifference( 2, PdfName("C") );
-    difference.AddDifference( 4, PdfName("D") );
-    difference.AddDifference( 5, PdfName("E") );
-    difference.AddDifference( 9, PdfName("F") );
-
-    PdfDifferenceEncoding encoding( difference, PdfDifferenceEncoding::eBaseEncoding_MacRoman, &doc );
-
-    // Check for encoding key
-    PdfObject* pObj = doc.GetObjects().CreateObject();
-    encoding.AddToDictionary( pObj->GetDictionary() );
-
-    CPPUNIT_ASSERT_EQUAL( true, pObj->GetDictionary().HasKey( PdfName("Encoding") ) );
-
-    PdfObject* pKey = pObj->GetDictionary().GetKey( PdfName("Encoding") );
-    CPPUNIT_ASSERT_EQUAL( true, pKey->IsReference() );
-
-    PdfObject* pEncoding = doc.GetObjects().GetObject( pKey->GetReference() );
-
-    // Test BaseEncoding
-    PdfObject* pBase = pEncoding->GetDictionary().GetKey( PdfName("BaseEncoding" ) );
-    CPPUNIT_ASSERT_EQUAL( pBase->GetName(), PdfName("MacRomanEncoding") );
-    
-    // Test differences
-    PdfObject* pDiff = pEncoding->GetDictionary().GetKey( PdfName("Differences" ) );
-    PdfArray   expected;
-
-    expected.push_back( static_cast<pdf_int64>(1LL) );
-    expected.push_back( PdfName("B") );
-    expected.push_back( PdfName("C") );
-    expected.push_back( static_cast<pdf_int64>(4LL) );
-    expected.push_back( PdfName("D") );
-    expected.push_back( PdfName("E") );
-    expected.push_back( static_cast<pdf_int64>(9LL) );
-    expected.push_back( PdfName("F") );
-
-    const PdfArray & data = pDiff->GetArray();
-    CPPUNIT_ASSERT_EQUAL( data.GetSize(), expected.GetSize() );
-    for( unsigned int i=0;i<data.GetSize(); i++ )
-        CPPUNIT_ASSERT_EQUAL( data[i], expected[i] );
-}
-
-void EncodingTest::testDifferencesEncoding()
-{
-    PdfMemDocument doc;
-
-    // Create a differences encoding where A and B are exchanged
-    PdfEncodingDifference difference;
-    difference.AddDifference( 0x0041, PdfName("B") );
-    difference.AddDifference( 0x0042, PdfName("A") );
-
-    PdfDifferenceEncoding encoding( difference, PdfDifferenceEncoding::eBaseEncoding_WinAnsi, &doc );
-
-    PdfString unicodeStr = encoding.ConvertToUnicode( PdfString("BAAB"), NULL );
-    CPPUNIT_ASSERT_EQUAL( PdfString("ABBA"), unicodeStr );
-
-    PdfRefCountedBuffer encodingStr = encoding.ConvertToEncoding( PdfString("ABBA"), NULL );
-    CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(4), encodingStr.GetSize() );
-    CPPUNIT_ASSERT_EQUAL( memcmp("BAAB", encodingStr.GetBuffer(), encodingStr.GetSize()), 0 );
-}
-
-void EncodingTest::testUnicodeNames()
-{
-    // List of items which are defined twice and cause
-    // other ids to be returned than those which where send in
-    const char* pszDuplicated[] = {
-        "Delta",
-        "fraction",
-        "hyphen",
-        "macron",
-        "mu",
-        "Omega",
-        "periodcentered",
-        "scedilla",
-        "Scedilla",
-        "space",
-        "tcommaaccent",
-        "Tcommaaccent",
-        "exclamsmall",
-        "dollaroldstyle",
-        "zerooldstyle",
-        "oneoldstyle",
-        "twooldstyle",
-        "threeoldstyle",
-        "fouroldstyle",
-        "fiveoldstyle",
-        "sixoldstyle",
-        "sevenoldstyle",
-        "eightoldstyle",
-        "nineoldstyle",
-        "ampersandsmall",
-        "questionsmall",
-        NULL
-    };
-
-    int nCount = 0;
-    for( int i = 0;i<=0xFFFF; i++ ) 
-    {
-        PdfName name = PdfDifferenceEncoding::UnicodeIDToName( static_cast<pdf_utf16be>(i) );
-
-        pdf_utf16be id = PdfDifferenceEncoding::NameToUnicodeID( name );
-
-        bool bFound = false;
-        const char** pszDup = pszDuplicated;
-        while( *pszDup ) 
-        {
-            if( PdfName( *pszDup ) == name ) 
-            {
-                bFound = true;
-                break;
-            }
-
-            ++pszDup;
-        }
-
-        if( !bFound )
-        {
-            // Does not work because of 2 many duplicates...
-            //CPPUNIT_ASSERT_EQUAL_MESSAGE( name.GetName(), id, static_cast<pdf_utf16be>(i) );
-            if( id == static_cast<pdf_utf16be>(i) )
-                ++nCount;
-        }
-    }
-
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "Compared codes count", 65422, nCount );
-}
-
-void EncodingTest::testGetCharCode()
-{
-    std::string msg;
-    bool        ret;
-
-    PdfWinAnsiEncoding cWinAnsiEncoding;
-    ret = outofRangeHelper( &cWinAnsiEncoding, msg, "PdfWinAnsiEncoding" );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( msg, ret, true );
-
-    PdfMacRomanEncoding cMacRomanEncoding;
-    ret = outofRangeHelper( &cMacRomanEncoding, msg, "PdfMacRomanEncoding" );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( msg, ret, true );
-
-    PdfIdentityEncoding cIdentityEncoding;
-    ret = outofRangeHelper( &cIdentityEncoding, msg, "PdfIdentityEncoding" );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( msg, ret, true );
-
-    PdfVecObjects vec;
-    vec.SetAutoDelete( true );
-    PdfEncodingDifference difference;
-    difference.AddDifference( 0x0041, PdfName("B") );
-    difference.AddDifference( 0x0042, PdfName("A") );
-    PdfDifferenceEncoding cDifferenceEncoding( difference, PdfDifferenceEncoding::eBaseEncoding_WinAnsi, &vec );
-    ret = outofRangeHelper( &cDifferenceEncoding, msg, "PdfDifferenceEncoding" );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( msg, ret, true );
-
-#ifdef PODOFO_IS_LITTLE_ENDIAN
-    CPPUNIT_ASSERT_EQUAL( static_cast<pdf_utf16be>(0x4200), cDifferenceEncoding.GetCharCode( 0x0041 ) );
-    CPPUNIT_ASSERT_EQUAL( static_cast<pdf_utf16be>(0x4100), cDifferenceEncoding.GetCharCode( 0x0042 ) );
-#else
-    CPPUNIT_ASSERT_EQUAL( static_cast<pdf_utf16be>(0x0042), cDifferenceEncoding.GetCharCode( 0x0041 ) );
-    CPPUNIT_ASSERT_EQUAL( static_cast<pdf_utf16be>(0x0041), cDifferenceEncoding.GetCharCode( 0x0042 ) );
-#endif // PODOFO_IS_LITTLE_ENDIAN
-}
-
-bool EncodingTest::outofRangeHelper( PdfEncoding* pEncoding, std::string & rMsg, const char* pszName )
-{
-    bool exception = false;
-
-    try {
-	pEncoding->GetCharCode( pEncoding->GetFirstChar() );
-    } 
-    catch( const PdfError & rError ) 
-    {
-	// This may not throw!
-	rMsg = "pEncoding->GetCharCode( pEncoding->GetFirstChar() ) failed";
-	return false;
-    }
-
-    try {
-	pEncoding->GetCharCode( pEncoding->GetFirstChar() - 1 );
-    } 
-    catch( const PdfError & rError ) 
-    {
-	// This has to throw!
-	exception = true;
-    }
-
-    if( !exception ) 
-    {
-	rMsg = "pEncoding->GetCharCode( pEncoding->GetFirstChar() - 1 ); failed";
-	return false;
-    }
-
-    try {
-	pEncoding->GetCharCode( pEncoding->GetLastChar() );
-    } 
-    catch( const PdfError & rError ) 
-    {
-	// This may not throw!
-	rMsg = "pEncoding->GetCharCode( pEncoding->GetLastChar()  ); failed";
-	return false;
-    }
-
-    exception = false;
-    try {
-	pEncoding->GetCharCode( pEncoding->GetLastChar() + 1 );
-    } 
-    catch( const PdfError & rError ) 
-    {
-	// This has to throw!
-	exception = true;
-    }
-
-    if( !exception ) 
-    {
-	rMsg = "pEncoding->GetCharCode( pEncoding->GetLastChar() + 1 ); failed";
-	return false;
-    }
-
-    PdfEncoding::const_iterator it = pEncoding->begin();
-    int nCount = pEncoding->GetFirstChar();
-    while( it != pEncoding->end() ) 
-    {
-	CPPUNIT_ASSERT_EQUAL_MESSAGE( pszName, *it, pEncoding->GetCharCode( nCount ) );
-
-	++nCount;
-	++it;
-    }
-
-    return true;
-}
--- test/unit/EncryptTest.cpp.orig	2024-06-29 17:32:05.036340031 +0000
+++ test/unit/EncryptTest.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,387 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU Library General Public License as       *
- *   published by the Free Software Foundation; either version 2 of the    *
- *   License, or (at your option) any later version.                       *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU Library General Public     *
- *   License along with this program; if not, write to the                 *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "EncryptTest.h"
-#include "TestUtils.h"
-
-#include <stdlib.h>
-
-using namespace PoDoFo;
-
-// Registers the fixture into the 'registry'
-CPPUNIT_TEST_SUITE_REGISTRATION( EncryptTest );
-
-void EncryptTest::setUp()
-{
-    const char* pBuffer1 = "Somekind of drawing \001 buffer that possibly \003 could contain PDF drawing commands";
-    const char* pBuffer2 = " possibly could contain PDF drawing\003  commands";
-    
-    m_lLen       = strlen( pBuffer1 ) + 2 * strlen( pBuffer2 );
-    m_pEncBuffer = static_cast<char*>(malloc( sizeof(char) * m_lLen ));
-
-    memcpy( m_pEncBuffer, pBuffer1, strlen( pBuffer1 ) * sizeof(char) );
-    memcpy( m_pEncBuffer + strlen(pBuffer1), pBuffer2, strlen( pBuffer2 ) );
-    memcpy( m_pEncBuffer + strlen(pBuffer1) + strlen( pBuffer2 ), pBuffer2, strlen( pBuffer2 ) );
-
-    m_protection = PdfEncrypt::ePdfPermissions_Print | 
-        PdfEncrypt::ePdfPermissions_Edit |
-        PdfEncrypt::ePdfPermissions_Copy |
-        PdfEncrypt::ePdfPermissions_EditNotes | 
-        PdfEncrypt::ePdfPermissions_FillAndSign |
-        PdfEncrypt::ePdfPermissions_Accessible |
-        PdfEncrypt::ePdfPermissions_DocAssembly |
-        PdfEncrypt::ePdfPermissions_HighPrint;
-
-}
-
-void EncryptTest::tearDown()
-{
-    free( m_pEncBuffer );
-}
-
-void EncryptTest::testDefault() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo" );
-
-    TestAuthenticate( pEncrypt, 40, 2 );
-    TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testRC4() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection,
-                                                        PdfEncrypt::ePdfEncryptAlgorithm_RC4V1,
-                                                        PdfEncrypt::ePdfKeyLength_40 );
-    
-    TestAuthenticate( pEncrypt, 40, 3 );
-    TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testRC4v2_40() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                         PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, 
-                                                         PdfEncrypt::ePdfKeyLength_40 );
-
-    TestAuthenticate( pEncrypt, 40, 3 );
-    TestEncrypt( pEncrypt );
-
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testRC4v2_56() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                         PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, 
-                                                         PdfEncrypt::ePdfKeyLength_56 );
-
-    TestAuthenticate( pEncrypt, 56, 3 );
-    TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testRC4v2_80() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                         PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, 
-                                                         PdfEncrypt::ePdfKeyLength_80 );
-
-    TestAuthenticate( pEncrypt, 80, 3 );
-    TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testRC4v2_96() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                         PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, 
-                                                         PdfEncrypt::ePdfKeyLength_96 );
-
-    TestAuthenticate( pEncrypt, 96, 3 );
-    TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testRC4v2_128() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                         PdfEncrypt::ePdfEncryptAlgorithm_RC4V2, 
-                                                         PdfEncrypt::ePdfKeyLength_128 );
-
-    TestAuthenticate( pEncrypt, 128, 3 );
-    TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-void EncryptTest::testAESV2() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                         PdfEncrypt::ePdfEncryptAlgorithm_AESV2, 
-                                                         PdfEncrypt::ePdfKeyLength_128 );
-
-    TestAuthenticate( pEncrypt, 128, 4 );
-    // AES decryption is not yet implemented.
-    // Therefore we have to disable this test.
-    // TestEncrypt( pEncrypt );
-
-    delete pEncrypt;
-}
-
-#ifdef PODOFO_HAVE_LIBIDN
-void EncryptTest::testAESV3() 
-{
-    PdfEncrypt* pEncrypt = PdfEncrypt::CreatePdfEncrypt( "user", "podofo", m_protection, 
-                                                        PdfEncrypt::ePdfEncryptAlgorithm_AESV3, 
-                                                        PdfEncrypt::ePdfKeyLength_256 );
-    
-    TestAuthenticate( pEncrypt, 256, 5 );
-    // AES decryption is not yet implemented.
-    // Therefore we have to disable this test.
-    // TestEncrypt( pEncrypt );
-    
-    delete pEncrypt;
-}
-#endif // PODOFO_HAVE_LIBIDN
-
-void EncryptTest::TestAuthenticate( PdfEncrypt* pEncrypt, int keyLength, int rValue ) 
-{
-    PdfString documentId;
-    documentId.SetHexData( "BF37541A9083A51619AD5924ECF156DF", 32 );
-
-    pEncrypt->GenerateEncryptionKey( documentId );
-
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "authenticate using user password",
-                                 pEncrypt->Authenticate(std::string("user"), documentId),
-                                 true );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "authenticate using wrong user password",
-                                 pEncrypt->Authenticate(std::string("wrongpassword"), documentId),
-                                 false );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "authenticate using owner password",
-                                 pEncrypt->Authenticate(std::string("podofo"), documentId),
-                                 true );
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "authenticate using wrong owner password",
-                                 pEncrypt->Authenticate(std::string("wrongpassword"), documentId),
-                                 false );
-}
-
-void EncryptTest::TestEncrypt( PdfEncrypt* pEncrypt ) 
-{
-    pEncrypt->SetCurrentReference( PdfReference( 7, 0 ) );
-    
-    int nOutputLen = pEncrypt->CalculateStreamLength(m_lLen);
-
-    unsigned char *pEncryptedBuffer = new unsigned char[nOutputLen];
-    unsigned char *pDecryptedBuffer = new unsigned char[m_lLen];
-
-    // Encrypt buffer
-    try {
-        pEncrypt->Encrypt( reinterpret_cast<unsigned char*>(m_pEncBuffer), m_lLen, pEncryptedBuffer, nOutputLen );
-    } catch (PdfError &e) {
-        CPPUNIT_FAIL(e.ErrorMessage(e.GetError()));
-    }
-    
-    // Decrypt buffer
-    try {
-        pEncrypt->Decrypt( pEncryptedBuffer, nOutputLen, pDecryptedBuffer, m_lLen );
-    } catch (PdfError &e) {
-        CPPUNIT_FAIL(e.ErrorMessage(e.GetError()));
-    }
-
-    CPPUNIT_ASSERT_EQUAL_MESSAGE( "compare encrypted and decrypted buffers",
-                                  0, memcmp( m_pEncBuffer, pDecryptedBuffer, m_lLen ) );
-
-    delete[] pEncryptedBuffer;
-    delete[] pDecryptedBuffer;
-}
-
-void EncryptTest::testLoadEncrypedFilePdfParser()
-{
-    std::string sFilename = TestUtils::getTempFilename();
-
-    try {
-        CreateEncryptedPdf( sFilename.c_str() );
-    
-        // Try loading with PdfParser
-        PdfVecObjects objects;
-        PdfParser     parser( &objects );
-
-        try {
-            parser.ParseFile( sFilename.c_str(), true );
-
-            // Must throw an exception
-            CPPUNIT_FAIL("Encrypted file not recognized!");
-        } catch( PdfError & e ) {
-            if( e.GetError() != ePdfError_InvalidPassword ) 
-            {
-                CPPUNIT_FAIL("Invalid encryption exception thrown!");
-            }
-        }
-
-        parser.SetPassword( "user" );
-    } catch( PdfError & e ) {
-        e.PrintErrorMsg();
-
-        printf("Removing temp file: %s\n", sFilename.c_str());
-        TestUtils::deleteFile(sFilename.c_str());
-        throw e;
-    }
-
-    printf("Removing temp file: %s\n", sFilename.c_str());
-    TestUtils::deleteFile(sFilename.c_str());
-}
-
-void EncryptTest::testLoadEncrypedFilePdfMemDocument()
-{
-    std::string sFilename = TestUtils::getTempFilename();
-
-    try {
-        CreateEncryptedPdf( sFilename.c_str() );
-    
-        // Try loading with PdfParser
-        PdfMemDocument document;
-        try {
-            document.Load( sFilename.c_str() );
-
-            // Must throw an exception
-            CPPUNIT_FAIL("Encrypted file not recognized!");
-        } catch( PdfError & e ) {
-            if( e.GetError() != ePdfError_InvalidPassword ) 
-            {
-                CPPUNIT_FAIL("Invalid encryption exception thrown!");
-            }
-        }
-        
-        document.SetPassword( "user" );
-
-    } catch( PdfError & e ) {
-        e.PrintErrorMsg();
-
-        printf("Removing temp file: %s\n", sFilename.c_str());
-        TestUtils::deleteFile(sFilename.c_str());
-
-        throw e;
-    }
-
-    printf("Removing temp file: %s\n", sFilename.c_str());
-    TestUtils::deleteFile(sFilename.c_str());
-}
-
-void EncryptTest::CreateEncryptedPdf( const char* pszFilename )
-{
-    PdfMemDocument  writer;
-    PdfPage* pPage = writer.CreatePage( PdfPage::CreateStandardPageSize( ePdfPageSize_A4 ) );
-    PdfPainter painter;
-    painter.SetPage( pPage );
-
-    PdfFont* pFont = writer.CreateFont( "Arial", PdfEncodingFactory::GlobalWinAnsiEncodingInstance(), false );
-    if( !pFont )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    pFont->SetFontSize( 16.0 );
-    painter.SetFont( pFont );
-    painter.DrawText( 100, 100, "Hello World" );
-    painter.FinishPage();
-
-    writer.SetEncrypted( "user", "owner" );
-    writer.Write( pszFilename );
-
-    printf( "Wrote: %s (R=%i)\n", pszFilename, writer.GetEncrypt()->GetRevision() );
-}
-
-void EncryptTest::testEnableAlgorithms()
-{
-    int nDefault = PdfEncrypt::GetEnabledEncryptionAlgorithms();
-
-    // By default every algorithms should be enabled
-    CPPUNIT_ASSERT( PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_RC4V1 ) );
-    CPPUNIT_ASSERT( PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_RC4V2 ) );
-    CPPUNIT_ASSERT( PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_AESV2 ) );
-#ifdef PODOFO_HAVE_LIBIDN
-    CPPUNIT_ASSERT( PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_AESV3 ) );
-#endif // PODOFO_HAVE_LIBIDN
-    CPPUNIT_ASSERT_EQUAL( PdfEncrypt::ePdfEncryptAlgorithm_RC4V1 |
-                          PdfEncrypt::ePdfEncryptAlgorithm_RC4V2 |
-                          PdfEncrypt::ePdfEncryptAlgorithm_AESV2
-#ifdef PODOFO_HAVE_LIBIDN
-                          | PdfEncrypt::ePdfEncryptAlgorithm_AESV3
-#endif // PODOFO_HAVE_LIBIDN
-                                                                   ,
-                          PdfEncrypt::GetEnabledEncryptionAlgorithms() );
-    // Disable AES
-    PdfEncrypt::SetEnabledEncryptionAlgorithms( PdfEncrypt::ePdfEncryptAlgorithm_RC4V1 |
-                                                PdfEncrypt::ePdfEncryptAlgorithm_RC4V2 );
-
-    CPPUNIT_ASSERT( PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_RC4V1 ) );
-    CPPUNIT_ASSERT( PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_RC4V2 ) );
-    CPPUNIT_ASSERT( !PdfEncrypt::IsEncryptionEnabled( PdfEncrypt::ePdfEncryptAlgorithm_AESV2 ) );
-
-    CPPUNIT_ASSERT_EQUAL( PdfEncrypt::ePdfEncryptAlgorithm_RC4V1 |
-                          PdfEncrypt::ePdfEncryptAlgorithm_RC4V2,
-                          PdfEncrypt::GetEnabledEncryptionAlgorithms() );
-
-
-    PdfObject object;
-    object.GetDictionary().AddKey(PdfName("Filter"), PdfName("Standard"));
-    object.GetDictionary().AddKey(PdfName("V"), static_cast<pdf_int64>(4L));
-    object.GetDictionary().AddKey(PdfName("R"), static_cast<pdf_int64>(4L));
-    object.GetDictionary().AddKey(PdfName("P"), static_cast<pdf_int64>(1L));
-    object.GetDictionary().AddKey(PdfName("O"), PdfString(""));
-    object.GetDictionary().AddKey(PdfName("U"), PdfString(""));
-
-    try {
-        (void)PdfEncrypt::CreatePdfEncrypt( &object );
-        CPPUNIT_ASSERT( false );
-    } catch( PdfError & rError ) {
-        CPPUNIT_ASSERT_EQUAL( rError.GetError(), ePdfError_UnsupportedFilter );
-    }
-
-    // Restore default
-    PdfEncrypt::SetEnabledEncryptionAlgorithms( nDefault );
-}
-
-
-                                  /*
-
-
-    PdfMemoryOutputStream mem( lLen );
-    PdfOutputStream* pStream = enc.CreateEncryptionOutputStream( &mem ); 
-    pStream->Write( pBuffer1, strlen( pBuffer1 ) );
-    pStream->Write( pBuffer2, strlen( pBuffer2 ) );
-    pStream->Write( pBuffer2, strlen( pBuffer2 ) );
-    pStream->Close();
-
-    printf("Result: %i \n", memcmp( pEncBuffer, mem.TakeBuffer(), lLen ) );
-
-
-    enc.Encrypt( reinterpret_cast<unsigned char*>(pEncBuffer), lLen );
-    printf("Decrypted buffer: %s\n", pEncBuffer );
-    */
-
--- tools/podofotxtextract/TextExtractor.cpp.orig	2011-12-05 19:52:30.000000000 +0000
+++ tools/podofotxtextract/TextExtractor.cpp.orig	1970-01-01 00:00:00.000000000 +0000
@@ -1,176 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Dominik Seichter                                *
- *   domseichter@web.de                                                    *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
- ***************************************************************************/
-
-#include "TextExtractor.h"
-
-#include <stack>
-
-TextExtractor::TextExtractor()
-{
-
-}
-
-TextExtractor::~TextExtractor()
-{
-}
-
-void TextExtractor::Init( const char* pszInput )
-{
-    if( !pszInput )
-    {
-        PODOFO_RAISE_ERROR( ePdfError_InvalidHandle );
-    }
-
-    PdfMemDocument document( pszInput );
-
-    int nCount = document.GetPageCount();
-    for( int i=0; i<nCount; i++ ) 
-    {
-        PdfPage* pPage = document.GetPage( i );
-        
-        this->ExtractText( &document, pPage );
-    }
-}
-
-void TextExtractor::ExtractText( PdfMemDocument* pDocument, PdfPage* pPage ) 
-{
-    const char*      pszToken = NULL;
-    PdfVariant       var;
-    EPdfContentsType eType;
-
-    PdfContentsTokenizer tokenizer( pPage );
-
-    double dCurPosX     = 0.0;
-    double dCurPosY     = 0.0;
-    double dCurFontSize = 0.0;
-    bool   bTextBlock   = false;
-    PdfFont* pCurFont   = NULL;
-
-    std::stack<PdfVariant> stack;
-
-    while( tokenizer.ReadNext( eType, pszToken, var ) )
-    {
-        if( eType == ePdfContentsType_Keyword )
-        {
-            // support 'l' and 'm' tokens
-            if( strcmp( pszToken, "l" ) == 0 || 
-                strcmp( pszToken, "m" ) == 0 )
-            {
-                dCurPosX = stack.top().GetReal();
-                stack.pop();
-                dCurPosY = stack.top().GetReal();
-                stack.pop();
-            }
-            else if( strcmp( pszToken, "BT" ) == 0 ) 
-            {
-                bTextBlock   = true;     
-                // BT does not reset font
-                // dCurFontSize = 0.0;
-                // pCurFont     = NULL;
-            }
-            else if( strcmp( pszToken, "ET" ) == 0 ) 
-            {
-                if( !bTextBlock ) 
-                    fprintf( stderr, "WARNING: Found ET without BT!\n" );
-            }
-
-            if( bTextBlock ) 
-            {
-                if( strcmp( pszToken, "Tf" ) == 0 ) 
-                {
-                    dCurFontSize = stack.top().GetReal();
-                    stack.pop();
-                    PdfName fontName = stack.top().GetName();
-                    PdfObject* pFont = pPage->GetFromResources( PdfName("Font"), fontName );
-                    if( !pFont ) 
-                    {
-                        PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle, "Cannot create font!" );
-                    }
-
-                    pCurFont = pDocument->GetFont( pFont );
-                    if( !pCurFont ) 
-                    {
-                        fprintf( stderr, "WARNING: Unable to create font for object %i %i R\n",
-                                 pFont->Reference().ObjectNumber(),
-                                 pFont->Reference().GenerationNumber() );
-                    }
-                }
-                else if( strcmp( pszToken, "Tj" ) == 0 ||
-                         strcmp( pszToken, "'" ) == 0 ) 
-                {
-                    AddTextElement( dCurPosX, dCurPosY, pCurFont, stack.top().GetString() );
-                    stack.pop();
-                }
-                else if( strcmp( pszToken, "\"" ) == 0 )
-                {
-                    AddTextElement( dCurPosX, dCurPosY, pCurFont, stack.top().GetString() );
-                    stack.pop();
-                    stack.pop(); // remove char spacing from stack
-                    stack.pop(); // remove word spacing from stack
-                }
-                else if( strcmp( pszToken, "TJ" ) == 0 ) 
-                {
-                    PdfArray array = stack.top().GetArray();
-                    stack.pop();
-                    
-                    for( int i=0; i<static_cast<int>(array.GetSize()); i++ ) 
-                    {
-                        if( array[i].IsString() || array[i].IsHexString() )
-                            AddTextElement( dCurPosX, dCurPosY, pCurFont, array[i].GetString() );
-                    }
-                }
-            }
-        }
-        else if ( eType == ePdfContentsType_Variant )
-        {
-            stack.push( var );
-        }
-        else
-        {
-            // Impossible; type must be keyword or variant
-            PODOFO_RAISE_ERROR( ePdfError_InternalLogic );
-        }
-    }
-}
-
-void TextExtractor::AddTextElement( double dCurPosX, double dCurPosY, 
-		PdfFont* pCurFont, const PdfString & rString )
-{
-    if( !pCurFont ) 
-    {
-        fprintf( stderr, "WARNING: Found text but do not have a current font: %s\n", rString.GetString() );
-        return;
-    }
-
-    if( !pCurFont->GetEncoding() ) 
-    {
-        fprintf( stderr, "WARNING: Found text but do not have a current encoding: %s\n", rString.GetString() );
-        return;
-    }
-
-    // For now just write to console
-    PdfString unicode = pCurFont->GetEncoding()->ConvertToUnicode( rString, pCurFont );
-    const char* pszData = unicode.GetStringUtf8().c_str();
-    while( *pszData ) {
-        //printf("%02x", static_cast<unsigned char>(*pszData) );
-        ++pszData;
-    }
-	printf("(%.3f,%.3f) %s \n", dCurPosX, dCurPosY, unicode.GetStringUtf8().c_str() );
-}
