2 * PDFPrintStreamDoc.java
4 package net.sf.openrocket.gui.print;
6 import javax.print.Doc;
7 import javax.print.DocFlavor;
8 import javax.print.attribute.AttributeSetUtilities;
9 import javax.print.attribute.DocAttributeSet;
13 * This class implements a javax Doc specifically for PDF printing. All reports in OpenRocket are PDF (iText) based.
15 public class PDFPrintStreamDoc implements Doc {
17 /** The source stream of the PDF document. */
18 private InputStream stream;
20 /** The document's attributes. */
21 private DocAttributeSet attributeSet;
26 * @param ostream an output stream representing the pdf doc
27 * @param attributes the attributes of the document
29 public PDFPrintStreamDoc (ByteArrayOutputStream ostream, DocAttributeSet attributes) {
30 stream = new ByteArrayInputStream(ostream.toByteArray());
31 if (attributes != null) {
32 attributeSet = AttributeSetUtilities.unmodifiableView(attributes);
42 public DocFlavor getDocFlavor () {
43 return DocFlavor.INPUT_STREAM.PDF;
47 public DocAttributeSet getAttributes () {
51 /* Since the data is to be supplied as an InputStream delegate to
52 * getStreamForBytes().
55 public Object getPrintData () throws IOException {
56 return getStreamForBytes();
60 * Intentionally null since the flavor is PDF.
65 public Reader getReaderForText () {
69 /* Return the print data as an InputStream.
70 * Always return the same instance.
73 public InputStream getStreamForBytes () throws IOException {