如何解决JAVA - 获取上次打印文件的路径
我创建了一个打印 jTable & methode printTable()
将文件保存为 pdf 的方法,
我想获取保存文件的路径.pdf
这是我的代码部分:
public static void printTable()
{
messageformat Header = new messageformat("Password List");
messageformat footer = new messageformat("PAGE # {0}");
PrintRequestAttributeSet set = new HashPrintRequestAttributeSet();
set.add(OrientationRequested.LANDSCAPE);
try {
Boolean Printing = ListPasss.print(JTable.PrintMode.FIT_WIDTH,Header,footer);
if (Printing )
{
System.out.println("succefully..");
}
else
{
System.out.println("Cancelled..");
}
} catch (PrinterException e) {
System.out.println("error");
}
}
public static void RotatePdf()
{
try
{
// load original PDF
PDFDocument pdfDoc = new PDFDocument ("Path of printed file",null);
// Loop through all pages
for (int i = 0; i < pdfDoc.getPageCount(); i++)
{
// get page in the original PDF
pdfpage page = pdfDoc.getPage(i);
// change the page rotation to flip it by 90 degrees
page.setPageRotation(90);
}
// print the document
pdfDoc.print(new PrintSettings());
// save the document
pdfDoc.saveDocument ("Path of printed file/modified");
}
catch (PDFException | PrinterException | IOException t)
{
System.out.println("Not Rotated");
}
}
有人可以帮忙吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。