Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Silent Print PDF file with printer configuration

 
sara sin
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.
 
Thakur Sachin Singh
Ranch Hand
Posts: 248
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you got any exception in this code??
 
Hebert Coelho
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic