This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Java Silent Print PDF file with printer configuration

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

How can I print the PDF file with windows printer configuration?

For example, I have 3 print queues in my windows XP.
Print Queue A - Configured Black and White
Print Queue B - Configured Color
Print Queue C - Configured Color and Staple

If I use Adobe Reader to print the PDF file, it will print whatever the print queue configured.

For example, I print the PDF in Adobe Reader by selecting Print Queue C, the printed file will be colored and stapled.

I printed in java but never take Print Queue C configuration. The following is my code.




Please help.
 
Ranch Hand
Posts: 251
Hibernate Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you got any exception in this code??
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello sara, welcome to JavaRanch.

Is there any error? The file is corrupted in the end?
 
sara sin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks for your reply.

No error / exception. The PDF file was printed successfully but not using Print Queue C configuration (Color and Stapled), printed without stapled.

Do you know why?
 
sara sin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Any Update?
 
sara sin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

If I set got the following error.

sun.print.PrintJobAttributeException: unsupported category: class javax.print.attribute.standard.Finishings
at sun.print.Win32PrintJob.getAttributeValues(Unknown Source)
at sun.print.Win32PrintJob.print(Unknown Source)
 
sara sin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

After many days of research, I know that is difficult to send PDF files to Print Queue directly from Java.
And difficult for Java to use the Print Queue function like Staple and etc.
Because Print Queue is running on OS and Java is running on JVM.
And all the function in the Print Queue are supported by the driver and the driver is provided by the printer company like Canon or etc.
And Canon didn't provided any Java API to use the printer function.

I have decided to use a third party tool (http://www.commandlinepdf.com/) to do this.
If you dont want to pay then you can use Adobe Reader to print but Adobe Reader Windows can't close after print.

The following is my code.



Hope this will help.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

I am able to send file to Printer but it prints unreadable character ?

Does any one experienced same.

Please suggest.
 
Marshal
Posts: 66140
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Which operating system are you on? What happens if you print the same character to the command line?
 
Rajesh Ladani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ritchie.

I am using windows 7 Professional. And i am executing this class file using Eclipse indigo.

I tried to print pdf content in console. it prints junk characters. unreadable format.
 
Campbell Ritchie
Marshal
Posts: 66140
250
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Eclipse console is not intended for printing pdfs, surely. You will have to use a pdf reading program to open it.
 
Rajesh Ladani
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So in this case can't i just send PDF file to printer directly.

I want to send pdf to printer directly without opening print dialog box.
 
Goodbye moon men. Hello tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!