printing #2

  • Follow


I am trying to print a file. I need to display the print dialog so that
the user can choose the correct printer. I got all this working.

My prolem occurs when the user chooses to print to a file (out.prn).
The source file is sent to the printer instead.

Any suggestions are appreciated.

0
Reply pdeline (3) 10/4/2006 7:00:36 PM

"pete231" <pdeline@crossroads.com> wrote in message 
news:1159988435.965459.281720@i3g2000cwc.googlegroups.com...
>I am trying to print a file. I need to display the print dialog so that
> the user can choose the correct printer. I got all this working.
>
> My prolem occurs when the user chooses to print to a file (out.prn).
> The source file is sent to the printer instead.
>
> Any suggestions are appreciated.
>

That's easy. Send the correct file instead of the source file.

My guess is that line 42 of xbquj.java is wrong.
-- 
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project


0
Reply Fred 10/5/2006 3:26:05 PM


>
> That's easy. Send the correct file instead of the source file.
>
> My guess is that line 42 of xbquj.java is wrong.


I don't understand this replay. Nor do I know what xbquj.java is.

0
Reply pete231 10/5/2006 7:30:06 PM

Don't remove the original question in a reply!
I have restored it:
>>>"pete231" <pdeline@crossroads.com> wrote in message
>>>news:1160076606.456953.260820@b28g2000cwb.googlegroups.com...
>>>I am trying to print a file. I need to display the print dialog so that
>>>the user can choose the correct printer. I got all this working.
>>>
>>>My prolem occurs when the user chooses to print to a file (out.prn).
>>>The source file is sent to the printer instead.
>>>
>>>Any suggestions are appreciated.

>>
>> That's easy. Send the correct file instead of the source file.
>>
>> My guess is that line 42 of xbquj.java is wrong.
>>
>
> I don't understand this replay. Nor do I know what xbquj.java i

Well, I made a wild guess at which file of yours had the problem.
Since you didn't include any code, I had to guess. Perhaps my
guess wasn't quite correct. I haven't been a very good mind reader
these past few months.

If you showed us what you actually tried, maybe we could provide some help.
-- 
Fred L. Kleinschmidt
Boeing Associate Technical Fellow
Technical Architect, Software Reuse Project


0
Reply Fred 10/5/2006 8:42:53 PM

>
> Well, I made a wild guess at which file of yours had the problem.
> Since you didn't include any code, I had to guess. Perhaps my
> guess wasn't quite correct. I haven't been a very good mind reader
> these past few months.
>

This works. It sends the file to the printer the users selects. If they
select "print to file" it still routes the file to the printer.

public boolean print(File file)
{
    PrinterJob printerjob = PrinterJob.getPrinterJob();

    if ( !printerjob.printDialog() )
      return false;

    try
    {
      printerjob.getPrintService().createPrintJob().print( new
SimpleDoc(
          new FileInputStream( file ),
          DOC_FLAVOR,
          new HashDocAttributeSet() ),
          new HashPrintRequestAttributeSet() );

      return true;
    }
    catch ( Exception e )
    {
      e.printStackTrace();
      return false;
    }
}

0
Reply pete231 10/5/2006 10:37:42 PM

4 Replies
105 Views

(page loaded in 0.086 seconds)

Similiar Articles:













7/20/2012 3:23:17 PM


Reply: