LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-18-2013, 02:57 PM   #1
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 15.0 (multilib)
Posts: 1,350

Rep: Reputation: 75
Java printing to ps file manipulating file name


I have a program that prints invoices re-iterating through a database to print a page for each entry. If I choose print to file in the print dialog then only the last invoice gets into a ps file, presumably each new invoice overwrites the previous one.

So I want to be able to manipulate the ps file name so at each invoice gets a separate ps file. The filename seems to be stored in PrintJob.mDestination. How can I manipulate this so the program chooses the file name?

Thanks
 
Old 07-19-2013, 09:41 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Are you asking how to do this?
Code:
String filename = Printjob.mDestination + Invoice.InvoiceNumber.toString();
 
Old 07-19-2013, 10:03 AM   #3
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 15.0 (multilib)
Posts: 1,350

Original Poster
Rep: Reputation: 75
No. I think what I need is the opposite.

Quote:
PrintJob.mDestination = PrintJob.mDestination + invoice.invoicenumber.tostring
but I think mDestination is protected.

Last edited by arubin; 07-19-2013 at 10:07 AM.
 
Old 07-19-2013, 11:16 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
When you say PrintJob, you mean java.awt.PrintJob? It looks like you have to use java.awt.Toolkit.getPrintJob() with the JobAttributes argument having had setFileName() called on it.
 
Old 07-19-2013, 12:02 PM   #5
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 15.0 (multilib)
Posts: 1,350

Original Poster
Rep: Reputation: 75
Thanks that looks more like it but I need some hand holding for this. Should I not be using java.awt.PrintJob?
 
Old 07-20-2013, 10:28 AM   #6
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
It's hard to give more than general advice with current level of detail you've posted.

I don't have any personal experience with this, but the Java Printing tutorial suggests using java.awt.print.PrinterJob. I think it's probably best to stick with what's currently working though.
 
1 members found this post helpful.
Old 07-20-2013, 07:02 PM   #7
arubin
Senior Member
 
Registered: Mar 2004
Location: Middx UK
Distribution: Slackware64 15.0 (multilib)
Posts: 1,350

Original Poster
Rep: Reputation: 75
Thank you, that was enough of a pointer to get this working with

Quote:
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
and
Quote:
while(it.hasNext()&i < n2){
i++;
s = (String)it.next();
house = (House)freeholds.get(s);
aset.add(new Destination(new java.net.URI("file:/home/alan/statement"+ house.keyref+ dateText+ ".ps")));
printJob.setPrintable(this, p);
printJob.print(aset);
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Manipulating the data in a file Boopathiraj Linux - General 5 01-31-2013 02:59 PM
C: Manipulating file adresswise derchris Programming 2 03-08-2011 09:17 AM
Accessing file, and manipulating with with folders adamelody Programming 11 03-14-2010 10:32 AM
Need help manipulating a text file lt1776 Linux - Newbie 4 02-16-2010 11:11 AM
GPG - encode file while manipulating output file name itmozart Linux - Newbie 2 10-03-2009 12:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:49 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration