Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8705693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:25:42+00:00 2026-06-13T03:25:42+00:00

When trying to print a JPEG file with the Java code below on Mac

  • 0

When trying to print a JPEG file with the Java code below on Mac OS X 10.8.0 I get
the error message:

Error: pstopdffilter/pstocupsraster failed with err number 31000

A Gooogle search brings suggestions that seem to hint that the problem is not directly to Java
e.g.
http://forum.parallels.com/showthread.php?t=106337

/**
 * http://stackoverflow.com/questions/7843338/printing-a-tif-file
 * 
 * @param graphicFile
 * @throws PrintException
 * @throws IOException
 */
public void printGraphic(File graphicFile) throws PrintException,
        IOException {

    PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    pras.add(new Copies(1));
    pras.add(Chromaticity.COLOR);
    pras.add(MediaSizeName.ISO_A4);
    PrintService pss[] = PrintServiceLookup.lookupPrintServices(
            DocFlavor.INPUT_STREAM.JPEG, pras);

    if (pss.length == 0)
        throw new RuntimeException("No printer services available.");

    PrintService ps = pss[0];
    System.out.println("Printing to " + ps);
    DocPrintJob job = ps.createPrintJob();
    FileInputStream fin = new FileInputStream(graphicFile);
    Doc doc = new SimpleDoc(fin, DocFlavor.INPUT_STREAM.JPEG, null);
    job.print(doc, pras);
    fin.close();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T03:25:44+00:00Added an answer on June 13, 2026 at 3:25 am

    As a workaround I would suggest to use jpeg instead of tiff.

    /**
     * http://stackoverflow.com/questions/5338423/print-a-image-with-actual-size
     * -in-java
     * 
     * @param graphicFile
     */
    public void printG(File graphicFile) {
        final Image img = new ImageIcon(graphicFile.getAbsolutePath())
                .getImage();
        PrinterJob printJob = PrinterJob.getPrinterJob();
        Printable printable = new Printable() {
            public int print(Graphics graphics, PageFormat pageFormat,
                    int pageIndex) throws PrinterException {
                if (pageIndex != 0) {
                    return NO_SUCH_PAGE;
                }
                graphics.drawImage(img, 0, 0, img.getWidth(null),
                        img.getHeight(null), null);
                return PAGE_EXISTS;
            }
        };
        printJob.setPrintable(printable, getPageFormat());
        if (printJob.printDialog()) {
            try {
                printJob.print();
            } catch (Exception prt) {
                handle(prt);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error when trying to upload a .JPG file. Warning: getimagesize()
I'm trying to get all the data from image file (jpg/jpeg/gif/png/bmp etc.) use Lua's
Im trying print Excel file data on a page. To do it i used
I am trying to print a single tiff file with multiple frames. However if
I am trying to get a list of file extensions based upon the first
I'm trying to get ffmpeg to encode several individual JPEG images into a video
In the below code I am trying to populate the JSON array with JSON
Im trying to print the realtime output based on user input for a search.
I'm trying to print a number of '+' characters followed by a number of
I'm trying to print a large string to alivepdf. I'm splitting the string by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.