Re: [Podofo-users] Parse error on Chromium generated PDFs

2018-01-16 Thread Matthew Brincke
Hello zyx, hello all,

> zyx  has written on 14 January 2018 at 15:42:
> 
> 
> On Wed, 2017-12-06 at 18:34 +0100, le...@free.fr wrote:
> > After some digging, Chromium / Skia do not store annotations as
> > references, but directly as dictionnary under /Annots.
> > Here is a simple patch which solves it but incorrect : the allocated
> > PdfObject is not deleted afterwards.
> 
>   Hi,
> thanks for the notice and the patch. You are right it is not complete,
> the pAnnot is also leaking and couple more issues had been there.
> I extended your change in revision 1867:
> https://sourceforge.net/p/podofo/code/1867

in that revision in src/doc/PdfPage.cpp:380 (i.e. line 380) there is
a typo: it should be pItem instead of pObj (as in line 384 the index
pItem is used for storing, so it should be used for querying also).
The object pObj is an array, you didn't want that as a map key, right?

An issue is also that you replaced the construct (*iterator).member
by iterator->member which is AFAIK non-standard, so (possibly at least)
non-portable. This is because iterator types don't have to be pointers
and aren't (otherwise) required to have an operator-> but only (see [1])
operator*() const for dereferencing the iterator. So please change it
back or please give me a technical reason why that isn't practical
for you.

> 
>   Bye,
>   zyx
> 

[1] http://en.cppreference.com/w/cpp/concept/Iterator
Example implementation in http://en.cppreference.com/w/cpp/iterator/iterator

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


Re: [Podofo-users] Fix for the "could avoid useless dependency" Debian build warning

2018-01-16 Thread Matthew Brincke
Hello all, hello Mattia, hello zyx,

