Discussion:
[iText-questions] Unlocking PDF files.
Subhrajyoti Moitra
2009-02-10 16:10:41 UTC
Permalink
Hi,
I am trying to unlock the attached PDF using the code snippet below.

public static void main(String[] args) throws Exception{
String
inputfile="C:\\SD\\User\\workspace\\Projects\\pdfapp-extension\\WebContent\\test_forms\\79954.pdf";
String
outputFile=System.getProperty("java.io.tmpdir")+File.separator+System.currentTimeMillis()+"_sourcePdf.pdf";
PdfReader sourcePdfFileReader=new PdfReader(inputfile);
if(!sourcePdfFileReader.isOpenedWithFullPermissions()){
System.out.println("This is encrypted and not will full
permissions.");
PdfEncryptor.encrypt(sourcePdfFileReader, new
FileOutputStream(outputFile), null,
null, PdfWriter.ALLOW_ASSEMBLY | PdfWriter.ALLOW_COPY
| PdfWriter.ALLOW_DEGRADED_PRINTING |
PdfWriter.ALLOW_FILL_IN
| PdfWriter.ALLOW_MODIFY_ANNOTATIONS |
PdfWriter.ALLOW_MODIFY_CONTENTS
| PdfWriter.ALLOW_PRINTING |
PdfWriter.ALLOW_SCREENREADERS, false);
}

sourcePdfFileReader.close();
}

This is giving me an exception

Exception in thread "main" java.lang.IllegalArgumentException: PdfReader not
opened with owner password

I read in this link, this is possible: http://www.ensode.net/pdf_unlock.html

Please help...
Thanks,
Subhro.
1T3XT info
2009-02-10 16:25:41 UTC
Permalink
Post by Subhrajyoti Moitra
Exception in thread "main" java.lang.IllegalArgumentException: PdfReader
not opened with owner password
I read in this link, this is possible: http://www.ensode.net/pdf_unlock.html
That link contains information about an action that is illegal.
You are not allowed to use iText to crack a PDF file.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
Subhrajyoti Moitra
2009-02-10 16:46:34 UTC
Permalink
Hi,
Let me tell you why i am doing this.

I want to append/prepend pages to the document. The final pdf need not be
the same doc (the source doc which is protected).
So what i want to do is:

Construct a new pdf file that adds(copies) a prepend.pdf, then copies the
source pdf and then another append pdf.
The final doc is combination of all the 3.

The issue is that i cant seem to accomplish this using PdfCopyFields. My
code is something like this

PdfCopyFields pcf=new PdfCopyFields(tempFileOutputStream);
pcf.addDocument(tempPrependReader);
pcf.addDocument(sourcePdfFileReader);//copy source pdf as is.
pcf.close();

While adding the sourcePdfFileReader i get the below exception. I wanted to
avoid this, is there a way to do this?

Thanks a lot for your time.

Subhro.
Post by Subhrajyoti Moitra
Post by Subhrajyoti Moitra
Exception in thread "main" java.lang.IllegalArgumentException: PdfReader
not opened with owner password
http://www.ensode.net/pdf_unlock.html
That link contains information about an action that is illegal.
You are not allowed to use iText to crack a PDF file.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with
Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code
to
build responsive, highly engaging applications that combine the power of
local
resources and data with the reach of the web. Download the Adobe AIR SDK
and
Ajax docs to start building applications today-
http://p.sf.net/sfu/adobe-com
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Leonard Rosenthol
2009-02-10 16:56:25 UTC
Permalink
You need to contact the original author of the PDF and ask them for the password.

They put the password there to prevent unauthorized use of the document - such as what you are trying to do. I am sure that if you tell them what you are doing, and why, they will be glad to work with you...

Leonard

From: Subhrajyoti Moitra [mailto:***@gmail.com]
Sent: Tuesday, February 10, 2009 11:47 AM
To: Post all your questions about iText here
Subject: Re: [iText-questions] Unlocking PDF files.

Hi,
Let me tell you why i am doing this.

I want to append/prepend pages to the document. The final pdf need not be the same doc (the source doc which is protected).
So what i want to do is:

Construct a new pdf file that adds(copies) a prepend.pdf, then copies the source pdf and then another append pdf.
The final doc is combination of all the 3.

The issue is that i cant seem to accomplish this using PdfCopyFields. My code is something like this

PdfCopyFields pcf=new PdfCopyFields(tempFileOutputStream);
pcf.addDocument(tempPrependReader);
pcf.addDocument(sourcePdfFileReader);//copy source pdf as is.
pcf.close();

While adding the sourcePdfFileReader i get the below exception. I wanted to avoid this, is there a way to do this?

Thanks a lot for your time.

Subhro.
Post by Subhrajyoti Moitra
Exception in thread "main" java.lang.IllegalArgumentException: PdfReader
not opened with owner password
I read in this link, this is possible: http://www.ensode.net/pdf_unlock.html
That link contains information about an action that is illegal.
You are not allowed to use iText to crack a PDF file.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net<mailto:iText-***@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php
Renjan Bhasi
2009-02-10 23:21:18 UTC
Permalink
But, if you know the password, how can we modify that pdf. I have a pdf
document which is protected, but I know the password. Could you please
explain how to do that?
Post by Leonard Rosenthol
You need to contact the original author of the PDF and ask them for the password.
They put the password there to prevent unauthorized use of the document –
such as what you are trying to do. I am sure that if you tell them what you
are doing, and why, they will be glad to work with you…
Leonard
*Sent:* Tuesday, February 10, 2009 11:47 AM
*To:* Post all your questions about iText here
*Subject:* Re: [iText-questions] Unlocking PDF files.
Hi,
Let me tell you why i am doing this.
I want to append/prepend pages to the document. The final pdf need not be
the same doc (the source doc which is protected).
Construct a new pdf file that adds(copies) a prepend.pdf, then copies the
source pdf and then another append pdf.
The final doc is combination of all the 3.
The issue is that i cant seem to accomplish this using PdfCopyFields. My
code is something like this
PdfCopyFields pcf=new PdfCopyFields(tempFileOutputStream);
pcf.addDocument(tempPrependReader);
pcf.addDocument(sourcePdfFileReader);//copy source pdf as is.
pcf.close();
While adding the sourcePdfFileReader i get the below exception. I wanted to
avoid this, is there a way to do this?
Thanks a lot for your time.
Subhro.
Post by Subhrajyoti Moitra
Exception in thread "main" java.lang.IllegalArgumentException: PdfReader
not opened with owner password
http://www.ensode.net/pdf_unlock.html
That link contains information about an action that is illegal.
You are not allowed to use iText to crack a PDF file.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with
Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-
http://p.sf.net/sfu/adobe-com
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with
Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-
http://p.sf.net/sfu/adobe-com
_______________________________________________
iText-questions mailing list
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
--
Thanks and Regards,

Renjan Bhasi,
Sr. Software Engineer,
Tavant Technologies India Pvt. Ltd.
VMS Admin Team - EAG
Office: 91-80-41190300 X220
www.tavant.com
1T3XT info
2009-02-11 07:07:44 UTC
Permalink
Post by Renjan Bhasi
But, if you know the password, how can we modify that pdf. I have a pdf
document which is protected, but I know the password. Could you please
explain how to do that?
That's explained in chapter 3 of the book. And as you probably know, the
first 3 chapters of the book are available as free downloads:
http://itextsoftware.com/chap2ebook.shtml

There's an encrypt/decrypt example here:
http://1t3xt.info/examples/browse/?page=example&id=42
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
Loading...