Hi all,

I'm really glad to see that in 0.20.5 it will be possible to create
named destinations in PDF. I have some small sugestions about this
functionality.

I'm using Acrobat Reader 5.1 and I was surprised to find out that the
url syntax '.pdf#dest=<NamedDest>' wasn't working for me. I've looked
deeper into
http://www.adobe.com/products/acrobat/pdfs/c01acrotip.pdf#page=4 and I
found a difference between the table (.pdf#dest=<NamedDest>) and the
examples (.pdf#namedest=<NamedDest>). Helas the syntax
'.pdf#namedest=<NamedDest>' also didn't work. Finally I've tried the
syntax '.pdf#nameddest=<NamedDest>' and it worked. I've also tested the
syntax '.pdf#<NamedDest>' and it also works fine. After some googling I
found http://www.adobe.com/support/techdocs/a17e.htm and it looks like
that the later form is really the one supported. If you believe it to be
safe, the changes required to contemplate the working forms in
pdf/PDFDocument.java would be:

Change PDF urls with named destinations

Diff for src/org/apache/fop/pdf/PDFDocument.java (rev 1.30.2.8)
1096c1096
<              } else if ((index = destination.indexOf(".pdf#dest=")) >
0) {
---
>              } else if ((index =
destination.indexOf(".pdf#nameddest=")) > 0) {
1098c1098,1106
<                  String dest = destination.substring(index + 10);
---
>                  String dest = destination.substring(index + 15);
>                  PDFFileSpec fileSpec = new
PDFFileSpec(++this.objectcount, file);
>                  this.objects.add(fileSpec);
>                  action = new PDFGoToRemote(++this.objectcount,
fileSpec, dest);
>                  this.objects.add(action);
>                  link.setAction(action);
>              } else if ((index = destination.indexOf(".pdf#")) > 0) {
>                  String file = destination.substring(0, index + 4);
>                  String dest = destination.substring(index + 5);

In my use of named destinations, I generate named destinations for every
bookmark I have in my documents. The fact that the extension element
fox:destination is only processed when used as a "root" element forces
me to make and additional pass on my xml document just to generate the
named destinations. If fox:destination was also processed whent it is
used as a child of a fox:outline, I could avoid that additional pass.
One way to achieve this, would be to add/change the following in
extensions/Outline.java and render/pdf/PDFRenderer.java:

Allow fox:destination as child of fox:outline

Diff for src/org/apache/fop/extensions/Outline.java (maint rev 1.4.2.5)
63a64
>     private ArrayList _destinations = new ArrayList();
119a121,122
>         } else if (obj instanceof Destination) {
>             _destinations.add(obj);
142a146,149
>     }
> 
>     public ArrayList getDestinations() {
>         return _destinations;

Diff for src/org/apache/fop/render/pdf/PDFRenderer.java (maint rev
1.91.2.15)
986,987c986
<                     Destination d = (Destination)ext;
<                     pdfDoc.addDestination(d.getDestinationName(),
d.getInternalDestination());
---
>                     renderDestination((Destination) ext);
1021a1021,1030
> 
>         // handle sub destinations
>         List vd = outline.getDestinations();
>         for (int i = 0; i < vd.size(); i++) {
>             renderDestination((Destination) vd.get(i));
>         }
>     }
> 
>     private void renderDestination(Destination d) {
>         pdfDoc.addDestination(d.getDestinationName(),
d.getInternalDestination());

BTW, shouldn't the method getName in extensions/Outline.java return
"fox:outline" instead of "fop:outline"? The constructor warning messages
use "fox:outline".

This is probably not the best way to provide this kind of patches. If
you need anything else, feel free to ask, I'll do my best. I try to
follow the digest of this list, but it might be better to email me
directly also. In the last few days I've also added some problems to
Bugzilla. This is the first time I use Bugzilla and I've tried not to
waste your time and be as effective as possible. I hope I didn't make
anything wrong...

Congratulations to you all for the excellent job you are doing, :-))

Ricardo Amador


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to