> Mattia Rizzolo has written on 14 January 2018 at 13:34:
> 
> 
> On Sun, Jan 14, 2018 at 01:18:58PM +0100, zyx wrote:
> > could you provide the exact warning you are referring to and in which
> > stage (some context) it had been written, please? I do not see/did not
> > notice any such warning on Fedora (maybe I overlooked it, or I do not
... snip ...
> 
> It's actually a message not coming from the podofo build system, but
> from dpkg-shlibdeps, i.e. the program that during a package build
> inspects all the ELF binaries to detect what libraries they are linked
> to and generate the list of dependencies.
... snip ...
> 
> This is caused by overlinking, and e.g. using -Wl,--as-needed avoids it
> (but better taking care of it like this patch is trying to do).
> 
> > While the change itself looks fine, I wasn't able to build PoDoFo on
> > Fedora with it, it failed with this error:
> > 
> >  Scanning dependencies of target podofosign
> >  [ 98%] Building CXX object 
> > tools/podofosign/CMakeFiles/podofosign.dir/podofosign.cpp.o
> >  [ 98%] Linking CXX executable podofosign
> >  CMakeFiles/podofosign.dir/podofosign.cpp.o: In function `main':
> > .../tools/podofosign/podofosign.cpp:879: undefined reference to 
> > `OPENSSL_init_ssl'
> >  collect2: error: ld returned 1 exit status
> 
> I'll let the OP take care of this error :)

I don't have Fedora, but I've nevertheless thought of some changes
to my patch (the new version is attached) to fix the build error:
Added LIBCRYPTO_LDFLAGS and OPENSSL_LIBRARIES to the podofosign link.
So please test it on your distro (already tested with sbuild's Debian
sid, zyx, please test with your Fedora, I hope it'll work there).
If it works, please first solve the issue my next e-mail will be about
(and commit), then please commit this.

Best regards, mabri

> 
> -- 
> regards,
>  Mattia Rizzolo
> 
> GPG Key: 66AE 2B4A FCCF 3F52 DA18 4D18 4B04 3FCD B944 4540
> more about me: https://mapreri.org
> Launchpad user: https://launchpad.net/~mapreri
> Debian QA page: https://qa.debian.org/developer.php?login=mattia--- libpodofo-0.9.5.orig/CMakeLists.txt
+++ libpodofo-0.9.5/CMakeLists.txt
@@ -509,10 +509,16 @@ IF(FONTCONFIG_FOUND AND WANT_FONTCONFIG)
   INCLUDE_DIRECTORIES(${FONTCONFIG_INCLUDE_DIR})
 ENDIF(FONTCONFIG_FOUND AND WANT_FONTCONFIG)
 
-SET(PODOFO_LIB
-podofo
-${PODOFO_LIB_DEPENDS}
-)
+IF(WIN32 OR PODOFO_BUILD_STATIC)
+  SET(PODOFO_LIB
+  podofo
+  ${PODOFO_LIB_DEPENDS}
+  )
+ELSE(WIN32 OR PODOFO_BUILD_STATIC)
+  SET(PODOFO_LIB podofo
+  ${stlport_libraries_if_use_stlport}
+  )
+ENDIF(WIN32 OR PODOFO_BUILD_STATIC)
 
 #
 # Setup directories we will need
--- libpodofo-0.9.5.orig/tools/podofosign/CMakeLists.txt
+++ libpodofo-0.9.5/tools/podofosign/CMakeLists.txt
@@ -1,7 +1,16 @@
 ADD_EXECUTABLE(podofosign podofosign.cpp)
 
 TARGET_INCLUDE_DIRECTORIES(podofosign PUBLIC ${LIBCRYPTO_INCLUDE_DIR})
-TARGET_LINK_LIBRARIES(podofosign ${PODOFO_LIB})
+
+SET(podofosign_extra_libs
+${LIBCRYPTO_LDFLAGS}
+${LIBCRYPTO_LIBRARIES}
+${OPENSSL_LIBRARIES}
+)
+TARGET_LINK_LIBRARIES(podofosign
+  ${podofosign_extra_libs}
+  ${PODOFO_LIB}
+)
 SET_TARGET_PROPERTIES(podofosign PROPERTIES COMPILE_FLAGS "${PODOFO_CFLAGS}")
 ADD_DEPENDENCIES(podofosign ${PODOFO_DEPEND_TARGET})
 INSTALL(TARGETS podofosign
--
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


Re: [Podofo-users] Difference between PdfObject::GetReference() and PdfObject::Reference()

2018-01-16 Thread Georg Funk
Thanks Dimitry,
for this hint!

Regards,
Georg

Am 13.01.2018 um 13:25 schrieb Dmitry Salychev 
>:

Hi, Georg.

I'm not a developer of PoDoFo and don't know any details lying deep there.
You may just take a look at the src/base/PdfObject.h and
src/base/PdfVariant.h to understand the difference between these two
functions:

inline const PdfReference & Reference() const;
inline const PdfReference & GetReference() const;

and their implementations:

const PdfReference & PdfObject::Reference() const
{
return m_reference;
}

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);
}

Personally, I didn't have a need to find object by its object and generation
numbers, but I had to obtain 'em from an existing one. There is a chance that
this piece of code to get a specific XObject by its name will be useful:

PdfObject *xobj;
int nobj, ngen;

xobj = get_xobject(_name, (PdfCanvas *)page);
/* Is object a reference? */
if (xobj->IsReference())
xobj = doc->GetObjects().GetObject(xobj->GetReference());
ngen = xobj->Reference().GenerationNumber();
nobj = xobj->Reference().ObjectNumber();
/* ... */

static PdfObject *get_xobject(PdfName *xobjname, PdfCanvas *pPage)
{
PdfObject *pResources = pPage->GetResources();
PdfObject *xobj_dict;

if (pResources != NULL &&
pResources->GetDictionary().HasKey(PdfName("XObject"))) {
xobj_dict = pResources->GetIndirectKey(PdfName("XObject"));
if (xobj_dict != NULL && xobj_dict->IsDictionary()) {
return xobj_dict->GetIndirectKey(*xobjname);
}
}
return NULL;
}


Regards,

- Dmitry

On Fri, Jan 12, 2018 at 10:35 PM, Georg Funk 
> wrote:
Dear podofo-developers,

could you please describe the difference between PdfObject::GetReference() and 
PdfObject::Reference()?
I need a way to access PdfObjects from within a PfVecObjects vector by their 
object and generation number. Further I need a function to follow indirect 
references of an object.
Can I use the above mentioned methods for these purposes?

Thank you in advance!

Regards,
Georg
--
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

--
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

--
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


Re: [Podofo-users] Info Strings can be references

2018-01-16 Thread zyx
On Tue, 2018-01-16 at 18:23 +0100, Florian Hänel wrote:
> I stumbled across a PDF (Producer: Mac OS X 10.13.1 Quartz
> PDFContext,
> Creator: Keynote) that has all strings in \Info as references.

Hi,
would you mind to share some simple tiny PDF file as a reproducer,
please?

> If you rely on e.g. GetProducer() returning even just an empty
> string, you will observe a crash.

Is it a real crash, or a PdfError exception thrown, not caught by
anything else in the call stack? I'd guess it's the later.

Thanks and bye,
zyx

--
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


Re: [Podofo-users] Difference between PdfObject::GetReference() and PdfObject::Reference()

2018-01-16 Thread Dmitry Salychev
Georg,

no problem (: It's nice that this code helped.

Regards,

- Dmitry
--
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