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");
        }
    }

我想用它来将pdf文件旋转到横向的路径 我创建的方法是:

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 (将#修改为@)