NAME

PDF::Make::Parser - Parse existing PDF files

SYNOPSIS

use PDF::Make::Parser;

# Parse from bytes
my $parser = PDF::Make::Parser->from_bytes($pdf_bytes);
my $doc = $parser->document;

# Parse from file
my $parser = PDF::Make::Parser->from_file('document.pdf');
my $doc = $parser->document;

# Enable repair mode for broken PDFs
my $parser = PDF::Make::Parser->from_file('broken.pdf', repair => 1);

# Access parsed information
print "Root object: ", $parser->root_num, " ", $parser->root_gen, " R\n";
print "Xref size: ", $parser->xref_size, "\n";

# Resolve an indirect reference
my $obj_kind = $parser->resolve($num, $gen);

DESCRIPTION

PDF::Make::Parser parses PDF files into a PDF::Make::Document structure. It supports classic xref tables, xref streams, hybrid files, and incremental updates. An optional repair mode can reconstruct the xref from a damaged file.

METHODS

from_bytes($bytes, %opts)

Create a parser from raw PDF bytes. Options:

repair => 1

Enable repair mode to reconstruct xref from damaged files.

from_file($path, %opts)

Create a parser from a file path. Same options as from_bytes.

parse()

Run the parser. Called automatically by document() and resolve() if needed. Returns $self.

document()

Returns the parsed PDF::Make::Document.

set_repair($enable)

Enable or disable repair mode before parsing.

root_num(), root_gen()

Return the object number and generation of the document root.

xref_size()

Return the number of entries in the cross-reference table.

resolve($num, $gen)

Resolve an indirect reference by object number and generation. Auto-parses if needed.

errmsg(), erroffset()

Return error information if parsing failed.

SEE ALSO

PDF::Make, PDF::Make::Document

AUTHOR

LNATION <email@lnation.org>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.