Package ca.cgjennings.apps.arkham.deck
Class PDFPrintSupport
- java.lang.Object
-
- ca.cgjennings.apps.arkham.deck.PDFPrintSupport
-
public final class PDFPrintSupport extends java.lang.Object
Creates simple PDF documents. PDF support is not built in; to use this class thecore-PDFOutput.selibrary
library must be installed. (That library provides a concrete implementation of thePDFPrintSupport.PDFWriter
interface defined in this class.) You can test whether PDF support is available by callingisAvailable()
.For easy PDF creation, use one of the static
printToPDF
methods that take aPrintable
orDeckEditor
. Alternatively, callcreatePDFWriter()
to obtain a high-level interface to the PDF engine.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PDFPrintSupport.Configuration
This class is a simple container for the configuration information that is passed to aPDFPrintSupport.PDFWriter
.static interface
PDFPrintSupport.PDFWriter
An interface implemented by classes that can provide very basic PDF writing support.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PDFPrintSupport.PDFWriter
createPDFWriter()
Returns a new instance of aPDFPrintSupport.PDFWriter
.static float
getDefaultOutputQuality()
Returns the default output quality level for newPDFPrintSupport.Configuration
s.static java.lang.String
getImplementationClassName()
Returns the name of the concretePDFPrintSupport.PDFWriter
class to use.static boolean
isAvailable()
Returnstrue
if PDF support is available.static void
printToPDF(DeckEditor deckEditor, java.io.File pdfFile)
Prints a the contents of a deck to a PDF file.static void
printToPDF(java.lang.String title, PaperProperties paper, java.awt.print.Printable printable, java.io.File pdfFile)
Prints the contents of anyPrintable
object to a PDF file.static void
printToPDF(java.lang.String title, java.awt.print.PageFormat pageFormat, java.awt.print.Printable printable, java.io.File pdfFile)
Prints the contents of anyPrintable
object to a PDF file.static void
setDefaultOutputQuality(float quality)
Sets the default output quality level.static void
setImplementationClassName(java.lang.String className)
Sets the name of the concretePDFPrintSupport.PDFWriter
class to use.
-
-
-
Method Detail
-
isAvailable
public static boolean isAvailable()
Returnstrue
if PDF support is available.- Returns:
true
ifcreatePDFWriter()
will not throw anUnsupportedOperationException
exception
-
printToPDF
public static void printToPDF(java.lang.String title, java.awt.print.PageFormat pageFormat, java.awt.print.Printable printable, java.io.File pdfFile)
Prints the contents of anyPrintable
object to a PDF file.- Parameters:
title
- the title of the PDF filepageFormat
- the page format to useprintable
- the content to printpdfFile
- the PDF file to create
-
printToPDF
public static void printToPDF(java.lang.String title, PaperProperties paper, java.awt.print.Printable printable, java.io.File pdfFile)
Prints the contents of anyPrintable
object to a PDF file.- Parameters:
title
- the title of the PDF filepaper
- the paper type to useprintable
- the content to printpdfFile
- the PDF file to create
-
printToPDF
public static void printToPDF(DeckEditor deckEditor, java.io.File pdfFile)
Prints a the contents of a deck to a PDF file.- Parameters:
deckEditor
- the editor displaying the deck to printpdfFile
- the PDF file to write- Throws:
java.lang.UnsupportedOperationException
- if PDF support is not available- See Also:
isAvailable()
-
createPDFWriter
public static PDFPrintSupport.PDFWriter createPDFWriter()
Returns a new instance of aPDFPrintSupport.PDFWriter
.- Returns:
- a new, uninitialized PDF writer instance
- Throws:
java.lang.UnsupportedOperationException
- if no PDF support is available
-
getDefaultOutputQuality
public static float getDefaultOutputQuality()
Returns the default output quality level for newPDFPrintSupport.Configuration
s.- Returns:
- the default quality setting
-
setDefaultOutputQuality
public static void setDefaultOutputQuality(float quality)
Sets the default output quality level. This is a value between 0 and 1 inclusive, where higher values suggest higher quality output, generally at the cost of larger file size. This is the default quality level for newPDFPrintSupport.Configuration
s.- Parameters:
quality
- the new quality setting- Throws:
java.lang.IllegalArgumentException
- if the quality is not in the range 0 to 1.- See Also:
PDFPrintSupport.Configuration.setQuality(float)
-
setImplementationClassName
public static void setImplementationClassName(java.lang.String className)
Sets the name of the concretePDFPrintSupport.PDFWriter
class to use.- Parameters:
className
- the fully qualified name of a class with a no-arg constructor that implementsPDFPrintSupport.PDFWriter
, ornull
to use the default class
-
getImplementationClassName
public static java.lang.String getImplementationClassName()
Returns the name of the concretePDFPrintSupport.PDFWriter
class to use.- Returns:
- the fully qualified name of a class use to create new
PDFPrintSupport.PDFWriter
s
-
-