SEARCH
NEW RPMS
DIRECTORIES
ABOUT
FAQ
VARIOUS
BLOG

BotDetect - Real-Time Bot Detection API
 
 

MAN page from Old RedHat 7.X perl-Text-PDF-0.09-8.i386.rpm

Text::PDF::File

Section: User Contributed Perl Documentation (3)
Updated: perl v5.6.0
Index 

NAME

Text::PDF::File - Holds the trailers and cross-reference tables for a PDF file 

SYNOPSIS

 $p = Text::PDF::File->open("filename.pdf", 1); $p->new_obj($obj_ref); $p->free_obj($obj_ref); $p->append_file; $p->close;
 

DESCRIPTION

This class keeps track of the directory aspects of a PDF file. There are twoparts to the directory: the main directory object which is the parent to allother objects and a chain of cross-reference tables and corresponding trailerdictionaries starting with the main directory object. 

INSTANCE VARIABLES

Within this class hierarchy, rather than making everything visible via methods,which would be a lot of work, there are various instance variables which areaccessible via associative array referencing. To distinguish instance variablesfrom content variables (which may come from the PDF content itself), each suchvariable will start with a space.

Variables which do not start with a space directly reflect elements in a PDFdictionary. In the case of a Text::PDF::File, the elements reflect those in thetrailer dictionary.

Since some variables are not designed for class users to access, variables aremarked in the documentation with (R) to indicate that such an entry should onlybe used as read-only information. (P) indicates that the information is privateand not designed for user use at all, but is included in the documentation forcompleteness and to ensure that nobody else tries to use it.

newroot
This variable allows the user to create a new root entry to occur in the trailerdictionary which is output when the file is written or appended. If you wish toover-ride the root element in the dictionary you have, use this entry to indicatethat without losing the current Root entry. Notice that newroot should point toa PDF level object and not just to a dictionary which does not have object status.
INFILE (R)
Contains the filehandle used to read this information into this PDF directory. Isan IO object.
fname (R)
This is the filename which is reflected by INFILE, or the original IO object passedin.
update (R)
This indicates that the read file has been opened for update and that at somepoint, $p->appendfile() can be called to update the file with the changes thathave been made to the memory representation.
maxobj (R)
Contains the first useable object number above any that have already appearedin the file so far.
outlist (P)
This is a list of Objind which are to be output when the next appendfile or outfileoccurs.
firstfree (P)
Contains the first free object in the free object list. Free objects are removedfrom the front of the list and added to the end.
lastfree (P)
Contains the last free object in the free list. It may be the same as the firstfreeif there is only one free object.
objcache (P)
All objects are held in the cache to ensure that a system only has one occurrence ofeach object. In effect, the objind class acts as a container type class to hold thePDF object structure and it would be unfortunate if there were two identicalplace-holders floating around a system.
epos (P)
The end location of the read-file.

Each trailer dictionary contains a number of private instance variables whichhold the chain together.

loc (P)
Contains the location of the start of the cross-reference table preceding thetrailer.
xref (P)
Contains an anonymous array of each cross-reference table entry.
prev (P)
A reference to the previous table. Note this differs from the Prev entry whichis in PDF which contains the location of the previous cross-reference table.
 

METHODS

 

Text::PDF::File->new

Creates a new, empty file object which can act as the host to other PDF objects.Since there is no file associated with this object, it is assumed that theobject is created in readiness for creating a new PDF file. 

$p = Text::PDF::File->open($filename, $update)

Opens the file and reads all the trailers and cross reference tables to builda complete directory of objects.

$update specifies whether this file is being opened for updating and editing,or simply to be read.

$filename may be an IO object 

$p->append_file()

Appends the objects for output to the read file and then appends the appropriate tale. 

$p->out_file($fname)

Writes a PDF file to a file of the given filename based on the current list ofobjects to be output. It creates the trailer dictionary based on informationin $self.

$fname may be an IO object; 

