JAVA - Getting path of last printed file

53 views Asked by At

I create a method that print a jTable & methode printTable() save a file as pdf, I Want to get the path of saved file.pdf

there is my part of code :

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

the path i want to use it to rotate the pdf file to landscape the method i created is :

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

can someone help ?

0

There are 0 answers