pdf::Doc Class Reference

Base class for documents. More...

#include <Doc.hh>

List of all members.

Public Member Functions

File I/O functions

File input/output functions



virtual void Read (const std::string &filename)=0
 Read a PDF document from a file.
virtual void Write (const std::string &filename) const =0
 Write the PDF document to a file.
Page Accessing Functions

These functions allow adding and remove pages from the document.



virtual PageAppendPage ()=0
 Add a page to the document.
virtual PageAddPage (std::size_t index)=0
 Add a page to the document.
virtual std::size_t PageCount () const =0
 Get the number of pages in the document.
virtual PageGetPage (std::size_t index)=0
 Get the page by its index.
Resources Functions

These functions provide interfaces to accessing the resources of the document.



virtual FontCreateSimpleFont (const std::string &name)=0
 Create a font to be used with the document.

Detailed Description

This class represents a PDF document. It is an abstract class that all functions are pure virtual. It has functions to read and write the PDF document from and to a file, as well as functions to manipulate the structure of the document like inserting or removing a page.


Member Function Documentation

virtual Page* pdf::Doc::AddPage ( std::size_t  index  )  [pure virtual]

It will add a page to the specified index.

Parameters:
index the index of the old page. If it is too large (i.e. larger than the number of pages), the page will be added at the end of the document.
Returns:
A pointer to the newly created page. This pointer will be invalidated after the document is destroyed.
virtual Page* pdf::Doc::AppendPage (  )  [pure virtual]

This function creates a new page and add it to the document. The page will be appended at the end of the document. The pointer to the newly added page will be returned and the caller can put content to the new page.

Returns:
A pointer to the newly created page. This pointer will be invalidated after the document is destroyed.
virtual Font* pdf::Doc::CreateSimpleFont ( const std::string &  name  )  [pure virtual]

This function creates a new font object that only this document can use.

Parameters:
name the name of the font, e.g. "Arial"
Returns:
A pointer to the newly created font object. The pointer pointed by it will be invalidated after the document is destroyed. The caller does not need to delete it after use.
virtual Page* pdf::Doc::GetPage ( std::size_t  index  )  [pure virtual]
Parameters:
index index to the page.
Returns:
A pointer to the page, or null if the index does not refer to a page. The pointer pointed by it will be invalidated after the document is destroyed.
virtual std::size_t pdf::Doc::PageCount (  )  const [pure virtual]
Returns:
number of page in the document
virtual void pdf::Doc::Read ( const std::string &  filename  )  [pure virtual]

This function reads a PDF document from a file. It will not read all data from the file. It will only read the trailer and cross reference table to know the structure of the PDF document. Page contents will be read on-demand.

The file will be opened throughout the life time of the document object. It will be read for document data when it is needed. The file will only be closed when the document object is destroyed.

The file must be a regular file that supports seeking. Since libpdfdoc will read and seek the file when page contents are read on-demand, it does not support reading PDF files from a pipe or socket.

Parameters:
filename The name of file to be read from. It must be readable, but not nesscarrily writable.
Exceptions:
ParseError is thrown when there is parser error in the PDF file.
See also:
Write()
virtual void pdf::Doc::Write ( const std::string &  filename  )  const [pure virtual]

This function writes the PDF document to a file. The file should not be the one that is specified in Read(). During Write(), all page content of the PDF document will be read and saved in filename .

Parameters:
filename The name of the file to be written to. If it does not exist, it will be created. It must be writable.
Exceptions:
ParseError is thrown when there is parser error when reading the page contents from the file.
See also:
Read()

The documentation for this class was generated from the following file:

Hosted by SourceForge Logo