У меня есть список файлов RTF, загруженных с сервера.
Я хочу распечатать все эти файлы .rtf одним щелчком мыши без каких-либо диалогов печати или только один.
Пожалуйста, предложите, как мне это сделать.
Я использую Aspose для печати файлов RTF.
Пожалуйста, найдите прикрепленный ниже код для того же самого.
import java.io.File;
import javax.print.attribute.AttributeSet;
import com.aspose.words.Document;
public class DocumentPrinter {
public static void main(String ar[]) throws Exception{
File folder = new File("D:\\projects\\emrs3\\PMS\\Claim\\PaperRTF");
File[] listOfFiles = folder.listFiles();
int j =3 ;
for (int i = 0; i <j ; i++) {
if (listOfFiles[i].isFile()) {
//System.out.println("File " + listOfFiles[i].getName());
Document doc = new Document(listOfFiles[i].getAbsolutePath());
doc.print();
} else if (listOfFiles[i].isDirectory()) {
System.out.println("Directory " + listOfFiles[i].getName());
}
}
}
}
Проблема, связанная с приведенным выше кодом, заключается в том, что он всегда запрашивает диалог печати, поскольку я поместил его doc.print();
в цикл for.
Есть ли способ составить список Document
и распечатать их все за раз.
Спасибо.