Olá
Tenho esse jsp com com api itext gerando um pdf porem ele deixa alterar o conteudo, teria como bloquear a edição do pdf?
Como faço isso?
Grato
<%@
page import="java.io.*,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
java.awt.Color,
java.net.MalformedURLException,
java.net.URL,
com.lowagie.text.*,
com.lowagie.text.pdf.*,
java.io.FileOutputStream,
com.lowagie.text.pdf.PdfWriter,
com.lowagie.text.rtf.RtfWriter2,
com.lowagie.text.pdf.codec.TiffImage,
com.lowagie.text.pdf.codec.GifImage,
com.lowagie.text.Image"
%><%
%><%
// Template JSP file for iText
// by Tal Liron
//
response.setContentType( "application/pdf" );
// step 1: creation of a document-object
Document document = new Document();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter writer = PdfWriter.getInstance( document, buffer );
document.open();
//Configurar saida como array buffer
//Configurar criptografia do conteudo em 128 bits
PdfContentByte cb = writer.getDirectContent();
PdfContentByte cb2 = writer.getDirectContent();
//Tipo de Fonte
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED );
cb.stroke();
cb.setColorFill(Color.blue);
cb.stroke();
cb.beginText();
cb.setFontAndSize(bf, 12);
cb.setColorFill(Color.darkGray);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 140, 591, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 140, 577, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 240, 562, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 140, 548, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 140, 532, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 140, 517, 0);
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text 1", 208, 502, 0);
cb.endText();
document.close();
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
%>