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 6756943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:35:10+00:00 2026-05-26T13:35:10+00:00

Currently I am using this code but its throwing PrintJobFlavorException . This is my

  • 0

Currently I am using this code but its throwing PrintJobFlavorException. This is my code help me out fixing this one:

public class PJUtil {
    public static void main(String[] args) throws Exception {
        DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
        Writer output = null;
        String text = "printing in pdfPrinting in Java ";
        File file = new File("C:\\CMPSup_AL_.PDF");
        output = new BufferedWriter(new FileWriter(file));
        output.write(text);
        output.close();
        InputStream is = new BufferedInputStream(new FileInputStream(file));
        PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        DocPrintJob job = service.createPrintJob();
        Doc doc = new SimpleDoc(is, flavor, null);
        PrintJobWatcher pjDone = new PrintJobWatcher(job);
        job.print(doc, null);
        pjDone.waitForDone();
        is.close();
    }
}

and exception is

Exception in thread "main" sun.print.PrintJobFlavorException: invalid flavor
    at sun.print.Win32PrintJob.print(Win32PrintJob.java:327)
    at Collections.PrinterJobUtil.main(PrinterJobUtil.java:89)
  • 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-05-26T13:35:11+00:00Added an answer on May 26, 2026 at 1:35 pm

    your printer may not support text based representation. Have a look at this article java printing, specially page 5.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using this type of mod_rewrite code for all my page...but i
I'm currently using this code to calculate the sunrise / sunset times. (To be
I am a rank beginner in C#. I am currently using this code: objGraphics.Clear(SystemColors.Control);
I am currently using code similar to this: try { // IE ONLY var
Using dotnet 2.0. I currently have code like this : DataView dv = new
i currently use this code to delete a folder and its contents: string tempFolder
I have a class like this one: public class Foo { public readonly int
Why does this code fail to display the category name Apples using the current
I'm currently using this jQuery validate plugin and having an issue in IE where
I'm currently using this method in calling batch files in vb.net: Private Sub Button3_Click(ByVal

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.