NAME
Document::Writer - Library agnostic document creation
SYNOPSIS
use Document::Writer;
# Use whatever you like
use Graphics::Primitive::Driver::Cairo;
my $doc = Document::Writer->new;
# Create the first page
my $p = $doc->turn_page(Document::Writer->get_paper_dimensions('letter'));
# ... Do something
my $p2 = $doc->turn_page;
# ... Do some other stuff
$self->draw($driver);
$driver->write('/Users/gphat/foo.pdf');
DESCRIPTION
Document::Writer is a document creation library that is built on the Graphics::Primitive stack. It aims to provide convenient abstractions for creating documents and a library-agnostic base for the embedding of other components that use Graphics::Primitive.
When you create a new Document::Writer, it has no pages. You can add pages to the document using either add_page($page)
or turn_page
. If calling turn_page to create your first page you'll need to provide a width and height (which can conveniently be gotten from get_paper_dimensions
). Subsequent calls to turn_page
will default the newly created page to the size of the last page in the document.
WARNING
This is an early release meant to shake support out of the underlying libraries. Further abstractions are forthcoming to make adding content to the pages easier than using Graphics::Primitive directly.
METHODS
- add_page ($page)
-
Add an already created page object to this document.
- clear_pages
-
Remove all pages from this document.
- draw ($driver)
-
Convenience method that hides all the Graphics::Primitive magic when you give it a driver. After this method completes the entire document will have been rendered into the driver. You can retrieve the output by using Driver's data or write methods.
- find_page ($name)
-
Finds a page by name, if it exists.
- first_page
-
Return the first page.
- get_paper_dimensions
-
Given a paper name, such as letter or a4, returns a height and width in points as an array. Uses Paper::Specs.
- get_page ($pos)
-
Returns the page at the given position
- get_tree
-
Returns a Forest::Tree object with this document at it's root and each page (and it's children) as children. Provided for convenience.
- page_count
-
Get the number of pages in this document.
- pages
-
Get the pages in this document.
- turn_page ([$width])
-
"Turn" to a new page by creating a new one and add it to the list of pages in this document. If there are pages already in the document then the last one will be used to provided height and width information.
For less sugar use add_page.
SEE ALSO
Graphics::Primitive, Paper::Specs
AUTHOR
Cory Watson, <gphat@cpan.org>
Infinity Interactive, http://www.iinteractive.com
BUGS
Please report any bugs or feature requests to bug-geometry-primitive at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geometry-Primitive. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
COPYRIGHT & LICENSE
Copyright 2008 by Infinity Interactive, Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.