Printing to a file
Hi, I'm looking for a way of specifying the output filename programatically if I print to file. Does anyone know how to do this?
Thanks,
Jon.
Ok, take the following code as an example.....
PrinterJob job = PrinterJob.getPrinterJob();
job.print();I do this (assuming I've set up something to actually print) and I have the default printer on my system set to print to file.
So when I fire off the print the print driver then asks what file the ouput should be written too. What I would like is some way to programatically tell the print driver the name of the output file and so avoid the dialog appearing.
Hope that made sense!?
Thanks,
Jon.
Similar Messages
-
How to print a HTML file in browser look using DocPrintJob
Hello guys,
Does anyone know how to print HTML output/file into browser look?
I'm using DocPrintJob and the DocFlavor set to DocFlavor.INPUT_STREAM.AUTOSENSE.
posted below is my code :
public class BasicPrint {
public static void main(String[] args) {
try {
// Open the image file
String testData = "C:/new_page_1.html";
InputStream is = new BufferedInputStream(new FileInputStream(testData));
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
// Find the default service
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
System.out.println(service);
// Create the print job
DocPrintJob job = service.createPrintJob();
Doc doc= new SimpleDoc(is, flavor, null);
// Monitor print job events; for the implementation of PrintJobWatcher,
// see e702 Determining When a Print Job Has Finished
PrintJobWatcher pjDone = new PrintJobWatcher(job);
// Print it
job.print(doc, null);
// Wait for the print job to be done
pjDone.waitForDone();
// It is now safe to close the input stream
is.close();
} catch (PrintException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
static class PrintJobWatcher {
// true iff it is safe to close the print job's input stream
boolean done = false;
PrintJobWatcher(DocPrintJob job) {
// Add a listener to the print job
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobCanceled(PrintJobEvent pje) {
allDone();
public void printJobCompleted(PrintJobEvent pje) {
allDone();
public void printJobFailed(PrintJobEvent pje) {
allDone();
public void printJobNoMoreEvents(PrintJobEvent pje) {
allDone();
void allDone() {
synchronized (PrintJobWatcher.this) {
done = true;
PrintJobWatcher.this.notify();
public synchronized void waitForDone() {
try {
while (!done) {
wait();
} catch (InterruptedException e) {
}the printed ouput for this code will be look like this
<html>
<body>
<div style="page-break-after:'always';
background-color:#EEEEEE;
width:400;
height:70">
testPrint</div>
ABCDEFGHIJK<p>
</p>
</body>
</html>however, the output that i want is the HTML in browser look not HTML code itself.
i've tried to change the DocFlavor into any TEXT_HTML type but it gives error:
sun.print.PrintJobFlavorException: invalid flavor if you guys has any idea or solution, can you share with me... already search in Google but still not found any solution
Thanks in advanced.hi,
do the following
URL url = null;
try
url = new URL("http://www.xyz.com");
catch (MalformedURLException e)
System.out.println("URL not correct " + e.toString());
if (url != null)
getAppletContext().showDocument(url,"_blank"); //shows the page in a new unnamed top level browser instance.
}hope that helpz
cheerz
ynkrish -
Cannot print a PDF file after upgrading to Windows 8.1
Cannot print a PDF file after upgrading to Windows 8.1
I can print anything else from either the Desktop or Start but not a PDF. No error message but just does not print.
Update: down loaded Adobe Reader which runs on the desktop so when I read a PDF file it now runs on the desktop and I can print it.Cannot print a PDF file after upgrading to Windows 8.1
I can print anything else from either the Desktop or Start but not a PDF. No error message but just does not print.
Update: down loaded Adobe Reader which runs on the desktop so when I read a PDF file it now runs on the desktop and I can print it. -
Error (InvalidArgsError) when Printing to a file with Adobe Acrobat 9.0 Interop SDK
Hi,
i am getting a error (Invalid arguments) when trying to print to a file with the Adobe Acrobat SDK 9.0. When i use Adobe Acrobat 7.0 it works correctly. I set the fileName Property as follow:
printerParamsType.InvokeMember("fileName", BindingFlags.SetProperty, null, printerParams, new object[] { path2RawFile });
fileName has the value: /c/temp/Rawfiles/df76eccc-2465-4f60-a4e7-d11d8da6ed64.prn
[9464] System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> System.Runtime.InteropServices.COMException (0x000003E9): InvalidArgsError: Invalid arguments.
thanksHello,
I'm sorry you're having trouble with Acrobat. Unfortunately,
these forums are specific to the
Acrobat.com website and its set of hosted services, and do
not cover the Acrobat family of desktop products.
Any questions related to the Acrobat family of desktop
products would be best suited in the Acrobat Forums:
Link to
Acrobat Forums
Thanks!
Michelle -
On my new Imac I saved some files on the free trial version of Pages, since downloading the full version from Apple, have been unable to save or print from old files saved when using the trial version. Any ideas? Thank you!
My guess is the 30-day trial period has expired but you didn't remove the trial before installing the full version. The files to delete are the iWork ’09 folder from the main HD > Applications; the iWork ’09 folder in HD > Library > Application Support & the individual iWork application plist files found in HD > Users > (your account) > Library > Preferences for each user.
Yvan Koenig has written an AppleScript that removes the files. You can find it on his iDisk in For_iWork > iWork '09 > uninstall iWork '09.zip. -
I am trying to print a PDF file to a legal size paper and I would like for it to fill up the page. How do I do this? I went into the settings and changed it from letter to legal, but it's still printing out the same size. Can someone help me, please?
Are you trying to Print to PDF or are you trying to Print a PDF file to a physical printer?
-
How to Print Post Script Files
Hi All,
I am trying to make a utility software in foxpro that could print post script file on:-
1) Post script printer
2) Non Post Script printer
Operating System Windows 95 & above
Help is requested from all the community members
Reagards
HarshPostScript printer - send it to the printer port e.g. LPT1: with a simple copy.
Non-PostScript printer - you'll need to buy a PostScript RIP, or perhaps use Acrobat Distiller to convert the PostScript to PDF, then print the PDF with Acrobat's API - see the Acrobat SDK. (This is not possible with the free Reader). -
Printing all of file to printer
I have written some code to print from a file to a printer. The problem is that only the first page prints out and the rest do not. Here's more clarification:
Becasue I assume that in a file about 45 lines make up a normal page I am able to get the right amount of pages to be displayed in the dialog and to print, but still, the first page is printed fine and the rest are blank. I am baffled as to what I'm doing wrong. I have also noticed that many other people have had the same problem, but with no solutions. It seems as though the print method of the printable interface is called twice for every page with a different graphics element, and I don't know if that is what is causing my problem or not. I am using the jdk 1.3.1 - is that a problem? Here is my code and if anyone can propose a solution to the blank pages problem I would be very grateful!
import java.awt.*;
import java.awt.print.*;
import java.io.*;
import javax.swing.*;
public class MyPrinter implements Runnable {
protected PrinterJob job;
protected MyPrintable myPrint = new MyPrintable();
protected MyPageable myPage = new MyPageable();
protected MyDialog dialog = new MyDialog();
protected RandomAccessFile raf;
//protected Startmenu mainMenu;
protected String fileName;
protected File printFile;
protected int numPages = 0;
public MyPrinter() { } // end constructor
public void printFile(String name) {// gives error message if file doesn't exist!
printFile = new File(name);
fileName = name;
if((printFile.exists()) && (printFile.canRead())) {
Thread myThread = new Thread(this);
myThread.start();
} // end if
else {
dialog.showError("Datei "+fileName+" existert nicht!", "Fehler mit Drucken");
} // end else
} // end printFile
public void run() {
numPages = findNumPages();
job = PrinterJob.getPrinterJob();
job.setPageable(myPage); // this is an instance of Pageable
if(job.printDialog()) { // user didn't cancel the printing
try {
job.print();
try { raf.close(); } // end try
catch(IOException e) { dialog.showError("Fehler: "+e.getMessage(), "Problem");}
} // end try
catch (PrinterException pe) {dialog.showError("Fehler: "+pe.getMessage(), "Problem");}
} // end if
} // end run
private int findNumPages() {
try {
numPages = 0;
raf = new RandomAccessFile(fileName, "r");
int fileLength = (int)printFile.length();
int lineNumber = 0;
while((int)raf.getFilePointer() < fileLength) {
lineNumber = 0;
while((((int)raf.getFilePointer()) < fileLength) && (lineNumber < 45)) {
raf.readLine();
lineNumber++;
} // end while loop
numPages++;
} // end while loop
raf.seek(0);
} // end try
catch(IOException e) { dialog.showError("Fehler: "+e.getMessage(), "Problem");}
return numPages;
} // end findNumPages
public class MyPageable implements Pageable {
public Printable getPrintable(int pageIndex) { return myPrint; } // end getPrintable
public PageFormat getPageFormat(int pageIndex) {
PageFormat pf = new PageFormat();
pf.setOrientation(PageFormat.PORTRAIT);
return pf;
} // end getPageFormat
public int getNumberOfPages() {
return numPages; // test
//return ((int)printFile.length()/4000); // assume 4KB per page
} // end getNumberOfPages
} // end MyPageable class
public class MyPrintable implements Printable {
private Font fnt = new Font("Serif", Font.PLAIN, 11);
protected int lastPageIndexChecked = -1;
public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {
// pageIndex # corresponds to page number # + 1
pf.setOrientation(PageFormat.PORTRAIT);
if (pageIndex >= numPages) { return Printable.NO_SUCH_PAGE; } // end if
else {
g.setFont(fnt);
g.setColor(Color.black);
String oneLine;
int x = 75, y = 80, lineNumber = 0;
try {
int fileLength = (int)printFile.length();
while((((int)raf.getFilePointer()) < fileLength) && (lineNumber < 45)) {
oneLine = raf.readLine();
lineNumber++;
g.drawString(oneLine, x, y);
y += 15;
} // end while loop
} // end try
catch(IOException e) { dialog.showError("Fehler: "+e.getMessage(), "Problem");}
return Printable.PAGE_EXISTS;
} // end else
} // end print
} // end MyPrintable class
} // end MyPrinter classI was actually able to solve the problem! The print function of the Printable interface is called twice for every page, which was what prevented the pages after the first (the graphics for the other pages) from somehow getting all the info they needed, etc. So here is my updated code for anyone who is having similar problems and needs a similar solution: :)
import java.awt.*;
import java.awt.print.*;
import java.io.*;
import javax.swing.*;
public class MyPrinter implements Runnable {
protected PrinterJob job;
protected MyPrintable myPrint = new MyPrintable();
protected MyPageable myPage = new MyPageable();
protected MyDialog dialog = new MyDialog();
protected RandomAccessFile raf;
protected String fileName;
protected File printFile;
protected int numPages = 0;
protected int[] lastFilePositions;
public MyPrinter() { } // end constructor
public void printFile(String name) {// gives error message if file doesn't exist!
printFile = new File(name);
fileName = name;
if((printFile.exists()) && (printFile.canRead())) {
Thread myThread = new Thread(this);
myThread.start();
} // end if
else {
dialog.showError("Datei "+fileName+" existert nicht!", "Fehler mit Drucken");
} // end else
} // end printFile
public void run() {
numPages = findNumPages();
job = PrinterJob.getPrinterJob();
job.setPageable(myPage); // this is an instance of Pageable
if(job.printDialog()) { // user didn't cancel the printing
try {
job.print();
try { raf.close(); } // end try
catch(IOException e) { dialog.showError("Fehler: "+e.getMessage(), "Problem");
System.exit(0);
} // end catch
} // end try
catch (PrinterException pe) {dialog.showError("Fehler: "+pe.getMessage(), "Problem");
System.exit(0);
} // end catch
} // end if
} // end run
private int findNumPages() {
try {
numPages = 0;
raf = new RandomAccessFile(fileName, "r");
int fileLength = (int)printFile.length();
int lineNumber = 0;
while((int)raf.getFilePointer() < fileLength) {
lineNumber = 0;
while((((int)raf.getFilePointer()) < fileLength) && (lineNumber < 45)) {
raf.readLine();
lineNumber++;
} // end while loop
numPages++;
} // end while loop
raf.seek(0);
lastFilePositions = new int[numPages];
intializeLastFilePositions();
} // end try
catch(IOException e) { dialog.showError("Fehler: "+e.getMessage(), "Problem");
System.exit(0);
} // end catch
return numPages;
} // end findNumPages
private void intializeLastFilePositions() {
for(int i = 0; i < lastFilePositions.length; i++) {
lastFilePositions[i] = 0;
} // end for loop
} // end intializeLastFilePositions
public class MyPageable implements Pageable {
public Printable getPrintable(int pageIndex) { return myPrint; } // end getPrintable
public PageFormat getPageFormat(int pageIndex) {
PageFormat pf = new PageFormat();
pf.setOrientation(PageFormat.PORTRAIT);
return pf;
} // end getPageFormat
public int getNumberOfPages() {
return numPages; // test
//return ((int)printFile.length()/4000); // assume 4KB per page
} // end getNumberOfPages
} // end MyPageable class
public class MyPrintable implements Printable {
private Font fnt = new Font("Serif", Font.PLAIN, 11);
protected int startAtLineNumber = 0;
public int print(Graphics g, PageFormat pf, int pageIndex)
throws PrinterException {
// pageIndex # corresponds to page number # + 1
pf.setOrientation(PageFormat.PORTRAIT);
if(pageIndex > numPages) return NO_SUCH_PAGE;
else {
if(pageIndex == 0) { startAtLineNumber = 0; } // end if
else {
startAtLineNumber = lastFilePositions[pageIndex-1];
} // end else
g.setFont(fnt);
g.setColor(Color.black);
String oneLine;
int x = 75, y = 80, lineNum = 0;
try {
raf.seek(startAtLineNumber);
int fileLength = (int)printFile.length();
while((((int)raf.getFilePointer()) < fileLength) && (lineNum < 45)) {
oneLine = raf.readLine();
if(oneLine.length() > 130) { // wrap lines if one line is too long
String secondLine = oneLine.substring(130, oneLine.length());
oneLine = oneLine.substring(0, 130);
g.drawString(oneLine, x, y);
y += 15;
g.drawString(secondLine, x, y);
y += 15;
} // end if
else { // line fit on one line
g.drawString(oneLine, x, y);
y += 15;
} // end else
lineNum++;
} // end while loop
lastFilePositions[pageIndex] = (int)raf.getFilePointer();
} // end try
catch(IOException e) { dialog.showError("Fehler: "+e.getMessage(), "Problem");
System.exit(0);
} // end catch
return Printable.PAGE_EXISTS;
} // end else
} // end print
} // end MyPrintable class
} // end MyPrinter class -
How do I download and print a pdf file in osx mountain lion
How do I download and print a pdf file?
control click on your PDF to download option
Open it on your desktop Command-P is the short cut for print option. -
How to Print a PDF file from within a ABAP ( from gui input)
Hi champions,
This is Client requirement:
"We need to print a PDF file from within a ABAP"
We first need to test whether it is even feasible, and then if it
is, then write a small test ABAP which can accept a PDF file
name as input (from GUI) and then print it to a SAP print
device (printer).
Please Can any body help me on this.......
It's urgent
Thanks
BasuCheck following blog for PDF output from SAP
/people/thomas.jung3/blog/2005/04/28/setting-up-an-adobe-writer-for-abap-output
anya -
I am using Numbers app for the ipad and it has been working absolutely fine but now, when I want to email a spreadsheet as a PDF via the 'share and print' option, the file now doesn't appear as an attachment to the recipient. Any ideas please?
Hi mafiose15,
Thanks for visiting Apple Support Communities.
Restoring your iPod to factory settings is the best way to try and get it back to working order. You can use the instructions below to restore it:
How to restore iPod
Verify that you have an active Internet connection, because you may need to download new versions of the iTunes and iPod Software.
Download and install the latest version of iTunes if necessary.
Open iTunes. Connect your iPod to your computer using the USB or FireWire cable that came with your iPod.
After a few moments, your iPod will appear in the Source panel in iTunes.
Select your iPod in the Source panel. You will see information about your iPod appear in the Summary tab of the main iTunes window.
Click Restore.
If you are using a Mac, you will be asked to enter an administrator’s name and password.
A progress bar will appear on the computer screen, indicating that stage one of the restore process has begun. When this stage is done, iTunes will present one of two messages with instructions specific to the iPod model you are restoring.
Disconnect iPod and connect it to iPod Power Adapter (typically applies to older iPod models).
Leave iPod connected to computer to complete restore (typically applies newer iPod models).
During stage two of the restore process, the iPod displays an Apple logo as well as a progress bar at the bottom of the display. It is critical that the iPod remain connected to the computer or iPod power adapter during this stage.
Note: The progress bar may be difficult to see, because the backlight on the iPod display may be off.
After stage two of the restore process is complete, the iTunes Setup Assistant window will appear. It will ask you to name your iPod and choose your syncing preferences, as it did when you connected your iPod for the first time.
You can find the instructions in this article:
Restoring iPod to factory settings
http://support.apple.com/kb/ht1339
All the best,
Jeremy -
Hello,
I'm looking for a way to print a .pdf file from sap . The file was created manualy and is in a newtwork folder.
I have to send the print to a network printer . Is it possible to use the AcroRd32.exe as a command line?
Thank you.hii,
try this
CONVERT_OTFSPOOLJOB_2_PDF
http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm
PDF - Printing a PDF file from ABAP or SAP Script
regards,
Sri. -
How can i get rid of the print dialog box when using api to print an html file
i am using the systemshell.vi provided by labview the VI is working fine but it will open a dialog box for printer selection and properties. i would like to hide that dialog box and have it print to the default printer with the default properties
ShellExec is part of lvwutil and merely calls a function in Shell32.dll. There is nothing about the function call that controls the display of the printer dialog. I think that what shell32.dll does when it prints (just like right clicking on the file) is print the file according to what is defined about that file type in Windows Folder Options. On my Win2K system, the print application is defined as "C:\Program Files\Microsoft Office\Office\msohtmed.exe" /p %1. If I remove the /p, then Word starts up and in order to print, I get a printer dialog when choosing Print from the File menu. So it seems like the printer dialog is entirely dependant on the application that does the printing. I get no dialog when I use the VI to print a .txt file. I
nstead of using shell32, you might want to try some ActiveX method or property of an application like Internet Explorer that can open and print an html file. -
Recently I got a new laptop, with excel 2010 version and acrobat 9 standard.
I could no longer print (save as) an excel file with multiple tabs into a pdf file with bookmarks.
My old computer has excel 2007 version and acrobat 9 standard.
Print an excel file into pdf with bookmarks was a piece of cake.
Both machine has the same add-in -- Acrobat PDFMaker Office COM addin
Thanks if anyone could help me with this.
TomYou need to upgrade Acrobat to a newer version.
On Thu, Oct 30, 2014 at 4:12 PM, excel-pdf-bookmarks < -
How to print an Doc file(MS Word File)on a printer in JAVA
Hi.I am Prakash.
Folowing is the code that i have used to print an doc file on a printer. Problem is that , when i run this code it will provide me an printout of a doc file.,but not in well formate as the actual formate of the file. If any one tried this before plz help me.Thanks
import java.lang.reflect.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Graphics2D;
import java.io.*;
import javax.swing.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;
public class BasicPrint {
JFrame frame;
JButton btn;
private boolean PrintJobDone = false;
protected void MakeGui() {
frame = new JFrame("PrintService");
btn = new JButton("Cancel Print Job");
btn.disable();
frame.getContentPane().add(btn, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
BasicPrint(String FileToPrint, String pMode) {
try {
MakeGui();
File baseDir = new File("d:/doc");
File outDir = new File(baseDir, FileToPrint);
// Open the image file
InputStream is = new BufferedInputStream(new FileInputStream(
outDir));
// Find the default service
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
//DocFlavor flavor = new DocFlavor("application/msword", "java.io.InputStream");
//DocFlavor docFlavor = new DocFlavor("application/vnd.ms-word", "java.io.InputStream");
if (pMode != null && pMode.equalsIgnoreCase("PS"))
flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
else if (pMode != null && pMode.equalsIgnoreCase("PDF"))
flavor = DocFlavor.INPUT_STREAM.PDF;
else if (pMode != null && pMode.equalsIgnoreCase("JPG"))
flavor = DocFlavor.INPUT_STREAM.JPEG;
else if (pMode != null && pMode.equalsIgnoreCase("GIF"))
flavor = DocFlavor.INPUT_STREAM.GIF;
else if (pMode != null && pMode.equalsIgnoreCase("PNG"))
flavor = DocFlavor.INPUT_STREAM.PNG;
else if (pMode != null && pMode.equalsIgnoreCase("PCL"))
flavor = DocFlavor.INPUT_STREAM.PCL;
else if (pMode != null && pMode.equalsIgnoreCase("RAW"))
flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
else if (pMode != null && pMode.equalsIgnoreCase("TXT16"))//**** *********
flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16;
System.out.println("****ACTIVE***");
else if (pMode != null && pMode.equalsIgnoreCase("TXTBE"))//****
flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16BE;
else if (pMode != null && pMode.equalsIgnoreCase("TXTHOST"))//***
flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST;
else if (pMode != null && pMode.equalsIgnoreCase("TXT8"))
flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8;
else if (pMode != null && pMode.equalsIgnoreCase("TXTASCI"))
flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII;
else if(pMode != null && pMode.equalsIgnoreCase("TXTLE"))
flavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_16LE; //*******
else if(pMode != null && pMode.equalsIgnoreCase("SEVICE"))
flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
String type = flavor.getMediaType();
System.out.println("Type ="+ type);
//IMPRIMIR prakashCV.doc TXT text/plain; charset="utf-16le"; class="java.io.InputStream"
System.err.println("* IMPRIMIR " + FileToPrint + " " + pMode + " "
+ flavor);
PrintService dservice = PrintServiceLookup
.lookupDefaultPrintService();
PrintService[] services = PrintServiceLookup.lookupPrintServices(
flavor, null);
if (services == null || services.length < 1)
services = PrintServiceLookup.lookupPrintServices(null, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(1));
aset.add(OrientationRequested.PORTRAIT);
// aset.add(MediaTray.MAIN);
aset.add(Sides.ONE_SIDED);
aset.add(MediaSizeName.ISO_A4);
PrintService service = ServiceUI.printDialog(
(GraphicsConfiguration) null, 60, 60, services,
(PrintService) dservice, (DocFlavor) flavor, aset);
if (service != null) {
// Create the print job
final DocPrintJob job = service.createPrintJob();
Doc doc = new SimpleDoc(is, flavor, null);
// Monitor print job events; for the implementation of
// PrintJobWatcher,
PrintJobWatcher pjDone = new PrintJobWatcher(job);
if (job instanceof CancelablePrintJob) {
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
CancelablePrintJob cancelJob = (CancelablePrintJob) job;
try {
cancelJob.cancel();
} catch (PrintException e) {
// Possible reason is job was already finished
btn.enable();
try {
// Print it
job.print(doc, (PrintRequestAttributeSet) aset);
} catch (PrintException e) {
e.printStackTrace();
System.err.println("* Impresion Realizada - Esperando ..");
// Wait for the print job to be done
pjDone.waitForDone();
// It is now safe to close the input stream
is.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
synchronized (BasicPrint.this) {
PrintJobDone = true;
BasicPrint.this.notify();
} catch (Exception e) {
e.printStackTrace();
public synchronized void waitForDone() {
try {
while (!PrintJobDone) {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
public static void main(String[] args) {
try {
//args[0]="t";
//args[1]="rr";
// if (args.length < 1) {
// System.err.println("\nSintaxis:\n\n java BasicPrint FileToPrint [pMode]\n");
// System.exit(0);
BasicPrint bp = null;
//if (args.length < 2){
//bp = new BasicPrint(args[0], null);
//}else{
//bp = new BasicPrint(args[0], args[1]);
bp = new BasicPrint("prakashCV.doc","SEVICE"); //****/***
bp.waitForDone();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
class PrintJobWatcher {
// true iff it is safe to close the print job's input stream
boolean done = false;
int lastEvent = 0;
PrintJobWatcher(DocPrintJob job) {
// Add a listener to the print job
job.addPrintJobListener(new PrintJobAdapter() {
public void printJobRequiresAttention(PrintJobEvent pje) {
lastEvent = pje.getPrintEventType();
System.err
.println("* La impresora requiere de su Atencion ! * "
+ pje);
// allDone();
public void printDataTransferCompleted(PrintJobEvent pje) {
lastEvent = pje.getPrintEventType();
System.err
.println("* Transferencia de datos a la impresora OK. * "
+ pje);
// allDone();
public void printJobCanceled(PrintJobEvent pje) {
lastEvent = pje.getPrintEventType();
System.err.println("* Trabajo de impresion CANCELADO ! * "
+ pje);
allDone();
public void printJobCompleted(PrintJobEvent pje) {
lastEvent = pje.getPrintEventType();
System.err.println("* Impresion completa OK. * " + pje);
allDone();
public void printJobFailed(PrintJobEvent pje) {
lastEvent = pje.getPrintEventType();
System.err.println("* ERROR en la Impresion ! * " + pje);
// allDone();
public void printJobNoMoreEvents(PrintJobEvent pje) {
lastEvent = pje.getPrintEventType();
System.err
.println("* No mas eventos de impresion * " + pje);
allDone();
void allDone() {
synchronized (PrintJobWatcher.this) {
done = true;
PrintJobWatcher.this.notify();
/** Description of the Method */
public synchronized void waitForDone() {
try {
while (!done) {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}Hi Maxpkh
Do you mean attachment? You can't do that with free Adobe Reader you need Acrobat to do this.
~Deepak -
How to print a text file with pagebreak.......
hi to all,
i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.hi to all,
i am new in java and i want to do print a text file with page break. that text file is converted from html view page with help of htmlconveter class and i want to set page break in the text file.ASCII 12 is not work properly.its not break a page in proper manner.plz reply soon.
Maybe you are looking for
-
Hello dps team, A few weeks ago we renewed our dps licence. Now we want to release our newest issue but we can't. Following error message appears "At the attempt to release the folio creates an error. The process could not be started. Please try agai
-
Converting analog to digital video
Does anybody know a cheap way to convert analog video (from a VHS) to digital video that can be burned on a DVD? A converter box is probably my best option as I have no digital camcorder, but I was looking for one under $150. So far the only ones I c
-
Non US date format within Workspace and Guides
Is is possible to change the date format displayed within the workspace and Guides to a non US date format? This really is a show stopper for us as our standard date format is DD/MM/YYYY and the forms won't be usable for our staff if they are not in
-
CATS Screen dumps when navigating between prev and foll weeks in ESS portal
The medical leave absence type MEDICAL LEAVE @1/2 PAY(13) is the only allowed by time administrators to enter through transaction CAT2 and not through ESS. Once entered,this appears in your time entry in ESS as a disabled entry. However once you navi
-
So You Think Your Computer's Not Powerful Enough For FCE/FCP !!!!!
It's NOT a question - just some sobering thoughts! How many times do we get worried owners asking whether the Mac they have or the one they intend to get will have enough power to operate FCE/FCP? So I trawled through the history books - otherwise kn