Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for printpdf.kix

(view source code of printpdf.kix as plain text)

  1. ; Some "shortcuts" to special characters
  2. $n = Chr(13) + Chr(10)
  3. $q = Chr(34)
  4.  
  5. ; Check if argument is a valid file specification and build the file list
  6. If $pdf = ""
  7. 	GoTo Syntax
  8. EndIf
  9. If Exist( $pdf ) = 0
  10. 	GoTo Syntax
  11. EndIf
  12. $filename = Dir( $pdf )
  13. If @ERROR
  14. 	GoTo Syntax
  15. EndIf
  16. While $filename <> "" and @ERROR = 0
  17. 	$pdflist  = $pdflist + " $q$filename$q "
  18. 	$filename = Dir()
  19. Loop
  20.  
  21. ; Read the print command from the registry
  22. $filetype = ReadValue( "HKEY_CLASSES_ROOT\.pdf", "" )
  23. $printcmd = ReadValue( "HKEY_CLASSES_ROOT\$filetype\shell\print\command", "" )
  24.  
  25. ; Quit if Acrobat Reader is not the default association for PDF files
  26. If InStr( $printcmd, "{" )
  27. 	GoTo Other
  28. EndIf
  29.  
  30. ; Execute the print command for all files from the list
  31. $printcmd = SubStr( $printcmd, 1, InStr( $printcmd, "$q" + "%1$q" ) - 1 ) + $pdflist
  32. Run $printcmd
  33.  
  34. ; Normal program termination
  35. Exit 0
  36.  
  37. :Other
  38. ? "This script only works when Acrobat Reader is the default association"
  39. ? "for PDF files.";
  40. ? "On this PC that doesn't seem to be the case, maybe because other"
  41. ? "Adobe software is installed as well.$n"
  42. Exit 1
  43.  
  44. :Syntax
  45. ? "PrintPDF.kix,  Version 1.00"
  46. ? "Print the specified PDF file(s)$n"
  47. ? "Usage:  KIX32  PRINTPDF.KIX  $PDF=$q" + "pdf_files$q$n"
  48. ? "Where:         $q" + "pdf_files$q is (are) the PDF file(s) to be printed"
  49. ? "                           (use wildcards to specify more than one file)$n"
  50. ? "Note:   This script will only work if Acrobat Reader is the default"
  51. ? "        association for PDF files."
  52. ? "        It usually fails on PCs with other Adobe software installed.$n"
  53. ? "Written by Rob van der Woude"
  54. ? "http://www.robvanderwoude.com$n"
  55. Exit 1
  56.  

page last uploaded: 2017-08-21, 14:26