import textproc/podofo, ok benoit@

PoDoFo is a free portable C++ library which includes classes to parse a PDF
file and modify its contents into memory. The changes can be written back to
disk easily. PoDoFo is designed to avoid loading large PDF objects into
memory until they are required and can write large streams immediately to
disk, so it is possible to manipulate quite large files with it.

Besides PDF parsing and writing PoDoFo includes also very simple classes
to create your own PDF files.

PoDoFo is primarily useful for applications that wish to do lower level
manipulation of PDF, such as extracting content or merging files. It's also
useful if your application has specific requirements for its PDF output that
more general output-oriented libraries like Cairo cannot satisfy.

Simple tools tuild around the PoDoFo library are also included. They are
primarily examples on how to use the PoDoFo library in your own projects,
but also offer some features for working with PDF files.
This commit is contained in:
sthen 2014-04-06 11:31:21 +00:00
parent 26d793217c
commit 75f1662441
7 changed files with 292 additions and 0 deletions

55
textproc/podofo/Makefile Normal file
View File

@ -0,0 +1,55 @@
# $OpenBSD: Makefile,v 1.1.1.1 2014/04/06 11:31:21 sthen Exp $
COMMENT= library and tools to modify and parse PDF documents
DISTNAME= podofo-0.9.2
SHARED_LIBS += podofo 0.0 # 0.9
CATEGORIES= textproc
HOMEPAGE= http://podofo.sourceforge.net/
MAINTAINER= Stuart Henderson <sthen@openbsd.org>
# GPLv2+ (tools) LGPLv2+ (lib)
PERMIT_PACKAGE_CDROM= Yes
WANTLIB += c crypto fontconfig freetype idn jpeg m png pthread
WANTLIB += stdc++ tiff z
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=podofo/}
MODULES= devel/cmake
LIB_DEPENDS= devel/libidn \
graphics/jpeg \
graphics/png \
graphics/tiff
CONFIGURE_ARGS+= -DCMAKE_INCLUDE_PATH=${X11BASE}/include \
-DCMAKE_LIBRARY_PATH=${X11BASE}/lib \
-DFREETYPE_INCLUDE_DIR=${X11BASE}/include/freetype2 \
-DPODOFO_BUILD_STATIC=True
post-extract:
rm ${WRKSRC}/cmake/modules/FindZLIB.cmake
NO_TEST= Yes
# there are various cppunit-based tests (which must be installed during
# configure), podofo-test is easy to run, but there's no framework to
# automatically run the others.
#
#BUILD_DEPENDS= devel/cppunit
#do-test:
# ${WRKBUILD}/test/unit/podofo-test
.include <bsd.port.arch.mk>
.if ${NO_SHARED_LIBS:L} == "yes"
CONFIGURE_ARGS+= -DPODOFO_BUILD_SHARED=False
.else
CONFIGURE_ARGS+= -DPODOFO_BUILD_SHARED=True
.endif
.include <bsd.port.mk>

2
textproc/podofo/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (podofo-0.9.2.tar.gz) = RlGRYYxX2prpIw55GeGYWiQt3H0QRc/bb7BmFA7Qo/M=
SIZE (podofo-0.9.2.tar.gz) = 1092131

View File

