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;
10 import java.io.ByteArrayInputStream;
11 import java.io.ByteArrayOutputStream;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.io.Reader;
18 public class PDFPrintStreamDoc implements Doc {
20 private InputStream stream;
21 private DocAttributeSet attributeSet;
23 public PDFPrintStreamDoc (ByteArrayOutputStream ostream, DocAttributeSet attributes) {
24 stream = new ByteArrayInputStream(ostream.toByteArray());
25 if (attributes != null) {
26 attributeSet = AttributeSetUtilities.unmodifiableView(attributes);
30 public DocFlavor getDocFlavor () {
31 return DocFlavor.INPUT_STREAM.PDF;
34 public DocAttributeSet getAttributes () {
38 /* Since the data is to be supplied as an InputStream delegate to
39 * getStreamForBytes().
42 public Object getPrintData () throws IOException {
43 return getStreamForBytes();
46 public Reader getReaderForText () {
50 /* Return the print data as an InputStream.
51 * Always return the same instance.
54 public InputStream getStreamForBytes () throws IOException {