Hi Jo, Did you try with latest SVN trunk. We had a change there to use GetIndirectKey which should resolve the reference and work for your case.
Cheers,
Dominik
Am Mittwoch 18 August 2010 schrieb Jo Van der Snickt:
> While parsing a PDF document, I'm trying to create a font. The following
> piece of code (similar to what is done in the pdofotxtextract tool):
>
> PdfVariant fontSize = popStack();
> PdfVariant fontName = popStack();
>
> if ( ! fontSize.IsReal() ) return;
> if ( ! fontName.IsName() ) return;
>
> cout << "Font name : " << fontName.GetName().GetName() << endl;
> cout << "Font size : " << fontSize.GetReal() << endl;
>
> PdfObject * fontObjectPtr = m_pdfPagePtr->GetFromResources( PdfName(
> "Font" ), fontName.GetName() );
>
> if ( ! fontObjectPtr )
> {
> cout << "Cannot create font" << endl; return;
> }
>
> cout << "Font successfully created" << endl;
>
>
> Produces the following output:
>
> Font name : R11
> Font size : 24.9976
> Cannot create font
>
>
> To find out why the GetFromResources() call fails, I try the following
> code:
>
> PdfVariant fontSize = popStack();
> PdfVariant fontName = popStack();
>
> if ( ! fontSize.IsReal() ) return;
> if ( ! fontName.IsName() ) return;
>
> cout << "Font name : " << fontName.GetName().GetName() << endl;
> cout << "Font size : " << fontSize.GetReal() << endl;
>
> PdfObject * typePtr =
> m_pdfPagePtr->GetResources()->GetDictionary().GetKey( PdfName( "Font" ) );
>
> if ( ! typePtr->IsDictionary() )
> {
> cout << "Type is " << typePtr->GetDataTypeString() << endl;
> return;
> }
>
>
> And this outputs:
>
> Font name : R11
> Font size : 24.9976
> Type is Reference
>
>
> Since this should be a Dictionary and not a Reference, the
> GetFromResources() call fails.
>
>
> What am I doing wrong?
>
>
>
>
> This e-mail and any attachments thereto may contain information which is
> confidential and/or protected by intellectual property rights and are
> intended for the sole use of the recipient(s) named above. Any use of the
> information contained herein (including, but not limited to, total or
> partial reproduction, communication or distribution in any form) by
> persons other then the designated recipient(s) is prohibited. If you have
> received this e-mail in error, please notify the sender either by
> telephone or by e-mail and delete the material from any computer. Thank
> you for your cooperation.
>
> Dilys bvba
> Nieuwe Stationsstraat 23
> 9160 Lokeren
>
> tel +32 9 356 97 13
> fax +32 9 353 90 11
>
> mailto:[email protected]
> http://www.dilys.be
>
>
>
> ---------------------------------------------------------------------------
> --- This SF.net email is sponsored by
>
> Make an app they can't live without
> Enter the BlackBerry Developer Challenge
> http://p.sf.net/sfu/RIM-dev2dev
> _______________________________________________
> Podofo-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/podofo-users
>
--
**********************************************************************
Dominik Seichter - [email protected]
KRename - http://www.krename.net - Powerful batch renamer for KDE
KBarcode - http://www.kbarcode.net - Barcode and label printing
PoDoFo - http://podofo.sf.net - PDF generation and parsing library
SchafKopf - http://schafkopf.berlios.de - Schafkopf, a card game, for KDE
Alan - http://alan.sf.net - A Turing Machine in Java
**********************************************************************
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ Podofo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/podofo-users
