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->next_page(Document::Writer->get_paper_dimensions('letter'));
# ... Do something
my $p2 = $doc->next_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 next_page
. If calling next_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 next_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.
- current_page
-
The index of the current page. This value is updated when calling next_page and is undefined when the document is created. TODO
- 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.
- next_page ([$width, $height])
-
Return the next page. Increments the
current_page
by one. If a page exists at that index it is returned. If a page does not exist then a new page is added to this document.If there are pages already in the document then width and height information will be copied from the last page. Prodiving width and height as arguments to this method override that behaviour and are necessary if there are no pages from which to copy it.
Note: Color is copied from the last page.
For less sugar use add_page.
- page_count
-
Get the number of pages in this document.
- pages
-
Get the pages in this document.
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.