Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Here's what I have now. I borrowed hdump from the examples directory of HTML::Parser. Then I used CAM::PDF::GS to make a gs log file.
#!/usr/bin/perl use strict; use warnings; use CAM::PDF; use Data::Dumper::Concise; use base qw(CAM::PDF::GS::NoText); my $file = shift @ARGV; my $log = '/root/Desktop/gs.log'; binmode STDOUT, ":encoding(utf8)"; open STDOUT, '>', $log; my $pdf = CAM::PDF->new($file); my $contentTree = $pdf->getPageContentTree(5); my $gs = $contentTree->computeGS; print Dumper($gs): close STDOUT;
From the cmdline do
perl gscript.pl /path/to/pdf
Then I used hdump to examine gs.log:
#!/usr/bin/perl -w use strict; use HTML::TokeParser; use Data::Dumper::Concise; $| = 1; sub h { my ( $event, $line, $column, $text, $tagname, $attr ) = @_; my (@d) = uc( substr( $event, 0, 1 ) ) . " L$line C$column"; substr( $text, 40 ) = "..." if length $text > 40; push @d, $text; push @d, $tagname if defined $tagname; push @d, $attr if $attr; print Dumper(@d); } my $p = HTML::Parser->new( api_version => 3 ); $p->handler( default => \&h, "event, line, column, text, tagname, attr +" ); $p->parse_file( @ARGV ? shift : *STDIN );
From the cmdline:
perl hdump /path/to/gs.log
I hope that it's useful for you.

In reply to Re^3: Example Of Using CAM::PDF Like HTML::TokeParser by Khen1950fx
in thread Example Of Using CAM::PDF Like HTML::TokeParser by Limbic~Region

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found