Search code examples
javaprintingswtpdfrenderer

PDF Renderer with PrintDialog


Is this possible?

I am getting the directory and filename of a existing PDF document. C:\temp\FileName.pdf

  1. Use PDF Renderer to either view the document or print the document I have PDF Renderer included in my Eclipse Project, just not sure how to use it

  2. Then use PrintDialog to print out the PDF Document. I think that PDF Renderer has to do something to make the PDF document printable

I want have 2 buttons on my form

  • View PDF -> opens the pdf document in read only
  • Print PDF -> gets the pdf document ready to print then calls PrintDialog to select a local printer and then prints

I am not having much luck finding any PDFRenderer sample code that shows how to open the PDF document in view mode. I haven't seen code on how to send the PDF Renderer result to a PrintDialog to print.


Solution

  • You certainly can implement PDF rendering in your application. The question is, if it is really necessary or not. Since you dindn't specify which library you want to include, I can't help you with the PDFRenderer.
    However, for purpose of launching an external PDF viewer and how to implement a print button, those API classes are useful:

    At least it'll help to (partially) solve your problem.