0

次のようにPDFを表示して<iframe>います:

<iframe src="/itextPdfServlet" height="600px" width="700px"></iframe>

この印刷オプションを無効にしたいと思います。どうすればこれを達成できますか?

私のサーブレット

protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        String fullPath = (String) request.getSession().getAttribute("fullPath");
        response.setContentType("application/pdf");
        ServletOutputStream out = null;
        try{
            File file = new File( fullPath );
            FileInputStream fileIn = new FileInputStream( file );
            out = response.getOutputStream();
            Document document = new Document(PageSize.A4);
            PdfWriter writer = PdfWriter.getInstance(document, out);
            document.open();
            PdfContentByte cb = writer.getDirectContent();
            PdfReader reader = new PdfReader(fileIn);
            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("fullPath"));
            stamper.setEncryption("reader_password".getBytes(), "permission_password".getBytes(),  
                    ~(PdfWriter.ALLOW_COPY | PdfWriter.ALLOW_PRINTING ), PdfWriter.STANDARD_ENCRYPTION_128);
            stamper.close();
            PdfImportedPage page = writer.getImportedPage(reader, 1);
            document.newPage();
            cb.addTemplate(page, 0, 0); 
            document.add(new Paragraph("my timestamp"));
            response.setHeader("Expires", "0");
            response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
            response.setHeader("Pragma", "public");
            document.close();

        }catch(Exception e){

        }

    }
4

2 に答える 2

0

iText を使用したことはありませんが、これが少し役立つと思います: iText Java disable print pdf

于 2013-08-28T15:25:16.717 に答える