perl script to create letter ballot comments from PDF annotations

Elliott, Robert Robert.Elliott at COMPAQ.com
Fri Apr 6 07:39:55 PDT 2001


* From the T10 Reflector (t10 at t10.org), posted by:
* "Elliott, Robert" <Robert.Elliott at compaq.com>
*
Here is a perl script to create text-format letter ballot comments from PDF
annotations.  The output format looks like:

CPQ.1 Page 23 Item 1
comment goes here

CPQ.2 Page 23 Item 2
comment goes here

...



#!/usr/local/bin/perl
# Parse Acrobat Annotations into T10 letter ballot comments
# by Rob Elliott, Compaq Computer Corporation
# robert.elliott at compaq.com

# Usage:
# Create an Annotations from PDF file
# Select all text in it
# Paste into a text file with a text editor (e.g. vim)
# Save the file and run this script on it
# parse_ann < input.txt > output.txt
#
# Comments are numbered, labels are stripped
use Text::Wrap;     # import wrap()

$Text::Wrap::columns = 77;  # wrap output lines
$prefix = "CPQ";        # prepend to each comment

<>;     # consume the Annotations from mmc3r09 line

while (<>) {
    # most lines start with Page
    # sometimes it gets concatenated to the previous line with .Page
    if (/Page (\d+)\s*$/) {
        $page = $1;

    # most lines start with Annotation
    # sometimes it gets concatenated to the previous line with .Annotation
    # assumes DOS text file format with \r\n line endings
    } elsif (/Annotation (\d+); Label.*/) {
        $item = $1;
        $annotation_count++;
        print "\r\n$prefix.$annotation_count Page $page Item $item\r\n";
    } else {
        print wrap "", "", $_;
    }
}
*
* For T10 Reflector information, send a message with
* 'info t10' (no quotes) in the message body to majordomo at t10.org




More information about the T10 mailing list