I have something that seems to be working, but I am not sure it is always
correct and I doubt it's the most optimal approach.
Here are the changes I did
1. PDFLink#toPDFString
Added
this.action.setParent(this);
(would be better to do this when creating the PDFUri object )
2. PDFUri#getAction
public String getAction() {
return "<< /URI (" + uri + ")\n/S /URI >>";
}
-->
public String getAction() {
String uriString=new String(this.encodeText2(uri));
return "<< /URI " + uriString + "\n /S /URI >>";
}
3. Added PDFObject#encodeText2
protected byte[] encodeText2(String text) {
if (getDocumentSafely().isEncryptionActive()) {
final byte[] buf = PDFText.encode(text);
byte[] enc = getDocument().getEncryption().encrypt(buf, this);
return PDFText.toHex(enc,true).getBytes();
} else {
return encode(PDFText.escapeText(text, false));
}
}
Perhaps this can be used as something to start from for a patch for bug
41959 ?
Thanks,
Peter
Peter Coppens wrote:
>
> Looks like the uri is not encrypted at all.
>
> The code that writes out the PDFLink object seems to completely skip the
> 'normal' pdf output processing and writes out text without going through
> the encodeText method from PDFObject.
>
> I tried to hack around a bit and after making sure PDFUri has its parent
> set to PDFLink (which it has not in the 0.95 code) something encrypted is
> written, but Acrobat still can not make sense of it.
>
> With the hack enabled I get
>
> << /Type /Annot
> /Subtype /Link
> /Rect [ 72.0 707.25 132.024 718.35 ]
> /C [ 0 0 0 ]
> /Border [ 0 0 0 ]
> /A << /URI
> (ö?§^[BÎ^OØ^^éOªûL^A;èÇ?%^Oµ?^G-?CS>^TÔñÏ?f:¯?±??!£?¯ÉÀ^]y?n¬??^OE5Ä}|
> ,^V)
> /S /URI >>
> /H /I
>
>>>
>
> (without the hack the URI is plain text)
>
>
> Unfortunately that is not what it should be...and I am clueless as to what
> is going wrong now. I guess I will have to dive in the encryption part of
> the pdf spec to figure out what exactly needs to be encrypted for Acrobat
> to be happy with it.
>
> Perhaps someone has suggestions on what might be wrong in the above
> Annotation object?
>
> Thanks!
>
> Peter
>
>
>
> Peter Coppens wrote:
>>
>> Thanks for the prompt feedback. I will try to get my head around the code
>> and see whether I can come up with a possible suggestion for a fix
>>
>> Peter
>>
>>
>> Andreas Delmelle-2 wrote:
>>>
>>> On 29 Nov 2008, at 13:24, Peter Coppens wrote:
>>>
>>> Hi Peter
>>>
>>>> <snip />
>>>> But with encryption options the link is garbled
>>>>
>>>> fop -noprint -nocopy -fo test.fo -pdf test.pdf
>>>>
>>>> When opening in Acrobat reader 8 it pops up a dialog stating
>>>>
>>>> The document is trying to connect to
>>>> file:///private/var/tmp/%1CH%3E%C2%A7%C3%AE%C2%B6%0C%C2%AAcA%C2%91%C2%8En%C2%A7y%C2%90%C3%9F%C2%AAI%C3%A3+%C2%81%C2%AA%3Euk%C3%98%05%C2%B6%C2%91
>>>
>>> Seems like this is a known bug (since 0.92) that no one has got around
>>> to fixing yet...
>>> (see also: http://issues.apache.org/show_bug.cgi?id=41959)
>>>
>>>
>>> Cheers
>>>
>>> Andreas
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Encryption-garbles-external-link-tp20746538p20753657.html
Sent from the FOP - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]