Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > using win32ole to print .txt, .pdf, .xps files

Reply
Thread Tools

using win32ole to print .txt, .pdf, .xps files

 
 
justin.irigo@gmail.com
Guest
Posts: n/a
 
      03-07-2007
good afternoon to all.

i am creating a simple script to automate the printing of pdf, txt,
and xps files. i'm using this exercise as my first step in learning
ruby.

i am able to print doc, xls, and ppt files using code that i put
together from snippets i got off the net:

require 'win32ole'
....
app = WIN32OLE.new("word.application")
app.Documents.Open("/test.doc")
testfile = app.ActiveDocument
testfile.PrintOut()
....
testfile.Close()
app.Quit()
....


i haven't been able to find code snippets (or adequate win32ole
documentation) for printing .txt files (through notepad), or pdf or
xps.
is this even possible? through win32ole or otherwise?
if it is, can anyone provide me with the necessary details as to how?
if it is not possible, any suggestions for an alternative method?

thank you very much in advance.

 
Reply With Quote
 
 
 
 
Dave Burt
Guest
Posts: n/a
 
      03-07-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> good afternoon to all.
>
> i am creating a simple script to automate the printing of pdf, txt,
> and xps files. i'm using this exercise as my first step in learning
> ruby.
>
> i am able to print doc, xls, and ppt files using code that i put
> together from snippets i got off the net:
>
> require 'win32ole'
> ...
> app = WIN32OLE.new("word.application")
> app.Documents.Open("/test.doc")
> testfile = app.ActiveDocument
> testfile.PrintOut()
> ...
> testfile.Close()
> app.Quit()
> ...


If you've written VBA code for MS Office programs, you may notice the
similarity. You're using COM, an simple programming API that Office and
some other programs expose. That is, all these methods (Documents, Open,
ActiveDocument, PrintOut, Close, Quit) are being sent to Word to
process. If you want to do more advanced stuff, the place you would look
for reference is in the documentation for VBA in Word.

> i haven't been able to find code snippets (or adequate win32ole
> documentation) for printing .txt files (through notepad), or pdf or
> xps.
> is this even possible? through win32ole or otherwise?


You can open and print a text file in Word in the same way you deal with
a Word document.

As far as I know, Adobe Reader doesn't have a COM interface. You could
use a macro-type solution such as AutoIt3 (which provides a COM
interface which can be used to interact with many Windows applications).

I'm not sure about XPS. Try Word's help to see if you can deal with it
like a Word document.

Otherwise, if you're brave, there's a paper here describing the Vista
..NET API, which you may be able to use via Ruby's DL library, or just a
..NET program rather than Ruby:
http://www.microsoft.com/whdc/xps/xps-read.mspx

Cheers,
Dave
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print a vs print '%s' % a vs print '%f' a David Cournapeau Python 0 12-30-2008 03:19 AM
WIN32OLE - failed to create WIN32OLE zxem Ruby 1 12-19-2007 07:01 PM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
WIN32OLE#[] and WIN32OLE#[]= method in Ruby 1.9 (or later) Masaki Suketa Ruby 4 03-27-2006 11:17 AM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments