Hello all,
the attached patch is for changing the behaviour to what an
unsupported filter should do: throw an exception with code
ePdfError_UnsupportedFilter instead of leaving the output
stream empty, and also for cleaning up the code of the filter
for release (e.g. removing all what's #ifdef'd out). After
the release, feel free to revert it, but please accept it
first (after my other patch), before the next release candidate.
The patch is made to the Debian package, but should apply to
trunk as well with just a little offset.
I have (only) build-tested it with sbuild into a Debian sid
(up-to-date) chroot, I couldn't run-test it for lack of a
suitable input file or tool to generate one (netpbm is so
old&buggy even in Debian sid) ;-(.
Best regards, mabri
> Matthew Brincke <ma...@mailbox.org> has written on 16 November 2017 at 16:59:
>
>
> Hello Luke, hello all,
>
> > Luke Kennedy <l...@avia-sys.com> has written on 9 August 2017 at 13:10:
> >
> > Hi all,
> >
> > As mentioned in further details here
> > https://stackoverflow.com/questions/45548467/empty-decoded-stream-of-ccittfaxdecode-decoder-using-podofo
> >
> > … we’ve hit an issue with CCITTFaxDecode for raster extraction.
> >
> > The stream is correctly extracted from the PDF file however the call
> > to GetFilteredCopy() does not appear to have applied the CCITTFaxDecode
> > filter
> > and returns length of zero:
> >
> > Is this a known issue?
> >
>
> in a way, yes (and sorry for answering at least ;-) a quarter too late), the
> filter is unimplemented, the only code doing anything is in a #ifdef checking
> for DS_CCITT_DEVELOPMENT_CODE (DS is AFAICS standing for Dominik Seichter, the
> project leader). The encoding side throws ePdfError_UnsupportedFilter.
>
> > Thanks,
> >
> > Luke
>
> Best regards, mabri
>
> ------------------------------------------------------------------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Podofo-users mailing list
> Podofo-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/podofo-users
--- libpodofo-0.9.5.orig/src/base/PdfFiltersPrivate.cpp
+++ libpodofo-0.9.5/src/base/PdfFiltersPrivate.cpp
@@ -1149,53 +1149,6 @@ jpeg_memory_src (j_decompress_ptr cinfo,
#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 )
{
@@ -1220,80 +1173,19 @@ 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
-
-
+void PdfCCITTFilter::BeginDecodeImpl( const PdfDictionary* )
+{
+ PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
}
-#ifndef _MSC_VER
-#pragma GCC diagnostic pop
-#endif
void PdfCCITTFilter::DecodeBlockImpl( const char*, pdf_long )
{
-
+ PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
}
void PdfCCITTFilter::EndDecodeImpl()
{
+ PODOFO_RAISE_ERROR( ePdfError_UnsupportedFilter );
}
-#endif // PODOFO_HAVE_TIFF_LIB
-
-
};
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users