public static void main(String[] args) throws IOException { FileInputStream in = new FileInputStream(“”); Doc doc = new SimpleDoc(in, DocFlavor. private boolean printData(PrintService printService, String printText) { try { SimpleDoc doc; doc = new SimpleDoc(es(), vor . DocPrintJob; import xception; import ervice; import erviceLookup; import Doc; import.

Author: Muzragore Vudogar
Country: Benin
Language: English (Spanish)
Genre: Sex
Published (Last): 27 October 2017
Pages: 386
PDF File Size: 1.22 Mb
ePub File Size: 17.38 Mb
ISBN: 604-7-91396-671-9
Downloads: 90327
Price: Free* [*Free Regsitration Required]
Uploader: Dubei

This tiny ad doesn’t respect those rules: I don’t think there are printers or printer drivers that understand PDF files at least not in the standard JREso this approach likely won’t work. Originally posted by Ulf Dittmer: Our naming policy sikpledoc one of our two rules the other is “Be Nice”.

I have set the printer defaults to: IllegalArgumentException – if flavor or printData is nullor the printData does not correspond to the specified doc flavor–for example, the data is not of the type specified as the representation in the DocFlavor. Adobe reeader not designed for automated printing and sijpledoc no extra features such as setting up a printer propertys, scalling page, page count, and other print options.

SimpleDoc (Java Platform SE 7 )

This javx the effort of the volunteers at the Ranch and wastes people’s valuable time. Object getPrintData Obtains the print data representation object that contains this doc object’s piece of print data in the format corresponding to the supported doc flavor.

To verify this is the case, try the following: Obtains the set of printing attributes for this doc object. Canon iP series that is the output. Thanks for your help. I don’t think there are printers or printer drivers that understand PDF files Sure there are – or the company I work for wouldn’t have a business! Print PDFs you can see the input file is “some. The file is created as an A4 document.

Related Posts  DS12887 DATASHEET PDF

That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Sikpledoc do I know the input stream is ready? InputStream The doc’s print data representation pprint is obtained. The following code worked perfectly for me, except for some page margin which is of course can be adjusted:. When you say this code works for me, does that mean it works for you to be able to print pdfs?

Simpleddoc can handle all of the presently defined “pre-defined” doc flavors defined as static variables in the DocFlavor class. Problems in printing a PDF file in java. I’m able to figure out the rest of the pieces, in regards to user input and determining pages of the pdf, except I don’t see how I will be able to print the pdf.

Similar Threads

Somebody suggested using a command line utility: This library can render PDFs; it should be possible to adapt it to print them as well if it can’t do that out of the box.

However, if the print kava representation object is itself a Reader then the print data representation object is simply returned. I’ve also changed my username over as well. It prints fine, but it just prints out tons of characters, not the actual document I’m sending to the printer. Reader getReaderForText Obtains a reader for extracting character print data from this doc.

Java Examples for javax.print.SimpleDoc

Why is it like that? Low-end consumer printers typically won’t do PDF directly; larger office and production printers mostly will do PDF and lots of other formats directly. Print data representation object. The Doc implementation is required to support this method if the DocFlavor has one of the following print data representation classes; otherwise this method returns null: If that doesn’t work, you could try the component Ulf pointed out and Java 2D printing.

Post Your Answer Discard By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued si,pledoc of the website is subject to these policies.


The getPrintData method returns an instance of the representation class whose name is given by getDocFlavor. As Ulf mentions, this code is dependent on your printer being able to direct-print a PDF. Thanks for the heads up. Obtains a reader for extracting character print data from this doc.

Java Examples for Doc

Below is another code based on my research: I want to print a document using java however, the program is successful but my printer is not printing anything.

I’m sorry, my bad. The following code worked perfectly for me, except for some page margin which is of course can be adjusted: By the way, could you take a moment and change your displayed name to your real or at least real-sounding first and last name? Description copied from interface: Whose rules are you playing by? Stack Overflow works best with JavaScript enabled.

If an input stream cannot be provided because this doc primt not meet the criteria stated above, null is returned. My LaserJet has this capability. I ain’t asking for API doc.

The code pure Java solution is given below: Thank you very much, and welcome to JavaRanch. Reader The doc’s print data representation object is used to construct and return a Reader for reading the print data as a stream of characters from the print data representation object.

So I was able to test that code, and I’m getting jaava same as I got before.