Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Copy & copy... Win32 clipboard utility

by boo_radley (Parson)
on Feb 06, 2002 at 15:24 UTC ( [id://143637]=CUFP: print w/replies, xml ) Need Help??

The Data

70 pages of text and images, formatted in an old print publication layout program.

The Task

Turn it all into HTML.

The Feeble Attempts

Program does not export to HTML
Program claims to output to both postscript and PDF. Lies. Exporting to these formats and then attempting to use a *2HTML converter proves worthless.
No documentation is available for the program to see if it's automatable through Win32::OLE.

The Horrible Conclusion

A whole lot of cutting & pasting.

The Mantra

Perl makes easy things easy and hard things possible.

The Code

#! perl -w use Win32::Clipboard; $clip = Win32::Clipboard::new(); $clip->Empty(); $SIG {"INT"} = sub {$exit=1}; while (1){ last if $exit; next unless $clip->GetText(); print $clip->GetText; print STDERR $clip->GetText; $clip->Empty(); }
explained :
Set up a new Win32::Clipboard object & clear the contents. Then set up a new $SIG{INT} handler to capture ctrl+c, which will be the 'exit' command.
loop while there's no text in the clipboard & the user hasn't pressed ctrl+c yet.
inside the loop, print the clipboard contents to STDOUT & STDERR, then clear them again.

usage : perl clipboard.pl >1.txt
arranged windows so that the layout program & a dos window were side-by-side. Starting with the first text element at the top of page one, select all of the element's text & copy. Move to next element, copy. Repeat for each text element. Hit ctrl-c.

move to next page in layout software & start perl clipboard.pl >2.txt... The entire process took a bit over 15 minutes once I got a rhythm down. Used the resulting files to craft simple XML documents, then applied a stylesheet to flesh out the HTML.

Total Elapsed Time : 2 hours
Thanks, perl!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://143637]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-03-19 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found