• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Printing PDF - Technical Solution Needed

 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I need some technical help in this problem that I am stuck in. I need to silent print(print without opening file) PDF file using java code. I have this code and it works fine except that it blows up font a little and the footer cuts off.



I don't know, how can I share .pdf files on this forum. Moderators could you please help me out?

Thanks in Advance
 
Shaan Shar
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just found from JAVA API docs following:



Now in my current code I am passing 3rd parameter(attributes) as null, as I don't know, how can I get attribute from my file. Could anyone help me out to get the attribute set for pdf file I have provided in FileInputStream() variable.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I need to silent print (print without opening file)


By "silent" I assume you mean "without showing a dialog to the user". The printer driver obviously will have to open the file.

Whether it's possible to print a PDF depends a good deal on the printer/printer driver you're using. Some printers can print PDFs, but many can't. For a general solution, I'd look into the https://pdf-renderer.dev.java.net/ library; it can print PDFs.
 
Shaan Shar
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:

By "silent" I assume you mean "without showing a dialog to the user". The printer driver obviously will have to open the file.

Whether it's possible to print a PDF depends a good deal on the printer/printer driver you're using. Some printers can print PDFs, but many can't. For a general solution, I'd look into the https://pdf-renderer.dev.java.net/ library; it can print PDFs.



Thanks for your reply ULF, but my printer is printing pdf file with this code, but the problem is, it blows up font a little and the footer cuts off.

I apologize if I haven't explained it correctly.
 
Shaan Shar
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ulf,
Could you help me to upload a sample pdf file, so that I can show it to you?
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ankur Sharma:
Now in my current code I am passing 3rd parameter(attributes) as null, as I don't know, how can I get attribute from my file. Could anyone help me out to get the attribute set for pdf file I have provided in FileInputStream() variable.


What you can try is to show a print dialog in a test setup, then read the DocAttributeSet it generates. Then create your own DocAttributeSet with the same contents in your real code.
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ankur Sharma:
Ulf,
Could you help me to upload a sample pdf file, so that I can show it to you?



I'm a new Bartender here so don't take this as 100% gospel but I'm pretty sure that Javaranch doesn't support uploads at this stage. Are you able to type out the surrounding lines?
 
Marshal
Posts: 76863
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the easiest ways to create a pdf is to use an office suite which supports pdf creation, write out a document with drawing objects in, and "export" it as a pdf. OpenOffice will do that easily.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the printing different than from printing the .pdf diractly from
a .pdf viewer ?
 
machines help you to do more, but experience less. Experience this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic