Hi Dominik,
Thanks for the quick response! Yes, the updated patch still works as 
expected—thanks for fixing it up.

Another issue I’ve run into is full failure of parsing when objects are 
referred to that don’t exist. Often this is due to XRef stream entries that 
point to non-existent object streams or non-existent indices within those 
streams.

There’s a bool member `m_bIgnoreBrokenObjects` in `PdfParser`, and that member 
is exposed through `SetIgnoreBrokenObjects()`, but it’s set to false in 
`Init()`, which is called by `Clear()`, which is called at the top of 
`ParseFile()`, so user-defined values are overwritten. Following the pattern 
used for the `m_bLoadOnDemand` flag, I’ve modified the `ParseFile()` functions 
to allow the user to pass in an optional `bIgnoreBrokenObjects` parameter 
(default false) to get around this issue. I’ve attached a patch to show what 
this looks like, and which also allows passing the `bIgnoreBrokenObjects` flag 
to `PdfMemDocument` constructors and `Load()` functions. It also checks the 
flag when reading objects from a stream.

Is this the right way to go about this, or is there a better way to allow 
graceful failure and continuation of parsing?

Thanks,
John

From: Dominik Seichter <domseich...@googlemail.com>
Sent: Saturday, February 9, 2019 3:47 AM
To: John Senneker <john.senne...@arup.com>
Cc: podofo-users@lists.sourceforge.net
Subject: [External] Re: [Podofo-users] Implementation of PNG Paeth filter

Hi John,

Thanks for your patch. When initially applied, your patch is causing this 
compilation error for me:

/home/dominik/Desktop/Programming/podofo/podofo/src/base/PdfFiltersPrivate.cpp: 
In member function ‘void PoDoFo::PdfPredictorDecoder::Decode(const char*, 
PoDoFo::pdf_long, PoDoFo
::PdfOutputStream*)’:
/home/dominik/Desktop/Programming/podofo/podofo/src/base/PdfFiltersPrivate.cpp:197:58:
 error: expected primary-expression before ‘unsigned’
                        int a = nLeftByteIndex < 0 ? 0 : unsigned char( 
m_pPrev[nLeftByteIndex] );
                                                         ^~~~~~~~
/home/dominik/Desktop/Programming/podofo/podofo/src/base/PdfFiltersPrivate.cpp:198:33:
 error: expected primary-expression before ‘unsigned’
                        int b = unsigned char( m_pPrev[m_nCurRowIndex] );
                                ^~~~~~~~
/home/dominik/Desktop/Programming/podofo/podofo/src/base/PdfFiltersPrivate.cpp:201:58:
 error: expected primary-expression before ‘unsigned’
                        int c = nLeftByteIndex < 0 ? 0 : unsigned char( 
m_pUpperLeftPixelComponents[nCurrComponentIndex] );
                                                         ^~~~~~~~
src/CMakeFiles/podofo_shared.dir/build.make:398: die Regel für Ziel 
„src/CMakeFiles/podofo_shared.dir/base/PdfFiltersPrivate.cpp.o“ scheiterte
make[2]: *** [src/CMakeFiles/podofo_shared.dir/base/PdfFiltersPrivate.cpp.o] 
Fehler 1
CMakeFiles/Makefile2:117: die Regel für Ziel 
„src/CMakeFiles/podofo_shared.dir/all“ scheiterte
make[1]: *** [src/CMakeFiles/podofo_shared.dir/all] Fehler 2
Makefile:127: die Regel für Ziel „all“ scheiterte
I fixed this by replacing unsigned char(...) with static_cast<unsigned 
char>(...) and committed the patch in revision 1965. Could you please verify if 
this is still as intended?

Thanks,
 Dominik


On Fri, Feb 8, 2019 at 7:39 PM John Senneker 
<john.senne...@arup.com<mailto:john.senne...@arup.com>> wrote:
Hi,
Please find attached a patch containing an implementation of the Paeth filter, 
which is the only PNG filter not currently implemented by PoDoFo. Let me know 
if there’s anything that could be improved!

Thanks,
John Senneker
 ____________________________________________________________
Electronic mail messages entering and leaving Arup business systems are scanned 
for viruses and acceptability of content.
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net<mailto:Podofo-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/podofo-users<https://secure-web.cisco.com/1tTp67yIZMaEgPAp06wiJHyJgeeRdFdoocG6cFNt1oLX9c3nbF3P8VM_190bydqr-WVHT2SSkrGixBju-tK1urMxQ6v10m6QDoXNTNBfSU7n5z3fAHL1q_x2ucf1Ha6RhvZowwm7GTM2z6ae94Qn8TJ8BHBJRRIg43LGNn8HjGJrZxz_-ZtXISZJXHeuzwF1dTXHnOJrvIXvv6EcILwZQGBq6e7ST0SlweFl6con-0di_Y7WN_MSZfRcH4uht5BmHUt6Q2ilCLV8J3CN9nJ5mI6swwe3LAMx8jd0B1Qbei7pGt3MY0RYwW1RpWcUIf_umHWoj1YY15aes2Zj_FFxm7w/https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fpodofo-users>

Attachment: PoDoFo-ignore-broken-objects.patch
Description: PoDoFo-ignore-broken-objects.patch

_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to