@ -0,0 +1,20 @@
$OpenBSD: patch-CMakeLists_txt,v 1.1.1.1 2014/04/06 11:31:21 sthen Exp $
--- CMakeLists.txt.orig Wed Dec 12 22:55:46 2012
+++ CMakeLists.txt Mon Mar 31 22:57:32 2014
@@ -282,7 +282,6 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
-Wswitch-enum
-Wcast-qual
-Wwrite-strings
- -Wredundant-decls
-Wreorder
#-Wold-style-cast
)
@@ -505,7 +504,7 @@ SET(PODOFO_LIB
#
# Setup directories we will need
#
-SET(MANDIR "share/man/")
+SET(MANDIR "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

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-src_base_PdfString_cpp,v 1.1.1.1 2014/04/06 11:31:21 sthen Exp $
For some reason, alloca() doesn't seem to be working from C++ on OpenBSD,
returning a linker error, so convert to malloc() instead.
--- src/base/PdfString.cpp.orig Mon Mar 31 22:47:08 2014
+++ src/base/PdfString.cpp Mon Mar 31 22:50:17 2014
@@ -530,7 +530,11 @@ void PdfString::InitFromUtf8( const pdf_utf8* pszStrin
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));
+ pdf_utf16be *pBuffer = static_cast<pdf_utf16be *>(malloc(lBufLen));
+ if( !pBuffer )
+ {
+ PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
+ }
lBufLen = PdfString::ConvertUTF8toUTF16( pszStringUtf8, lLen, pBuffer, lBufLen );
@@ -539,6 +543,7 @@ void PdfString::InitFromUtf8( const pdf_utf8* pszStrin
memcpy( m_buffer.GetBuffer(), reinterpret_cast<const char*>(pBuffer), lBufLen );
m_buffer.GetBuffer()[lBufLen] = '\0';
m_buffer.GetBuffer()[lBufLen+1] = '\0';
+ free(pBuffer);
}
void PdfString::InitUtf8()

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-src_base_PdfXRefStream_cpp,v 1.1.1.1 2014/04/06 11:31:21 sthen Exp $
For some reason, alloca() doesn't seem to be working from C++ on OpenBSD,
returning a linker error, so convert to malloc() instead.
--- src/base/PdfXRefStream.cpp.orig Mon Mar 31 22:47:08 2014
+++ src/base/PdfXRefStream.cpp Mon Mar 31 22:51:31 2014
@@ -64,7 +64,11 @@ void PdfXRefStream::WriteSubSection( PdfOutputDevice*,
void PdfXRefStream::WriteXRefEntry( PdfOutputDevice*, pdf_uint64 offset, pdf_gennum generation,
char cMode, pdf_objnum objectNumber )
{
- char * buffer = reinterpret_cast<char*>(alloca(m_bufferLen));
+ char * buffer = reinterpret_cast<char*>(malloc(m_bufferLen));
+ if( !buffer )
+ {
+ PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
+ }
if( cMode == 'n' && objectNumber == m_pObject->Reference().ObjectNumber() )
m_offset = offset;
@@ -76,6 +80,7 @@ void PdfXRefStream::WriteXRefEntry( PdfOutputDevice*,
memcpy( &buffer[1], reinterpret_cast<const char*>(&offset_be), sizeof(pdf_uint64) );
m_pObject->GetStream()->Append( buffer, m_bufferLen );
+ free(buffer);
}
void PdfXRefStream::EndWrite( PdfOutputDevice* pDevice )

17
textproc/podofo/pkg/DESCR Normal file
View File

@ -0,0 +1,17 @@
PoDoFo is a free portable C++ library which includes classes to parse a PDF
file and modify its contents into memory. The changes can be written back to
disk easily. PoDoFo is designed to avoid loading large PDF objects into
memory until they are required and can write large streams immediately to
disk, so it is possible to manipulate quite large files with it.
Besides PDF parsing and writing PoDoFo includes also very simple classes
to create your own PDF files.
PoDoFo is primarily useful for applications that wish to do lower level
manipulation of PDF, such as extracting content or merging files. It's also
useful if your application has specific requirements for its PDF output that
more general output-oriented libraries like Cairo cannot satisfy.
Simple tools tuild around the PoDoFo library are also included. They are
primarily examples on how to use the PoDoFo library in your own projects,
but also offer some features for working with PDF files.

142
textproc/podofo/pkg/PLIST Normal file
View File

@ -0,0 +1,142 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2014/04/06 11:31:21 sthen Exp $
@bin bin/podofobox
@bin bin/podofocolor
@bin bin/podofocountpages
@bin bin/podofocrop
@bin bin/podofoencrypt
@bin bin/podofogc
@bin bin/podofoimg2pdf
@bin bin/podofoimgextract
@bin bin/podofoimpose
@bin bin/podofoincrementalupdates
@bin bin/podofomerge
@bin bin/podofopages
@bin bin/podofopdfinfo
@bin bin/podofotxt2pdf
@bin bin/podofotxtextract
@bin bin/podofouncompress
@bin bin/podofoxmp
include/podofo/
include/podofo/base/
include/podofo/base/Pdf3rdPtyForwardDecl.h
include/podofo/base/PdfArray.h
include/podofo/base/PdfCanvas.h
include/podofo/base/PdfColor.h
include/podofo/base/PdfCompilerCompat.h
include/podofo/base/PdfCompilerCompatPrivate.h
include/podofo/base/PdfContentsTokenizer.h
include/podofo/base/PdfData.h
include/podofo/base/PdfDataType.h
include/podofo/base/PdfDate.h
include/podofo/base/PdfDefines.h
include/podofo/base/PdfDefinesPrivate.h
include/podofo/base/PdfDictionary.h
include/podofo/base/PdfEncoding.h
include/podofo/base/PdfEncodingFactory.h
include/podofo/base/PdfEncrypt.h
include/podofo/base/PdfError.h
include/podofo/base/PdfFileStream.h
include/podofo/base/PdfFilter.h
include/podofo/base/PdfFiltersPrivate.h
include/podofo/base/PdfImmediateWriter.h
include/podofo/base/PdfInputDevice.h
include/podofo/base/PdfInputStream.h
include/podofo/base/PdfLocale.h
include/podofo/base/PdfMemStream.h
include/podofo/base/PdfMemoryManagement.h
include/podofo/base/PdfName.h
include/podofo/base/PdfObject.h
include/podofo/base/PdfObjectStreamParserObject.h
include/podofo/base/PdfOutputDevice.h
include/podofo/base/PdfOutputStream.h
include/podofo/base/PdfParser.h
include/podofo/base/PdfParserObject.h
include/podofo/base/PdfRect.h
include/podofo/base/PdfRefCountedBuffer.h
include/podofo/base/PdfRefCountedInputDevice.h
include/podofo/base/PdfReference.h
include/podofo/base/PdfStream.h
include/podofo/base/PdfString.h
include/podofo/base/PdfTokenizer.h
include/podofo/base/PdfVariant.h
include/podofo/base/PdfVecObjects.h
include/podofo/base/PdfVersion.h
include/podofo/base/PdfWriter.h
include/podofo/base/PdfXRef.h
include/podofo/base/PdfXRefStream.h
include/podofo/base/PdfXRefStreamParserObject.h
include/podofo/base/podofo_config.h
include/podofo/base/podofoapi.h
include/podofo/base/util/
include/podofo/base/util/PdfMutex.h
include/podofo/base/util/PdfMutexImpl_noop.h
include/podofo/base/util/PdfMutexImpl_pthread.h
include/podofo/base/util/PdfMutexImpl_win32.h
include/podofo/base/util/PdfMutexWrapper.h
include/podofo/doc/
include/podofo/doc/PdfAcroForm.h
include/podofo/doc/PdfAction.h
include/podofo/doc/PdfAnnotation.h
include/podofo/doc/PdfCMapEncoding.h
include/podofo/doc/PdfContents.h
include/podofo/doc/PdfDestination.h
include/podofo/doc/PdfDifferenceEncoding.h
include/podofo/doc/PdfDocument.h
include/podofo/doc/PdfElement.h
include/podofo/doc/PdfEncodingObjectFactory.h
include/podofo/doc/PdfExtGState.h
include/podofo/doc/PdfField.h
include/podofo/doc/PdfFileSpec.h
include/podofo/doc/PdfFont.h
include/podofo/doc/PdfFontCID.h
include/podofo/doc/PdfFontCache.h
include/podofo/doc/PdfFontConfigWrapper.h
include/podofo/doc/PdfFontFactory.h
include/podofo/doc/PdfFontFactoryBase14Data.h
include/podofo/doc/PdfFontMetrics.h
include/podofo/doc/PdfFontMetricsBase14.h
include/podofo/doc/PdfFontMetricsFreetype.h
include/podofo/doc/PdfFontMetricsObject.h
include/podofo/doc/PdfFontSimple.h
include/podofo/doc/PdfFontTTFSubset.h
include/podofo/doc/PdfFontTrueType.h
include/podofo/doc/PdfFontType1.h
include/podofo/doc/PdfFontType1Base14.h
include/podofo/doc/PdfFunction.h
include/podofo/doc/PdfHintStream.h
include/podofo/doc/PdfIdentityEncoding.h
include/podofo/doc/PdfImage.h
include/podofo/doc/PdfInfo.h
include/podofo/doc/PdfMemDocument.h
include/podofo/doc/PdfNamesTree.h
include/podofo/doc/PdfOutlines.h
include/podofo/doc/PdfPage.h
include/podofo/doc/PdfPagesTree.h
include/podofo/doc/PdfPagesTreeCache.h
include/podofo/doc/PdfPainter.h
include/podofo/doc/PdfPainterMM.h
include/podofo/doc/PdfShadingPattern.h
include/podofo/doc/PdfSignOutputDevice.h
include/podofo/doc/PdfSignatureField.h
include/podofo/doc/PdfStreamedDocument.h
include/podofo/doc/PdfTable.h
include/podofo/doc/PdfXObject.h
include/podofo/podofo-base.h
include/podofo/podofo.h
lib/libpodofo.a
@lib lib/libpodofo.so.${LIBpodofo_VERSION}
@man man/man1/podofobox.1
@man man/man1/podofocountpages.1
@man man/man1/podofocrop.1
@man man/man1/podofoencrypt.1
@man man/man1/podofoimg2pdf.1
@man man/man1/podofoimgextract.1
@man man/man1/podofoimpose.1
@man man/man1/podofoincrementalupdates.1
@man man/man1/podofomerge.1
@man man/man1/podofopages.1
@man man/man1/podofopdfinfo.1
@man man/man1/podofotxt2pdf.1
@man man/man1/podofotxtextract.1
@man man/man1/podofouncompress.1
@man man/man1/podofoxmp.1