Skip to main content



      Home
Home » Archived » BIRT » PDF password protected
PDF password protected [message #248495] Tue, 17 July 2007 15:37 Go to next message
Eclipse UserFriend
Hi,

I have the following question: is there any possibility to assign a
password to a report such as if the user wants to modify the generated PDF
in Acrobat Reader, not to be allowed (only if they know that password)?

Thank you,
Cristian
Re: PDF password protected [message #248875 is a reply to message #248495] Thu, 19 July 2007 09:19 Go to previous messageGo to next message
Eclipse UserFriend
Hi. I posted this message a couple of days ago but no answer. Does anybody
have any idea is it is implemented or not and if yes how to use it? The
problem is: password protected PDFs: we would like to generate PDFs that
cannot be modified by user (only if they know a password or something). We
are generating reports that are sent via email to user, and we would like
to make them password protected or read only (the user is not allowed to
modify them in Acrobat program).

Thank you,
Cristian
Re: PDF password protected [message #250181 is a reply to message #248875] Fri, 27 July 2007 11:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi. I've posted a week ago this message and because I didn't got no answer
I'll posted again.

Thanks,
Cristian
Re: PDF password protected [message #250782 is a reply to message #250181] Wed, 01 August 2007 14:09 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

i also have the same problem with generated password protected PDF report.
i wonder wether it is supported directly by birt2.2.

regards
Re: PDF password protected [message #251142 is a reply to message #250782] Fri, 03 August 2007 14:27 Go to previous messageGo to next message
Eclipse UserFriend
I didn't find anything anywhere about PDF protection in BIRT. My solution
would be to use iText tools to protect the generated report with a
password or smth.
Re: PDF password protected [message #251394 is a reply to message #251142] Tue, 07 August 2007 02:05 Go to previous messageGo to next message
Eclipse UserFriend
I agree, use iText.

example code, encrypting with an ownerpassword:

final PdfReader reader = new PdfReader(fileName);
final File destinationFile = File.createTempFile("report_encrypted_",
".pdf");

PdfEncryptor.encrypt(reader,
new FileOutputStream(destinationFile),
null,
password.getBytes(),
PdfWriter.AllowPrinting,
false);

final File sourceFile = new File(fileName);
sourceFile.delete();
destinationFile.renameTo(sourceFile);


Cristian schrieb:
> I didn't find anything anywhere about PDF protection in BIRT. My
> solution would be to use iText tools to protect the generated report
> with a password or smth.
>
Re: PDF password protected [message #251409 is a reply to message #251394] Tue, 07 August 2007 03:04 Go to previous messageGo to next message
Eclipse UserFriend
But wouldn't it make sense to log a bug against Birt to allow this out
of the box, by setting some configuration variable?

Tom

Jochen Frühwirth schrieb:
> I agree, use iText.
>
> example code, encrypting with an ownerpassword:
>
> final PdfReader reader = new PdfReader(fileName);
> final File destinationFile = File.createTempFile("report_encrypted_",
> ".pdf");
>
> PdfEncryptor.encrypt(reader,
> new FileOutputStream(destinationFile),
> null,
> password.getBytes(),
> PdfWriter.AllowPrinting,
> false);
>
> final File sourceFile = new File(fileName);
> sourceFile.delete();
> destinationFile.renameTo(sourceFile);
>
>
> Cristian schrieb:
>> I didn't find anything anywhere about PDF protection in BIRT. My
>> solution would be to use iText tools to protect the generated report
>> with a password or smth.
>>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: PDF password protected [message #251660 is a reply to message #251394] Wed, 08 August 2007 09:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi, I'll continue this thread with another issue.

I was trying to implement the following scenario:
From the app, I'll invoke the BIRT ViewerServlet and catch whatever it
generates in a byte array. This byte array is then casted to a PdfReader
object and the rest you well know (apply the password with iText tools
aso). I would prefer not to save the generated PDF on a local disk and
then to open it.

Now the issue is that when I open the new connection to the BIRT
ViewerServlet, I'm loosing the previous session. I've tried to set also
the cookies but no success. I'm curious if anybody had this issue before
and how did they solve it.

Thanks,
Cristian

/*===code sample===*/

ServletOutputStream out = null;
String param1 = "test1";
String vPath =
" http://localhost:8080/myApp/secure/run?__format=pdf&__lo cale=EN&__report=myDemoReport.rptdesign&param1="+param1+"&timestamp="+(new
Date()).getTime();
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(vPath);
DefaultMethodRetryHandler retryhandler = new DefaultMethodRetryHandler();
retryhandler.setRequestSentRetryEnabled(false);
retryhandler.setRetryCount(3);
method.setMethodRetryHandler(retryhandler);
Cookie[] cookies = client.getState().getCookies();
Cookie cook = new Cookie();
cook.setName("foo");
cook.setValue("bar");
client.getState().addCookie(cook);
try {
// Execute the method.
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK)
{
String message = "error";
throw new ActionException(message, "error");
}

byte[] responseBody = method.getResponseBody();
/*
do password protection with iText
*/
out = response.getOutputStream();
out.write(responseBody);
out.flush();
out.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
method.releaseConnection();
}


/*==========in the myDemoReport.rptdesign ===========*/
var request = reportContext.getHttpServletRequest();
cookys = request.getCookies();
if( cookys ) {
testcook = "Cookies:: ";
for( uu=0; uu < cookys.length; uu++ ){
testcook += cookys[uu].getName() + " :: " + cookys[uu].getValue();
}
}else{
testcook = "No cookies";
}
this.valueExpr=testcook;
Re: PDF password protected [message #251846 is a reply to message #251660] Thu, 09 August 2007 09:14 Go to previous message
Eclipse UserFriend
Hi,

solved the problem. I was using servlet filtering.

Regards,
Cristian
Previous Topic:Don't show images from JAR in HTML when deployed into Tomcat
Next Topic:BIRT Report Hangs
Goto Forum:
  


Current Time: Sun May 11 00:17:37 EDT 2025

Powered by FUDForum. Page generated in 0.03280 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top