Upload *.pdf file to a JSP page

Asked

Viewed 294 times

0

I was able to open a page of a *.pdf file in Acrobat by java from this code:

try {

        File pdfFile = new File("C:\\testes\\teste.pdf");
        if (pdfFile.exists()) {
            String cmd = "C:\\Program Files (x86)\\Adobe\\Acrobat Reader DC\\Reader\\AcroRd32.exe";
            String param1 = "/A";
            String param2 = "page=2";

            String[] cmds = new String[]{cmd, param1, param2, pdfFile.getAbsolutePath()};
            Process p = new ProcessBuilder(cmds).start();
            /*if (Desktop.isDesktopSupported()) {
                //Desktop.getDesktop().open(pdfFile);

            } else {
                System.out.println("Awt Desktop não disponível");
            }*/

        } else {
            System.out.println("Ficheiro inexistente");
        }

        System.out.println("Done");

    } catch (Exception ex) {
        ex.printStackTrace();
    }

It is possible to do the same by browser with JSP?

  • <a href = 'address File'>Click here< a>?

  • The point is that I need it to automatically open the PDF of the folder without a button

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.