The following code works, but when I type in the PDFCreator printer driver, its default name is "Print in Java". (I suspect this is true for Adobe Distiller, since if you do a google search for PDFs using Java Printing , you will get many results.)
Is there a way to change this from "Java Printing" to another line?
package com.example.test.gui; import java.awt.Graphics; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; public class TestPrint implements Printable { @Override public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex != 0) return NO_SUCH_PAGE; graphics.drawString("Hi there", 100, 100); return PAGE_EXISTS; } public void printPage() throws PrinterException { PrinterJob job = PrinterJob.getPrinterJob(); boolean ok = job.printDialog(); if (ok) { job.setPrintable(this); job.print(); } } public static void main(String[] args) { try { new TestPrint().printPage(); } catch (PrinterException e) { e.printStackTrace(); } } }
source share