$p->create_file($fname)

Creates a new output file (no check is made of an existing open file) ofthe given filename or IO object. Note, make sure that $p->{'Version'} is setcorrectly before calling this function. 

$p->close_file

Closes up the open file for output by outputting the trailer etc. 

($value, $str) = $p->readval($str)

Reads a PDF value from the current position in the file. If $str is too shortthen read some more from the current location in the file until the whole objectis read. This is a recursive call which may slurp in a whole big stream (unprocessed).

Returns the recursive data structure read and also the current $str that has beenread from the file. 

$ref = $p->read_obj($objind)

Given an indirect object reference, locate it and read the object returningthe read in object. 

$objind = $p->new_obj($obj)

Creates a new, free object reference based on free space in the cross reference chain.If nothing free then thinks up a new number. If $obj then turns that object into thisnew object rather than returning a new object. 

$p->out_obj($objind)

Indicates that the given object reference should appear in the output xreftable whether with data or freed. 

$p->free_obj($objind)

Marks an object reference for output as being freed. 

$p->remove_obj($objind)

Removes the object from all places where we might remember it 

$p->ship_out(@objects)

Ships the given objects (or all objects for output if @objects is empty) tothe currently open output file (assuming there is one). Freed objects are notshipped, and once an object is shipped it is switched such that this filebecomes its source and it will not be shipped again unless out_obj is calledagain. Notice that a shipped out object can be re-output or even freed, butthat it will not cause the data already output to be changed. 

PRIVATE METHODS & FUNCTIONS

The following methods and functions are considered private to this class. Thisdoes not mean you cannot use them if you have a need, just that they aren't reallydesigned for users of this class. 

$offset = $p->locate_obj($num, $gen)

Returns a file offset to the object asked for by following the chain of crossreference tables until it finds the one you want. 

update($fh, $str)

Keeps reading $fh for more data to ensure that $str has at least a line fullfor `readval' to work on. At this point we also take the opportunity to ignorecomments. 

$objind = $p->test_obj($num, $gen)

Tests the cache to see whether an object reference (which may or may not havebeen getobj()ed) has been cached. Returns it if it has. 

$p->add_obj($objind)

Adds the given object to the internal object cache. 

$tdict = $p->readxrtr($xpos)

Recursive function which reads each of the cross-reference and trailer tablesin turn until there are no more.

Returns a dictionary corresponding to the trailer chain. Each trailer alsoincludes the corresponding cross-reference table.

The structure of the xref private element in a trailer dictionary is of ananonymous hash of cross reference elements by object number. Each elementconsists of an array of 3 elements corresponding to the three elements readin [location, generation number, free or used]. See the PDF Specificationfor details. 

$p->out_trailer($tdict)

Outputs the body and trailer for a PDF file by outputting all the objects inthe ' outlist' and then outputting a xref table for those objects and anyfreed ones. It then outputs the trailing dictionary and the trailer code. 

Text::PDF::File->_new

Creates a very empty PDF file object (used by new and open)


 

Index

NAME
SYNOPSIS
DESCRIPTION
INSTANCE VARIABLES
METHODS
Text::PDF::File->new
$p = Text::PDF::File->open($filename, $update)
$p->append_file()
$p->out_file($fname)
$p->create_file($fname)
$p->close_file
($value, $str) = $p->readval($str)
$ref = $p->read_obj($objind)
$objind = $p->new_obj($obj)
$p->out_obj($objind)
$p->free_obj($objind)
$p->remove_obj($objind)
$p->ship_out(@objects)
PRIVATE METHODS & FUNCTIONS
$offset = $p->locate_obj($num, $gen)
update($fh, $str)
$objind = $p->test_obj($num, $gen)
$p->add_obj($objind)
$tdict = $p->readxrtr($xpos)
$p->out_trailer($tdict)
Text::PDF::File->_new

This document was created byman2html,using the manual pages.
 
ICM Bot detect detector