We have developed an in-house printing solution that allows users to manage their prints (audit/merge/review/send to multiple printers) etc... but we are having issues with the very end of the process - the final print.
Currently our solution stores documents (original & after merging) in PDFs. We need to be able to send these documents to a particular printer and have it in some cases (when the user has selected the option) print page 1 to tray 8 and the rest to tray 1. We can't split the PDFs and print them separately as they also have to be stapled by the printer as a single job.
Our idea was to convert the PDF files to PostScript files using ghostscript then insert PJL commands into the PostScript and then print this modified PostScript file using gsprint.
Unfortunately the combination of ghostscript, postscript, PJL and gsprint doesn't seem to be working. The PJL commands we try, which we CAN get to work within text files sent to the printer via the windows copy command, don't seem to have the same affect when put into the PostScript files and printed using gsprint.
Can anyone spot any hideous flaws in what we are doing to the PostScript or have any idea why the PostScript->PJL amends->gsprint workflow we have might not be working?
It's been very difficult to find examples online so it's very possible our placement of PJL commands is incorrect.
(//comments not in final file)
<ESC>%-12345X#PJL JOB<ESC>&l8H //start job printing first page
#PJL ENTER LANGUAGE = Postscript //to tray 8 (letterhead)
#PJL COMMENT CANPJL SET STAPLE=ONEUPLEFT //indicate the document should be stapled
%!PS-Adobe-3.0 //start of PostScript file proper
---
%%PageTrailer //end of first page
<ESC>%-12345X#PJL EOJ<ESC>%-12345X //end the first job
%%Page: 2
<ESC>%-12345X#PJL JOB<ESC>&l7H //start 2nd job to print remaining
--- //pages to tray 1 (plain)
---
%%EOF
<ESC>%-12345X#PJL EOJ<ESC>%-12345X //end 2nd job
We then take this modified PostScript and use gsprint as follows:
gsprint -noquery -ghostscript gswin32c -printer "printer" "C:\postscriptfile.ps"
This all print out to the default tray and unstapled, i.e. none of this works as expected.
I hope it's clear what we are trying to achieve. Any help would be greatly appreciated.
Thanks in advance.
PS: All our printers are Canon printers.
Edit:
After KenS's answer below it seems the logical workflow should instead be PDF->PCL->add PJL->send to printer with "copy"
Unfortunately we are still having issues with this, certain PJL commands seem to be ignored by our printers (the printers are definitely PCL printers).
If we take a 2 page PDF produced by Microsoft Word, convert it to PCL using ghostscript then edit that PCL file with Notepad++ add add the following:
<ESC>%-12345X#PJL JOB NAME = "My Print Job Name"<CR><LF>
#PJL SET DUPLEX = ON
#PJL SET OUTBIN = LOWER
#PJL ENTER LANGUAGE = PCL
...original PCL data...
<ESC>%-12345X#PJL EOJ<CR><LF>
<ESC>%-12345X
the document comes out of the lower output tray but not duplexed. But what is extra odd is that the printer seems to take much longer to print when DUPLEX = ON than the exact same job with DUPLEX = OFF and it sounds like it's doing something different internally.
Any ideas?
I think you misunderstand how gsprint operates. It takes an input file, renders it to a bitmap, draws that bitmap on an appropriate canvas, and then uses the Windows printing system to print that canvas on a printer. It does not have any control of the printer at all, as a result embedding anything which is expected to control the printer (as opposed to the rendering) will not have any effect.
In addition, PJL is asociated with HP PCL printers, not with PostScript printers. Whil;e your PJL may work on a PCL printer, because it treats each page as a separate job, it won't work at all on a PostScript printer, and may well cause it to give you an error, depending on whether the interpreter ignores PJL commands or not.
In order to control the printer, you will need to determine what kind of input the printer supports (PostScript or PCL), you then need to convert your PDF to that form, then insert appropriate control sequences. In the case of a PCL printer you might reasonably use PJL, for PostScript printers you should control this using the setpagdevice operator. Assuming you have a Windows .WPD or .PPD file for your printer, the relevant control sequences can be found there, or by printing a few test files and examining their contents.
In passing; you say that the commands you are using work when sending text files to the printer. This means the printer at least understands PJL and is almost certainly a PCL printer. You can't send text to a PostScript printer, it will generate an error, because PostScript is a programming language and you will have syntax errors with any random piece of text. You can however send text to a PCL printer which assumes that anything not starting with a 0x1B (escape) is just text to be printed.
So using Ghostscript to produce PCL output, inserting your PJL as you have above, and then sending the result directly to the printer should probably work. Of course identifying the end of each page might be more difficult in a PCL file.
We had similar issue this is how we did using ghost script and PJL
http://reddymails.blogspot.com/2014/07/how-to-print-documents-using-java-how.html
Also bfo.com has some commercial jars which do the same thing without ghost script and in a Pure java way. But you have to pay for it :)
Related
I have a program that basically creates a text report containing non-ASCII characters (Traditional Chinese, to be exact). The file opens up fine in text editors.
The main problem I'm having is printing this text report
If I print this file from notepad, the form feeds/page breaks
aren't recognized and the alignment goes haywire. Non-ASCII characters show fine.
If I use the command "type filename > \\machine\printer", the alignment works but all non-ASCII characters print as gibberish.
I've tried several variations of raw printing, setting system locale, changing code page, etc but can't get it to work.
Originally, the program was allowed to spool directly to printer (and it worked fine) but due to technology changes, direct spooling is forbidden. I can only work with the text-file as-is after it's been generated.
Does anyone have an idea how to work with this?
Found a way -basically using powershell and force the encoding to UTF-8 in Get-Content. Apparently cmd spooling will never be able to handle this...
Briefly, I would like to show a moderately complicated Photoshop action in a forum. Saving the .atn file is easy, but it is encrypted by adobe.
I found a 25,475 line .jsx file which will apparently convert it to XML but is unusable without any usage or documentation
http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/apps/ActionFileToXML.jsx
What is the easiest way, other than read action word, type word in text editor, to get the 6 inches of action (as seen in Photoshop) into plain text?
GORY DETAILS:
I have a large number of files which I inadvertently damaged by using perfectlyclear on them. It enhances some of the areas but pathologically destroys all darkish areas by converting them to pure black and near zero contrast. When printed, the pictures look like somebody took a black magic marker and redacted large areas. They are damaged beyond use as-is.
The Photoshop fix is to
duplicate layer
select color range, click on a black area, set fuzziness to ~12, range=100%
select expand 4, feather 3
make new mask channel
select backward (original) layer
delete (nukes blackened area under mask)
save as PNG with transparency
This leaves a PNG file with the redacted areas transparent and with feathering around them. By placing the original file beneath it, the original non-blackeded areas are shown.
I would like to document this modest solution in an ImageMagick forum but can not believe how far adobe has gone to lock my action into adobe-only tools. I want to jailbreak this and all of my other actions.
NOTE: There is a one line usage in ActionFileToXML.jsx: "This script reads an ActionFile and converts it to XML" and no documentation of any type. An alert I stumbled upon states that it will only work in CS2/3/4 and I have CS6. It has a 2007 date on it.
I have read that this .JSX is adobe's version of JavaScript and that you run them from inside Illustrator (which I don't have).
I want to figure out how to decrypt my actions and write a useable script:
USAGE: decrypt.atn.to.txt.pl encrypted.atn [-o text_file_name] <enter>
Supply fully qualified path to a .atn" file and it will be deciphered
into a useable .txt file with the same path/basename and a .txt
extension unless you use the -O option which will attempt to write to
the file name you supply.
Perhaps, I could even make a CPAN module?!
Good thing the .JSX writer had the foresight to include 0.0039% documentation or the program would be completely useless! :)
SOLUTION == and STEP by STEP instructions:
The link:
http://ps-scripts.cvs.sourceforge.net/viewvc/ps-scripts/xtools/apps/ActionFileToXML.jsx
points to a gigantic adope extend-script. Reading the file, line 3 has the ~only documentation:
// This script reads an ActionFile and converts it to XML.
The filename already tells you this: ActionFileToXML.jsx
Without wading through 25,000 lines of largely uncommented, 8-year-old code/data/??? it is completely unusable.
What the link poster failed to include was the PACKAGE containing the other 300 files which includes the README.txt, INSTALLATION.txt, /docs, etc.
The PACKAGE supplying context, install, usage, etc can be found at
http://sourceforge.net/projects/ps-scripts/files/xtools/v2.2betas/
How to Decrypt adope's .atn file, step by step:
download README.txt and xtools*.zip from http :// sourceforge.net|projects|ps-scripts|files|xtools|v2.2betas
READ README.txt and unzip zip to any place you like (and REMEMBER where you put it). NOTE: evilnet explorer will by default hide it under some mile long, incredibly ugly file path where you may never find it so use FIREFOX: set tools -> options -> general -> downloads to Always_Ask_Me (or set a reasonable download directory)
Photoshop -> actions, click on action set you want to decipher and click the "arrow box" to the right of actions -> save_actions and put them where you can find them
Photoshop file -> scripts -> browse and navigate to where you stashed ActionFileToXML.jsx and execute. This pops up a GUI as shown at http :// ps-scripts.sourceforge.net|xtools.html
Navigate to where you hid you .atn file, the XML file box will be populated with the same path/file_BASE_name and an XML extension as a default. Adjust name/location to suit
hit PROCESS and in a delightfully brief period (in my case), it was done
Get ready to marvel at the succinct efficiency with which adope stores an action like [select->color_range, localized, fuzziness=14, range=100%] (56 bytes written by hand) in only 3635 bytes of unfathomably labyrinthine XML with no default values left underspecified. It look a lot like IRS regulation fine print! ;)
The main difficulty in trying to make sense of the XML is that it is written in some funky interpreter psycho-code which bears absolutely no resemblance to the keys/clicks you actually used to create it.
One of the steps I was attempting to elucidate was was simply layer (I NEVER ToucheDER) -> layer_mask -> hide_selection. It is diabolically obfuscated as (and I quote):
<ActionItem key="TEXT" expanded="false" enabled="true" withDialog="false" dialogOptions="2" identifier="TEXT" event="make" name="Make" hasDescriptor="true"><ActionDescriptor key="make" count="3"> <DescValueType.CLASSTYPE key="1316429856" id="1316429856" symname="New" sym="Nw " classString="Channel" class="Chnl"/><DescValueType.REFERENCETYPE key="1098129440" id="1098129440" symname="At" sym="At "><ActionReference key="1098129440" id="1098129440" symname="At" sym="At " count="1">
make .. new .. channel .. at .. mask .. hideSelection? Huh?
I had to scratch my head and fiddle around with the Channels panel options before I found the menu solution.
According to the generous and personable developer, Xbytor (who patiently answers emails from agitated would-be users), this XML can be hacked (carefully), translated back into a .ATN file and used by Photoshop. A very powerful possibility.
Brian
I have a couple of (mostly) text widgets that I would like to render to a printer through a standard "Print..." menu option. One widget is a Mono.TextEditor document, and the other is a Gtk.TextView.
I'm looking for a pretty basic print for now, which might wrap long lines, and add page numbers. Do I need to code all of this myself somehow?
If you have pointers, that would be great, especially if they were in C#.
For line wrap and justification, one can use pango Layout
options, as described for Python at pygtk/class-pangolayout or for C at pango/pango-Layout-Objects. See functions pango_layout_set_wrap() and pango_layout_set_justify().
Also see the example-code routines begin_print, do_page_setup, and do_print in file pygtk-demo/demos/print_editor.py, if you have installed pygtk on your system. (On my system, the full path to directory of Python Gtk demo files currently is /usr/share/doc/pygtk2-2.17.0/examples/pygtk-demo/demos)
For printer setup dialog, see gtk-High-level-Printing-API for C, or class-gtkprintoperation for Python.
Is there a way to run a file through a print driver without opening the application?
Ex: run a .docx file, without opening word, and save it to file?
Since it is a .docx-file Microsoft Word is probably the best program to do the task.
I would have a look at the [command line arguments] to Word:
Have a look at the following switches:
/q, /n, /mFilePrintDefault and /mFileExit
(/q and /n explained in the page above, and /mXxxx refers to macros. Have a look att google.)
Example:
WINWORD.EXE your_document.docx /mFilePrintDefault /mFileExit /q /n
The following page seems to explain how to convert it to PDF.
What you are looking for is called "headless start" of the program which needs to print.
I know for sure that OpenOffice can do this.
Basically, you need to start it and invoke a macro which will do the printing. Even more, you can print to a PDF, HTML, or anything else that Oo supports.
This negates the need for install of Microsoft Word and the cost of license, because OpenOffice is free.
If you are looking only for .docx silent printing then [aioobe] answer is the best. If you want a more generic silent print program that runs on Windows, use powershell or .NET and use the print verb. http://www.eggheadcafe.com/software/aspnet/30441939/how-to-suppress-printdialog-when-using-print-verb.aspx provides an example.
Hope this helps, if so +1 please :)
You might be interested in DocTo which will convert a word document to another file format, including pdf and XPS but does require Word on the machine.
For example
Docto -f "c:\docs\mydocument.docx" -o "c:\output" -t wdFormatPDF
Will output mydocument.docx to c:\output\mydocument.pdf as a pdf file.
I am automating the printing of jpg files using a windows batch file and the command line interface for the Windows Picture and Fax Viewer. The command I'm using in my .bat is:
rundll32.exe C:\Windows\System32\shimgvw.dll,ImageView_PrintTo /pt "%fullpath_to_jpg%" "%printer_name%"
My photo printer does 4x6 prints. If the jpg file is exactly 4x6 aspect ratio, everything works fine and I get a full-bleed 4x6 print. If not, I get a white border that I do NOT want. In Windows Explorer, I can right click on the non-4x6 jpg and select print to invoke the Photo Printing Wizard, select "Full page photo print" and it crops to give me the full-bleed 4x6 print that I want.
How can I specify "Full Page Photo Print" layout selection from the command line to tell shimgvw.dll to "crop and rotate to fit" not "center and rotate to fit"? Is there a registry setting to select this as the default layout instead of the "Full page fax print? Should I be using photowiz.dll instead of shimgvw.dll?
I can't find a reference for command line parms or registry settings for these dlls.
Bad news: there is no way to do this, even with VBS. I extracted all the strings and did significant searches on the web for all means of controlling this .dll and only two basic ones exist:
rundll32 shimgvw.dll,ImageView_Fullscreen c:\temp\grub.jpg
will print grub.jpg to the screen
rundll32 shimgvw.dll,ImageView_PrintToW /pt c:\temp\grub.jpg "Microsoft XPS Document Writer"
will print grub.jpg to the MS Office XPS printer, though this and PDF printers will require you to select a filename so automating this way is not possible
The only way to possibly automate printing using built-in methods to XP would use SendKeys, but that's a horrible solution, given that any accidental keystrokes entered by the user would render the output different than what you want. Of course you could always start the process hidden in VBS but this is not an ideal solution.