Hi all,
before digging into the source code I'd prefer to have a steer from
somebody who has more experience than me with the library.
I have a small document which uses in its stream a font named '/F2' but
such font can't be looked up by the attached code, which simply
compiles a main which takes two parameters: doc file and font name.
./main test.pdf F1
It won't be able to look the font up even if it exists as the line
PdfFont * font = document.GetFont( pdfObject );
Return a pointer to NULL.
I inspected the PDF with i7j and I can find the font under the page
'/Resources' -> '/Font' dictionary therefore it is there indeed, am I
using the library incorrectly or doing anything silly ?
If the patch fixes the problem I am more than happy to test it.I had
been unable to send the pdf as an attachment, it is fairly small (300
KB) but the moderation system won't let it through nonetheless.
Thanks,
Pietro.
#include <iostream>
#include <podofo/podofo.h>
#include <iomanip>
using namespace std;
using namespace PoDoFo;
int main(int argn, char **argv)
{
// Doc, fontName
try {
PdfMemDocument document;
document.Load( argv[1] );
PdfPage * page = document.GetPage( 0 );
PdfName fontName( argv[2] );
// Initialize function for string 'rendering'
PdfObject * pdfObject = page->GetFromResources( PdfName( "Font" ) ,
fontName);
if( !pdfObject )
{
cerr << "No font name '"
<< fontName.GetName()
<< "' found";
exit( 255 );
}
PdfFont * font = document.GetFont( pdfObject );
if ( !font )
{
cerr << "Could not look up font " << fontName.GetName() << endl;
exit( 255 );
}
cerr << "Font found " << font->GetIdentifier().GetName() << endl;
} catch( PdfError & e ) {
cerr << e.GetError() << std::endl;
e.PrintErrorMsg();
}
return 0;
}
_______________________________________________
Podofo-users mailing list
Podofo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/podofo-users