NoteWorthy Software, Inc.
2014-04-16 09:11 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Licensed NWC2 users can upgrade their community membership [more]
 
   Home   Help Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Script to print to PDF  (Read 9342 times)
Randy Williams
Virtuoso
« on: 2010-10-02 09:45 PM »

I doubt anyone will have a need for this script, as I did, but thought I'd post it anyway.  Apologies in advance if wasting your time.  And if someone has a similar script done with "AutoIt" instead of VBScript, I'd be interested in it.

Attached script automates key sequences needed to print current song in NWC to PDF file (song need not be saved to a file).  Script was written to expect PDFCreator 0.9.6, but I believe it can easily be modified for other PDF printers if needed.  Script allows for an optional command-line option which becomes a differentiating suffix for the PDF file.

Script does "inject" key presses, which I'm not a big fan of, but it has some safeguards.  It only does key presses, and never does mouse clicks.  It makes every attempt to ensure correct application has focus before injecting key presses.  It does nothing to the NWC session (or the original file), but instead spawns a separate NWC Viewer (via a temporary file) to do the printing (script can be greatly simplified if one is comfortable injecting to NWC itself - I was not).

I use this script in conjunction with "Run User Tool", so that a single user tool invocation can sequence some automated conversions and then print the result to a PDF, followed by a revert and running another similar user tool to create and print an alternate version, and so on.  Each top-level user tool automatically does everything needed to create and print its specific version.

Invocation command for general use is: wscript scripts\prw_PrintToPdf.vbs "<PROMPT:Suffix:=*>"

Drop ".txt" from file name after downloading.  Specify "File Text" for "Input Type".  Specify "Long Task Handling" option.

* prw_PrintToPdf.vbs.txt (7.2 KB - downloaded 767 times.)
Logged
Flurmy
Virtuoso


« Reply #1 on: 2010-10-04 03:41 AM »

Sorry, I must be sleepy. What's the use of such a program?
Isn't easier (or virtually the same) to use "file->print->PDFCreator" as I do so often?
Logged
Randy Williams
Virtuoso
« Reply #2 on: 2010-10-04 12:58 PM »

What is the idea of any script, but to automate a process which would be tedious to manually do otherwise?!

I found myself doing the following 5 separate times for every hymn I entered:
  • Click on "File", Click on "Print" (or Ctrl-P)
  • Wait for Print box to come up
  • Choose "PDFCreator" for printer (if not already there)
  • Click on "OK"
  • Wait for PDFCreator window to come up
  • Click on "Save"
  • Wait for Save As box to come up
  • Click on end of File Name
  • Enter differentiating suffix [" (C)", " (Bb)", " (F)", " (Eb)", or " (C-alto)"]
  • Click on "Save"

If you find that doing this process so often is easier (or virtually the same) than running a single user tool, you're perfectly welcome to do so!  I have no illusions that this script is a great time-saver for everyone - it just works well for me, and I thought I'd share it, just in case.  Again, apologies if I'm further wasting anyone's time here.

[Using RunUserTool and other scripts, I am fast getting to the point where a single user tool invocation can automatically generate all 5 of my PDFs for a hymn (for C instrument, Bb instrument, F instrument, Eb instrument, and C instrument alto clef).  This PrintToPDF script was a part of that automation process.]
Logged
Flurmy
Virtuoso


« Reply #3 on: 2010-10-05 03:40 AM »

Quote
I am fast getting to the point where a single user tool invocation can automatically generate all 5 of my PDFs for a hymn (for C instrument, Bb instrument, F instrument, Eb instrument, and C instrument alto clef).  This PrintToPDF script was a part of that automation process.

Aha, this makes a lot more sense!

Quote
Again, apologies if I'm further wasting anyone's time here.

Oh, I think I'll survive... ;-)
Out of joke: mine was not a critic, I was simply curious.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by SMF 1.1.19 | SMF © 2013, Simple Machines
Page created in 0.169 seconds with 18 queries.

Copyright © 2014 Noteworthy Software, Inc.