Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Copy & copy... Win32 clipboard utility

by boo_radley (Parson)
on Feb 06, 2002 at 15:24 UTC ( #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 >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 >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?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2022-08-14 18:02 GMT
Find Nodes?
    Voting Booth?

    No recent polls found