• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing JTable to PDF so that text is searchable

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you print (eg a JTable) from Java/Swing and choose "Adobe PDF" as the printer, you get an Acrobat file. But the PDF isn't searchable because the text has already been rendered by Java before Adobe PDF gets to see it. Is there a way to make printing use a more high-level interface to the printer driver so that the text is left intact?

For the avoidance of doubt: I'm not asking for Java to generate PostScript, although I guess that would be a solution - as would OCR'ing the resultant PDF.
 
Malcolm Storey
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JTable printing examples do what I want, https://docs.oracle.com/javase/tutorial/uiswing/misc/printtable.html so it's something I'm doing wrong. I wrote the code a while ago, so need to investigate - probably printing the container not the JTable.

Apologies for wasting people's time.
 
Malcolm Storey
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In case anybody's interested I tracked it down. I was trying to hide the grid by making it transparent:

Obviously this is better:

Apparently if there's any transparency, Java renders the text itself rather than trying to do it in PostScript.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We usually discuss tables in our GUIs forum. Moving discussion.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic