You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Santiago Cardoso Geller <ca...@gmail.com> on 2015/06/19 22:27:34 UTC

pdfbox Encrypt from command line

Hi! I was trying to Encrypt a pdf from the command line by executing the
following:

java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
test-encrypted.pdf

But I get the following error:
Encrypt failed with the following exception:
java.io.IOException: Error: Expected a long type at offset 7321, instead
got '?'
        at
org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
        at
org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
        at
org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
        at
org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
        at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
        at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
        at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
        at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
        at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
        at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
        at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)

I only downloaded pdfbox-app-1.8.9.jar file. Is it required something else?

Thanks,
Santiago

Re: pdfbox Encrypt from command line

Posted by Tilman Hausherr <TH...@t-online.de>.
I think I found the problem. Your file has been written with EBCDIC code 
:-(  It is this code (and possibly elsewhere too):

  private void writeXrefRange(long x, long y) throws IOException
     {
         getStandardOutput().write(String.valueOf(x).getBytes());
         getStandardOutput().write(SPACE);
         getStandardOutput().write(String.valueOf(y).getBytes());
         getStandardOutput().writeEOL();
     }

And it should have been

  private void writeXrefRange(long x, long y) throws IOException
     {
getStandardOutput().write(String.valueOf(x).getBytes(Charsets.ISO_8859_1));
         getStandardOutput().write(SPACE);
getStandardOutput().write(String.valueOf(y).getBytes(Charsets.ISO_8859_1));
         getStandardOutput().writeEOL();
     }

I'll open an issue and fix this later today. I guess you're the first 
person in the world to use PDFBox on that OS.

Tilman


Am 20.06.2015 um 00:46 schrieb Santiago Cardoso Geller:
> Hi Tilman. I found that the error is in the pdf generated previously with
> the TextToPDF command.
>
> This is my environment:
> OS: Unix Service running on Z/OS.
> JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
> PDFBOX: pdfbox-app-1.8.9.jar
>
> I uploaded the original test.txt file and the pdf generated from z/OS (and
> also another one generated on Win7) here:
> https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0
>
> If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
> different at line 58. If I change those bytes, then the encryption works
> fine.
>
> Thanks and regards,
> Santiago
>
>
>
> On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Could you please upload the file somewhere?
>>
>> Tilman
>>
>>
>> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>>
>>> Hi! I was trying to Encrypt a pdf from the command line by executing the
>>> following:
>>>
>>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>>> test-encrypted.pdf
>>>
>>> But I get the following error:
>>> Encrypt failed with the following exception:
>>> java.io.IOException: Error: Expected a long type at offset 7321, instead
>>> got '?'
>>>           at
>>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>>           at
>>>
>>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>>           at
>>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>>           at
>>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>>           at
>>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>>           at
>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>>           at
>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>>           at
>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>>           at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>>           at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>>           at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>>
>>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>>> else?
>>>
>>> Thanks,
>>> Santiago
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: pdfbox Encrypt from command line

Posted by Santiago Cardoso Geller <ca...@gmail.com>.
Thank you Tilman.

Tested. Now its OK. This is the command line I executed:

java -jar pdfbox-app-1.8.10-20150621.120349-75.jar TextToPDF
test_zos_fixed.pdf test.txt.ebcdic

And you can find the test_zos_fixed.pdf file on dropbox:
https://www.dropbox.com/sh/q45d8p4fi4eqcoh/AAC5SKGS0q9Yy3v1iTSXPqSMa?dl=0

Thanks,
Santiago


On Sun, Jun 21, 2015 at 12:31 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Hi,
>
> A new snapshot is available now:
>
> https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/1.8.10-SNAPSHOT/
> look near the bottom for an updated jar.
>
> it would be nice to test it without the file.encoding trick, to see
> whether we fixed the bug you reported.
>
> Tilman
>
> Am 21.06.2015 um 05:55 schrieb Santiago Cardoso Geller:
>
>> Tilman, following your 2nd suggestion I could make it work with
>> thiscommand:
>>
>> java *-Dfile.encoding=ISO-8859-1* -jar pdfbox-app-1.8.9.jar TextToPDF
>>
>> test.pdf test.txt
>>
>> Thank you very much!
>>
>> On Sun, Jun 21, 2015 at 12:36 AM, Santiago Cardoso Geller <
>> cardosogeller@gmail.com> wrote:
>>
>>  Thank you Tilman.
>>> I can see your changes on the SVN. By the moment I don't know how to get
>>> the project from the SVN repository to build the new jar. I will try and
>>> then I'll test your changes on the z/os.
>>>
>>> On Sat, Jun 20, 2015 at 11:07 AM, Tilman Hausherr <THausherr@t-online.de
>>> >
>>> wrote:
>>>
>>>  Hi,
>>>>
>>>> I opened an issue for you:
>>>> https://issues.apache.org/jira/browse/PDFBOX-2837
>>>>
>>>> We are currently having a config problem with the Apache build server,
>>>> so
>>>> there won't be a snapshot now, maybe next week. So there are two options
>>>> for you until there is:
>>>>
>>>> 1) build from source yourself. The svn repository for the 1.8 version is
>>>> https://svn.apache.org/repos/asf/pdfbox/branches/1.8, for the 2.0
>>>> version it is https://svn.apache.org/repos/asf/pdfbox/trunk
>>>> 2) read this:
>>>> http://www.ibm.com/developerworks/systems/library/es-java-batchz.html
>>>> set /file.encoding/ property to ISO-8859-1.
>>>>
>>>> The very best would of course be that you run a build on your z/OS
>>>> system, to see if any tests fail. I did fix several method calls where
>>>> the
>>>> charset was missing and where this could make a "bad" difference, but I
>>>> don't know if I got them all.
>>>>
>>>> Tilman
>>>>
>>>>
>>>> Am 20.06.2015 um 00:46 schrieb Santiago Cardoso Geller:
>>>>
>>>>  Hi Tilman. I found that the error is in the pdf generated previously
>>>>> with
>>>>> the TextToPDF command.
>>>>>
>>>>> This is my environment:
>>>>> OS: Unix Service running on Z/OS.
>>>>> JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
>>>>> PDFBOX: pdfbox-app-1.8.9.jar
>>>>>
>>>>> I uploaded the original test.txt file and the pdf generated from z/OS
>>>>> (and
>>>>> also another one generated on Win7) here:
>>>>>
>>>>> https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0
>>>>>
>>>>> If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
>>>>> different at line 58. If I change those bytes, then the encryption
>>>>> works
>>>>> fine.
>>>>>
>>>>> Thanks and regards,
>>>>> Santiago
>>>>>
>>>>>
>>>>>
>>>>> On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <
>>>>> THausherr@t-online.de>
>>>>> wrote:
>>>>>
>>>>>   Could you please upload the file somewhere?
>>>>>
>>>>>> Tilman
>>>>>>
>>>>>>
>>>>>> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>>>>>>
>>>>>>   Hi! I was trying to Encrypt a pdf from the command line by executing
>>>>>>
>>>>>>> the
>>>>>>> following:
>>>>>>>
>>>>>>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>>>>>>> test-encrypted.pdf
>>>>>>>
>>>>>>> But I get the following error:
>>>>>>> Encrypt failed with the following exception:
>>>>>>> java.io.IOException: Error: Expected a long type at offset 7321,
>>>>>>> instead
>>>>>>> got '?'
>>>>>>>            at
>>>>>>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>>>>>>            at
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>>>>>>            at
>>>>>>>
>>>>>>>
>>>>>>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>>>>>>            at
>>>>>>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>>>>>>            at
>>>>>>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>>>>>>            at
>>>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>>>>>>            at
>>>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>>>>>>            at
>>>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>>>>>>            at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>>>>>>            at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>>>>>>            at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>>>>>>
>>>>>>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>>>>>>> else?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Santiago
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>>
>>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: pdfbox Encrypt from command line

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

A new snapshot is available now:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/1.8.10-SNAPSHOT/
look near the bottom for an updated jar.

it would be nice to test it without the file.encoding trick, to see 
whether we fixed the bug you reported.

Tilman

Am 21.06.2015 um 05:55 schrieb Santiago Cardoso Geller:
> Tilman, following your 2nd suggestion I could make it work with thiscommand:
>
> java *-Dfile.encoding=ISO-8859-1* -jar pdfbox-app-1.8.9.jar TextToPDF
> test.pdf test.txt
>
> Thank you very much!
>
> On Sun, Jun 21, 2015 at 12:36 AM, Santiago Cardoso Geller <
> cardosogeller@gmail.com> wrote:
>
>> Thank you Tilman.
>> I can see your changes on the SVN. By the moment I don't know how to get
>> the project from the SVN repository to build the new jar. I will try and
>> then I'll test your changes on the z/os.
>>
>> On Sat, Jun 20, 2015 at 11:07 AM, Tilman Hausherr <TH...@t-online.de>
>> wrote:
>>
>>> Hi,
>>>
>>> I opened an issue for you:
>>> https://issues.apache.org/jira/browse/PDFBOX-2837
>>>
>>> We are currently having a config problem with the Apache build server, so
>>> there won't be a snapshot now, maybe next week. So there are two options
>>> for you until there is:
>>>
>>> 1) build from source yourself. The svn repository for the 1.8 version is
>>> https://svn.apache.org/repos/asf/pdfbox/branches/1.8, for the 2.0
>>> version it is https://svn.apache.org/repos/asf/pdfbox/trunk
>>> 2) read this:
>>> http://www.ibm.com/developerworks/systems/library/es-java-batchz.html
>>> set /file.encoding/ property to ISO-8859-1.
>>>
>>> The very best would of course be that you run a build on your z/OS
>>> system, to see if any tests fail. I did fix several method calls where the
>>> charset was missing and where this could make a "bad" difference, but I
>>> don't know if I got them all.
>>>
>>> Tilman
>>>
>>>
>>> Am 20.06.2015 um 00:46 schrieb Santiago Cardoso Geller:
>>>
>>>> Hi Tilman. I found that the error is in the pdf generated previously with
>>>> the TextToPDF command.
>>>>
>>>> This is my environment:
>>>> OS: Unix Service running on Z/OS.
>>>> JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
>>>> PDFBOX: pdfbox-app-1.8.9.jar
>>>>
>>>> I uploaded the original test.txt file and the pdf generated from z/OS
>>>> (and
>>>> also another one generated on Win7) here:
>>>> https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0
>>>>
>>>> If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
>>>> different at line 58. If I change those bytes, then the encryption works
>>>> fine.
>>>>
>>>> Thanks and regards,
>>>> Santiago
>>>>
>>>>
>>>>
>>>> On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <TH...@t-online.de>
>>>> wrote:
>>>>
>>>>   Could you please upload the file somewhere?
>>>>> Tilman
>>>>>
>>>>>
>>>>> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>>>>>
>>>>>   Hi! I was trying to Encrypt a pdf from the command line by executing
>>>>>> the
>>>>>> following:
>>>>>>
>>>>>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>>>>>> test-encrypted.pdf
>>>>>>
>>>>>> But I get the following error:
>>>>>> Encrypt failed with the following exception:
>>>>>> java.io.IOException: Error: Expected a long type at offset 7321,
>>>>>> instead
>>>>>> got '?'
>>>>>>            at
>>>>>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>>>>>            at
>>>>>>
>>>>>>
>>>>>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>>>>>            at
>>>>>>
>>>>>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>>>>>            at
>>>>>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>>>>>            at
>>>>>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>>>>>            at
>>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>>>>>            at
>>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>>>>>            at
>>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>>>>>            at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>>>>>            at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>>>>>            at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>>>>>
>>>>>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>>>>>> else?
>>>>>>
>>>>>> Thanks,
>>>>>> Santiago
>>>>>>
>>>>>>
>>>>>>   ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>>
>>>>>
>>>>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: pdfbox Encrypt from command line

Posted by Santiago Cardoso Geller <ca...@gmail.com>.
Tilman, following your 2nd suggestion I could make it work with thiscommand:

java *-Dfile.encoding=ISO-8859-1* -jar pdfbox-app-1.8.9.jar TextToPDF
test.pdf test.txt

Thank you very much!

On Sun, Jun 21, 2015 at 12:36 AM, Santiago Cardoso Geller <
cardosogeller@gmail.com> wrote:

> Thank you Tilman.
> I can see your changes on the SVN. By the moment I don't know how to get
> the project from the SVN repository to build the new jar. I will try and
> then I'll test your changes on the z/os.
>
> On Sat, Jun 20, 2015 at 11:07 AM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Hi,
>>
>> I opened an issue for you:
>> https://issues.apache.org/jira/browse/PDFBOX-2837
>>
>> We are currently having a config problem with the Apache build server, so
>> there won't be a snapshot now, maybe next week. So there are two options
>> for you until there is:
>>
>> 1) build from source yourself. The svn repository for the 1.8 version is
>> https://svn.apache.org/repos/asf/pdfbox/branches/1.8, for the 2.0
>> version it is https://svn.apache.org/repos/asf/pdfbox/trunk
>> 2) read this:
>> http://www.ibm.com/developerworks/systems/library/es-java-batchz.html
>> set /file.encoding/ property to ISO-8859-1.
>>
>> The very best would of course be that you run a build on your z/OS
>> system, to see if any tests fail. I did fix several method calls where the
>> charset was missing and where this could make a "bad" difference, but I
>> don't know if I got them all.
>>
>> Tilman
>>
>>
>> Am 20.06.2015 um 00:46 schrieb Santiago Cardoso Geller:
>>
>>> Hi Tilman. I found that the error is in the pdf generated previously with
>>> the TextToPDF command.
>>>
>>> This is my environment:
>>> OS: Unix Service running on Z/OS.
>>> JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
>>> PDFBOX: pdfbox-app-1.8.9.jar
>>>
>>> I uploaded the original test.txt file and the pdf generated from z/OS
>>> (and
>>> also another one generated on Win7) here:
>>> https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0
>>>
>>> If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
>>> different at line 58. If I change those bytes, then the encryption works
>>> fine.
>>>
>>> Thanks and regards,
>>> Santiago
>>>
>>>
>>>
>>> On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <TH...@t-online.de>
>>> wrote:
>>>
>>>  Could you please upload the file somewhere?
>>>>
>>>> Tilman
>>>>
>>>>
>>>> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>>>>
>>>>  Hi! I was trying to Encrypt a pdf from the command line by executing
>>>>> the
>>>>> following:
>>>>>
>>>>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>>>>> test-encrypted.pdf
>>>>>
>>>>> But I get the following error:
>>>>> Encrypt failed with the following exception:
>>>>> java.io.IOException: Error: Expected a long type at offset 7321,
>>>>> instead
>>>>> got '?'
>>>>>           at
>>>>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>>>>           at
>>>>>
>>>>>
>>>>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>>>>           at
>>>>>
>>>>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>>>>           at
>>>>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>>>>           at
>>>>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>>>>           at
>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>>>>           at
>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>>>>           at
>>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>>>>           at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>>>>           at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>>>>           at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>>>>
>>>>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>>>>> else?
>>>>>
>>>>> Thanks,
>>>>> Santiago
>>>>>
>>>>>
>>>>>  ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>>>
>>>>
>>
>

Re: pdfbox Encrypt from command line

Posted by Santiago Cardoso Geller <ca...@gmail.com>.
Thank you Tilman.
I can see your changes on the SVN. By the moment I don't know how to get
the project from the SVN repository to build the new jar. I will try and
then I'll test your changes on the z/os.

On Sat, Jun 20, 2015 at 11:07 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Hi,
>
> I opened an issue for you:
> https://issues.apache.org/jira/browse/PDFBOX-2837
>
> We are currently having a config problem with the Apache build server, so
> there won't be a snapshot now, maybe next week. So there are two options
> for you until there is:
>
> 1) build from source yourself. The svn repository for the 1.8 version is
> https://svn.apache.org/repos/asf/pdfbox/branches/1.8, for the 2.0 version
> it is https://svn.apache.org/repos/asf/pdfbox/trunk
> 2) read this:
> http://www.ibm.com/developerworks/systems/library/es-java-batchz.html
> set /file.encoding/ property to ISO-8859-1.
>
> The very best would of course be that you run a build on your z/OS system,
> to see if any tests fail. I did fix several method calls where the charset
> was missing and where this could make a "bad" difference, but I don't know
> if I got them all.
>
> Tilman
>
>
> Am 20.06.2015 um 00:46 schrieb Santiago Cardoso Geller:
>
>> Hi Tilman. I found that the error is in the pdf generated previously with
>> the TextToPDF command.
>>
>> This is my environment:
>> OS: Unix Service running on Z/OS.
>> JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
>> PDFBOX: pdfbox-app-1.8.9.jar
>>
>> I uploaded the original test.txt file and the pdf generated from z/OS (and
>> also another one generated on Win7) here:
>> https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0
>>
>> If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
>> different at line 58. If I change those bytes, then the encryption works
>> fine.
>>
>> Thanks and regards,
>> Santiago
>>
>>
>>
>> On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <TH...@t-online.de>
>> wrote:
>>
>>  Could you please upload the file somewhere?
>>>
>>> Tilman
>>>
>>>
>>> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>>>
>>>  Hi! I was trying to Encrypt a pdf from the command line by executing the
>>>> following:
>>>>
>>>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>>>> test-encrypted.pdf
>>>>
>>>> But I get the following error:
>>>> Encrypt failed with the following exception:
>>>> java.io.IOException: Error: Expected a long type at offset 7321, instead
>>>> got '?'
>>>>           at
>>>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>>>           at
>>>>
>>>>
>>>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>>>           at
>>>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>>>           at
>>>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>>>           at
>>>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>>>           at
>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>>>           at
>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>>>           at
>>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>>>           at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>>>           at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>>>           at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>>>
>>>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>>>> else?
>>>>
>>>> Thanks,
>>>> Santiago
>>>>
>>>>
>>>>  ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>>>
>>>
>

Re: pdfbox Encrypt from command line

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

I opened an issue for you:
https://issues.apache.org/jira/browse/PDFBOX-2837

We are currently having a config problem with the Apache build server, 
so there won't be a snapshot now, maybe next week. So there are two 
options for you until there is:

1) build from source yourself. The svn repository for the 1.8 version is 
https://svn.apache.org/repos/asf/pdfbox/branches/1.8, for the 2.0 
version it is https://svn.apache.org/repos/asf/pdfbox/trunk
2) read this:
http://www.ibm.com/developerworks/systems/library/es-java-batchz.html
set /file.encoding/ property to ISO-8859-1.

The very best would of course be that you run a build on your z/OS 
system, to see if any tests fail. I did fix several method calls where 
the charset was missing and where this could make a "bad" difference, 
but I don't know if I got them all.

Tilman


Am 20.06.2015 um 00:46 schrieb Santiago Cardoso Geller:
> Hi Tilman. I found that the error is in the pdf generated previously with
> the TextToPDF command.
>
> This is my environment:
> OS: Unix Service running on Z/OS.
> JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
> PDFBOX: pdfbox-app-1.8.9.jar
>
> I uploaded the original test.txt file and the pdf generated from z/OS (and
> also another one generated on Win7) here:
> https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0
>
> If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
> different at line 58. If I change those bytes, then the encryption works
> fine.
>
> Thanks and regards,
> Santiago
>
>
>
> On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Could you please upload the file somewhere?
>>
>> Tilman
>>
>>
>> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>>
>>> Hi! I was trying to Encrypt a pdf from the command line by executing the
>>> following:
>>>
>>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>>> test-encrypted.pdf
>>>
>>> But I get the following error:
>>> Encrypt failed with the following exception:
>>> java.io.IOException: Error: Expected a long type at offset 7321, instead
>>> got '?'
>>>           at
>>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>>           at
>>>
>>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>>           at
>>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>>           at
>>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>>           at
>>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>>           at
>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>>           at
>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>>           at
>>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>>           at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>>           at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>>           at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>>
>>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>>> else?
>>>
>>> Thanks,
>>> Santiago
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


Re: pdfbox Encrypt from command line

Posted by Santiago Cardoso Geller <ca...@gmail.com>.
Hi Tilman. I found that the error is in the pdf generated previously with
the TextToPDF command.

This is my environment:
OS: Unix Service running on Z/OS.
JRE: JRE 1.6.0 IBM J9 2.4 z/OS s390-31
PDFBOX: pdfbox-app-1.8.9.jar

I uploaded the original test.txt file and the pdf generated from z/OS (and
also another one generated on Win7) here:
https://www.dropbox.com/sh/k8lpjgxed0lxhfe/AADFnwW8y_7zJXe9gL3mz9UDa?dl=0

If you compare test_zos.pdf and test_win7.pdf you will find 2 bytes
different at line 58. If I change those bytes, then the encryption works
fine.

Thanks and regards,
Santiago



On Fri, Jun 19, 2015 at 6:25 PM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Could you please upload the file somewhere?
>
> Tilman
>
>
> Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
>
>> Hi! I was trying to Encrypt a pdf from the command line by executing the
>> following:
>>
>> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
>> test-encrypted.pdf
>>
>> But I get the following error:
>> Encrypt failed with the following exception:
>> java.io.IOException: Error: Expected a long type at offset 7321, instead
>> got '?'
>>          at
>> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>>          at
>>
>> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>>          at
>> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>>          at
>> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>>          at
>> org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>>          at
>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>>          at
>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>>          at
>> org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>>          at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>>          at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>>          at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>>
>> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something
>> else?
>>
>> Thanks,
>> Santiago
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: pdfbox Encrypt from command line

Posted by Tilman Hausherr <TH...@t-online.de>.
Could you please upload the file somewhere?

Tilman

Am 19.06.2015 um 22:27 schrieb Santiago Cardoso Geller:
> Hi! I was trying to Encrypt a pdf from the command line by executing the
> following:
>
> java -jar pdfbox-app-1.8.9.jar Encrypt -U 12345 -O 12345 test.pdf
> test-encrypted.pdf
>
> But I get the following error:
> Encrypt failed with the following exception:
> java.io.IOException: Error: Expected a long type at offset 7321, instead
> got '?'
>          at
> org.apache.pdfbox.pdfparser.BaseParser.readLong(BaseParser.java:1695)
>          at
> org.apache.pdfbox.pdfparser.BaseParser.readObjectNumber(BaseParser.java:1623)
>          at
> org.apache.pdfbox.pdfparser.PDFParser.parseXrefTable(PDFParser.java:818)
>          at
> org.apache.pdfbox.pdfparser.PDFParser.parseObject(PDFParser.java:540)
>          at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:203)
>          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1220)
>          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1187)
>          at org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1112)
>          at org.apache.pdfbox.Encrypt.encrypt(Encrypt.java:158)
>          at org.apache.pdfbox.Encrypt.main(Encrypt.java:53)
>          at org.apache.pdfbox.PDFBox.main(PDFBox.java:54)
>
> I only downloaded pdfbox-app-1.8.9.jar file. Is it required something else?
>
> Thanks,
> Santiago
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org