Getting Started

This section will describe how to write a simplest "Hello world" program with libpdfdoc.

Let's start with the following code:

pdf::Doc *doc = pdf::CreateDoc( ) ;
pdf::Page *p = doc->AppendPage( ) ;
pdf::Font *f = doc->CreateSimpleFont( "Arial" ) ;

pdf::PageContent *c = p->GetContent( ) ;
pdf::Text *t = c->AddText( 12.0, f ) ;
t->AddLine( 100, 100, L"Hello world!" ) ;

doc->Write( "helloworld.pdf" ) ;
delete doc ;

The first line creates a PDF document. The CreateDoc() function will create a Doc object, which represents a PDF document. The Doc object provides functions to access the document content. It has member functions to get the individual pages of the document.

The second line call pdf::Doc::AppendPage() to insert a new page at the end of the document.


Hosted by SourceForge Logo