You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by useratnab <Ti...@gmx.net> on 2009/02/13 12:05:17 UTC

Making Links in PDF

Hello,

I get an "Exception in thread "AWT-EventQueue-0"
java.lang.IllegalArgumentException: Cannot reference this object. It doesn't
have an object number"

Is there somehting wrong with using "addLink"?

<pre>
PDFDocumentGraphics2D 	pdf2D;
AffineTransform Tx = new AffineTransform( 1, 0, 0, 1, 0, 0);

Rectangle2D  rect = new Rectangle2D.Double ();
rect.setRect (20., 20., 100., 50.);		 
			 
// 0 --> other files
// 1 --> another pos in same file
// 2 --> URL 
pdf2D.addLink(rect, Tx, "[/XYZ 0 0 null]", 1);
</pre>

Thank you
Tim
-- 
View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p21994320.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Making Links in PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Oh, that line is just a left-over from some experiments. It just makes a
copy of the other AffineTransform. You could use it directly.

On 20.02.2009 11:59:15 useratnab wrote:
> 
> Thanks a lot, now it works as I wanted it to.
> But one more thing, I don't get, is why do you use the AffineTansform a 2nd
> time, before the addLink in your example:
> 
>             AffineTransform pdfInitialTransform = new AffineTransform(
>                     1, 0, 0, -1, 0, pageSize.height);
> 
>             g2d.translate(20, 20);
> 
>             Rectangle rect = new Rectangle(20, 20, 40, 50);
>             g2d.setColor(Color.BLUE);
>             g2d.fill(rect);
> 
> >>>            AffineTransform tx = new
> >>> AffineTransform(pdfInitialTransform);
>             Rectangle2D targetRect = rect;
> 
>             g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
> 
> 
> Thanks again
> Tim
> 
<snip/> 


Jeremias Maerki


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


Re: Making Links in PDF

Posted by useratnab <Ti...@gmx.net>.
Thanks a lot, now it works as I wanted it to.
But one more thing, I don't get, is why do you use the AffineTansform a 2nd
time, before the addLink in your example:

            AffineTransform pdfInitialTransform = new AffineTransform(
                    1, 0, 0, -1, 0, pageSize.height);

            g2d.translate(20, 20);

            Rectangle rect = new Rectangle(20, 20, 40, 50);
            g2d.setColor(Color.BLUE);
            g2d.fill(rect);

>>>            AffineTransform tx = new
>>> AffineTransform(pdfInitialTransform);
            Rectangle2D targetRect = rect;

            g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);


Thanks again
Tim



Jeremias Maerki-2 wrote:
> 
> You'll have to dig deeper and extend the code. "FitR" is currently
> hard-coded. I'm sure that can be improved.
> 
> But "/Page /Next" won't work. I haven't found that possibility in the
> PDF specification. Take a look at the Table 8.2 in the PDF specification
> 1.4 on page 475. That shows you what is possible.
> 
> On 19.02.2009 13:29:52 useratnab wrote:
>> 
>> I've tried to change the destination from
>> 
>> String pdfdest = "/FitR " + dest;
>> to
>> String pdfdest = "/Page /Next";
>> 
>> but this won't do it. I guess I have to dig deeper for it or do you have
>> any
>> suggestions to link the prev. and next page?
>> 
>> Thanks
>> 
>> 
>> 
>> 
>> Jeremias Maerki-2 wrote:
>> > 
>> > Yes, you'll need that fix I mentioned. You'll have to use the latest
>> FOP
>> > Trunk directly from the Subversion repository.
>> > 
>> > On 18.02.2009 14:28:06 useratnab wrote:
>> >> 
>> >> Hey,
>> >> 
>> >> first of all I gotta say: a big thanks to you and your support, I got
>> >> some
>> >> things fixed, I thought I'd never find the answer for :confused:
>> >> 
>> >> But unfortunately there's still the "Cannot reference this object. It
>> >> doesn't have an object number" error, when calling:
>> >> 
>> >> g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
>> >> 
>> >> What fop are you using? 
>> >> Is that "SVG #svgView(viewBox())" bug-fix necessary, you mentioned
>> >> earlier?
>> >> 
>> >> Thanks again Tim
>> >> 
>> > <snip/> 
>> > 
>> > 
>> > Jeremias Maerki
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Making-Links-in-PDF-tp21994320p22099417.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22118611.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Making Links in PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
You'll have to dig deeper and extend the code. "FitR" is currently
hard-coded. I'm sure that can be improved.

But "/Page /Next" won't work. I haven't found that possibility in the
PDF specification. Take a look at the Table 8.2 in the PDF specification
1.4 on page 475. That shows you what is possible.

On 19.02.2009 13:29:52 useratnab wrote:
> 
> I've tried to change the destination from
> 
> String pdfdest = "/FitR " + dest;
> to
> String pdfdest = "/Page /Next";
> 
> but this won't do it. I guess I have to dig deeper for it or do you have any
> suggestions to link the prev. and next page?
> 
> Thanks
> 
> 
> 
> 
> Jeremias Maerki-2 wrote:
> > 
> > Yes, you'll need that fix I mentioned. You'll have to use the latest FOP
> > Trunk directly from the Subversion repository.
> > 
> > On 18.02.2009 14:28:06 useratnab wrote:
> >> 
> >> Hey,
> >> 
> >> first of all I gotta say: a big thanks to you and your support, I got
> >> some
> >> things fixed, I thought I'd never find the answer for :confused:
> >> 
> >> But unfortunately there's still the "Cannot reference this object. It
> >> doesn't have an object number" error, when calling:
> >> 
> >> g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
> >> 
> >> What fop are you using? 
> >> Is that "SVG #svgView(viewBox())" bug-fix necessary, you mentioned
> >> earlier?
> >> 
> >> Thanks again Tim
> >> 
> > <snip/> 
> > 
> > 
> > Jeremias Maerki
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22099417.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org




Jeremias Maerki


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


Re: Making Links in PDF

Posted by useratnab <Ti...@gmx.net>.
Now it works just fine. 

But I guess I have to modify the PDFGraphics2D.java, because for internal
links, it'll always start the destination like this:

pdfdest = "/FitR " + dest;

This is probably the reason why "[/XYZ 0 0 null]" won't work either...



  public void addLink(Rectangle2D bounds, AffineTransform trans, String
dest, int linkType) {
        if (!pdfDoc.getProfile().isAnnotationAllowed()) {
            return;
        }
        preparePainting();
        AffineTransform at = getTransform();
        Shape b = at.createTransformedShape(bounds);
        b = trans.createTransformedShape(b);
        if (b != null) {
            Rectangle rect = b.getBounds();

            if (linkType != PDFLink.EXTERNAL) {
                String pdfdest = "/FitR " + dest;
                resourceContext.addAnnotation(
                    pdfDoc.getFactory().makeLink(rect, getPageReference(),
pdfdest));
            } else {
                resourceContext.addAnnotation(
                    pdfDoc.getFactory().makeLink(rect, dest, linkType, 0));
            }
        }
    }





Jeremias Maerki-2 wrote:
> 
> Yes, you'll need that fix I mentioned. You'll have to use the latest FOP
> Trunk directly from the Subversion repository.
> 
> On 18.02.2009 14:28:06 useratnab wrote:
>> 
>> Hey,
>> 
>> first of all I gotta say: a big thanks to you and your support, I got
>> some
>> things fixed, I thought I'd never find the answer for :confused:
>> 
>> But unfortunately there's still the "Cannot reference this object. It
>> doesn't have an object number" error, when calling:
>> 
>> g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
>> 
>> What fop are you using? 
>> Is that "SVG #svgView(viewBox())" bug-fix necessary, you mentioned
>> earlier?
>> 
>> Thanks again Tim
>> 
> <snip/> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22096684.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Making Links in PDF

Posted by useratnab <Ti...@gmx.net>.
I've tried to change the destination from

String pdfdest = "/FitR " + dest;
to
String pdfdest = "/Page /Next";

but this won't do it. I guess I have to dig deeper for it or do you have any
suggestions to link the prev. and next page?

Thanks




Jeremias Maerki-2 wrote:
> 
> Yes, you'll need that fix I mentioned. You'll have to use the latest FOP
> Trunk directly from the Subversion repository.
> 
> On 18.02.2009 14:28:06 useratnab wrote:
>> 
>> Hey,
>> 
>> first of all I gotta say: a big thanks to you and your support, I got
>> some
>> things fixed, I thought I'd never find the answer for :confused:
>> 
>> But unfortunately there's still the "Cannot reference this object. It
>> doesn't have an object number" error, when calling:
>> 
>> g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
>> 
>> What fop are you using? 
>> Is that "SVG #svgView(viewBox())" bug-fix necessary, you mentioned
>> earlier?
>> 
>> Thanks again Tim
>> 
> <snip/> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22099417.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Making Links in PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Yes, you'll need that fix I mentioned. You'll have to use the latest FOP
Trunk directly from the Subversion repository.

On 18.02.2009 14:28:06 useratnab wrote:
> 
> Hey,
> 
> first of all I gotta say: a big thanks to you and your support, I got some
> things fixed, I thought I'd never find the answer for :confused:
> 
> But unfortunately there's still the "Cannot reference this object. It
> doesn't have an object number" error, when calling:
> 
> g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
> 
> What fop are you using? 
> Is that "SVG #svgView(viewBox())" bug-fix necessary, you mentioned earlier?
> 
> Thanks again Tim
> 
<snip/> 


Jeremias Maerki


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


Re: Making Links in PDF

Posted by useratnab <Ti...@gmx.net>.
Hey,

first of all I gotta say: a big thanks to you and your support, I got some
things fixed, I thought I'd never find the answer for :confused:

But unfortunately there's still the "Cannot reference this object. It
doesn't have an object number" error, when calling:

g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);

What fop are you using? 
Is that "SVG #svgView(viewBox())" bug-fix necessary, you mentioned earlier?

Thanks again Tim



Jeremias Maerki-2 wrote:
> 
> On 18.02.2009 11:54:04 useratnab wrote:
>> 
>> Hey Jeremias,
>> 
>> thanks for looking on it. 
>> My intension is to add some internal links from one page to another like
>> it
>> is done with pdfmarks in ps-files. I'm drawing some "shapes" on a JPanel
>> and
>> these are painted onto the PDFDocumentGraphics2D. Now there should be a
>> frame around the shape, where a user can click on it to get redirected
>> onto
>> another page in the pdf where there is a detailed view of that shape.
>> 
>> Somehow 
>> pdf2D.addLink(rect, Tx, "/FitR", 1); 
>> 
>> won't work either.
> 
> Yeah, it should be something like :
> pdf2D.addLink(rect, Tx, "0 0 595 842", 1);
> 
> The four values make up the window for /FitR (which is implicit).
> 
> Here's a complete example I wrote to test this:
> 
>         File outputFile = new File("D:/out.pdf");
>         OutputStream out = new java.io.FileOutputStream(outputFile);
>         out = new java.io.BufferedOutputStream(out);
>         try {
>             PDFDocumentGraphics2D g2d = new PDFDocumentGraphics2D();
>             g2d.setDeviceDPI(PDFDocumentGraphics2D.NORMAL_PDF_RESOLUTION);
>             g2d.setGraphicContext(new GraphicContext());
>             Dimension pageSize = new Dimension(595, 842); //A4
>             g2d.setupDocument(out, pageSize.width, pageSize.height);
> 
>             AffineTransform pdfInitialTransform = new AffineTransform(
>                     1, 0, 0, -1, 0, pageSize.height);
> 
>             g2d.translate(20, 20);
> 
>             Rectangle rect = new Rectangle(20, 20, 40, 50);
>             g2d.setColor(Color.BLUE);
>             g2d.fill(rect);
> 
>             AffineTransform tx = new AffineTransform(pdfInitialTransform);
>             Rectangle2D targetRect = rect;
> 
>             //Works:
>             //g2d.addLink(targetRect, tx, "http://www.apache.org",
> PDFLink.EXTERNAL);
>             //Doesn't work
>             //g2d.addLink(targetRect, tx, "[/XYZ 0 0 null]",
> PDFLink.INTERNAL);
>             //Works:
>             g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);
> 
> 
>             g2d.finish();
>         } finally {
>             IOUtils.closeQuietly(out);
>         }
> 
> 
>> Thanks Tim
>> 
>> 
>> 
>> Jeremias Maerki-2 wrote:
>> > 
>> > Finally got to look into that. Two things:
>> > 
>> > 1. There was a bug in PDFFactory that caused the bug you mention. I've
>> > just fixed that: http://svn.apache.org/viewvc?rev=744690&view=rev
>> > But that only really fixes part of a problem with SVG
>> #svgView(viewBox())
>> > functionality (as mentioned in the commit message). For reference, the
>> > SVG test case to reproduce the problem can be found here:
>> >
>> http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/samples/tests/spec/linking/linkingViewBox.svg
>> > 
>> > 2. But you seem to want to use PDFDocumentGraphics2D outside an SVG
>> > context. Looking at the code I don't think that was foreseen. The code
>> > covers only the functionality required by above-mentioned #svgView
>> stuff,
>> > either external links or the viewBox() method (FitR in PDF). Things
>> like
>> > /XYZ cannot be done using PDFGraphics2D.addLink at the moment. For
>> that,
>> > the code would have to be refactored. 
>> > 
>> > If you pass "0 0 10 10" (or other 4 integers representing arguments to
>> > the /FitR function) as "dest" parameter into addLink(), it should work.
>> > But specifying the function itself will lead to errors in Acrobat
>> Reader.
>> > 
>> > Patches to improve that (and above SVG problem) are welcome.
>> > 
>> > On 13.02.2009 12:05:17 useratnab wrote:
>> >> 
>> >> Hello,
>> >> 
>> >> I get an "Exception in thread "AWT-EventQueue-0"
>> >> java.lang.IllegalArgumentException: Cannot reference this object. It
>> >> doesn't
>> >> have an object number"
>> >> 
>> >> Is there somehting wrong with using "addLink"?
>> >> 
>> >> <pre>
>> >> PDFDocumentGraphics2D 	pdf2D;
>> >> AffineTransform Tx = new AffineTransform( 1, 0, 0, 1, 0, 0);
>> >> 
>> >> Rectangle2D  rect = new Rectangle2D.Double ();
>> >> rect.setRect (20., 20., 100., 50.);		 
>> >> 			 
>> >> // 0 --> other files
>> >> // 1 --> another pos in same file
>> >> // 2 --> URL 
>> >> pdf2D.addLink(rect, Tx, "[/XYZ 0 0 null]", 1);
>> >> </pre>
>> >> 
>> >> Thank you
>> >> Tim
>> >> -- 
>> >> View this message in context:
>> >> http://www.nabble.com/Making-Links-in-PDF-tp21994320p21994320.html
>> >> Sent from the FOP - Users mailing list archive at Nabble.com.
>> >> 
>> > 
>> > 
>> > 
>> > Jeremias Maerki
>> > 
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Making-Links-in-PDF-tp21994320p22076342.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
>> 
> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22078708.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Making Links in PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 18.02.2009 11:54:04 useratnab wrote:
> 
> Hey Jeremias,
> 
> thanks for looking on it. 
> My intension is to add some internal links from one page to another like it
> is done with pdfmarks in ps-files. I'm drawing some "shapes" on a JPanel and
> these are painted onto the PDFDocumentGraphics2D. Now there should be a
> frame around the shape, where a user can click on it to get redirected onto
> another page in the pdf where there is a detailed view of that shape.
> 
> Somehow 
> pdf2D.addLink(rect, Tx, "/FitR", 1); 
> 
> won't work either.

Yeah, it should be something like :
pdf2D.addLink(rect, Tx, "0 0 595 842", 1);

The four values make up the window for /FitR (which is implicit).

Here's a complete example I wrote to test this:

        File outputFile = new File("D:/out.pdf");
        OutputStream out = new java.io.FileOutputStream(outputFile);
        out = new java.io.BufferedOutputStream(out);
        try {
            PDFDocumentGraphics2D g2d = new PDFDocumentGraphics2D();
            g2d.setDeviceDPI(PDFDocumentGraphics2D.NORMAL_PDF_RESOLUTION);
            g2d.setGraphicContext(new GraphicContext());
            Dimension pageSize = new Dimension(595, 842); //A4
            g2d.setupDocument(out, pageSize.width, pageSize.height);

            AffineTransform pdfInitialTransform = new AffineTransform(
                    1, 0, 0, -1, 0, pageSize.height);

            g2d.translate(20, 20);

            Rectangle rect = new Rectangle(20, 20, 40, 50);
            g2d.setColor(Color.BLUE);
            g2d.fill(rect);

            AffineTransform tx = new AffineTransform(pdfInitialTransform);
            Rectangle2D targetRect = rect;

            //Works:
            //g2d.addLink(targetRect, tx, "http://www.apache.org", PDFLink.EXTERNAL);
            //Doesn't work
            //g2d.addLink(targetRect, tx, "[/XYZ 0 0 null]", PDFLink.INTERNAL);
            //Works:
            g2d.addLink(targetRect, tx, "0 0 595 842", PDFLink.INTERNAL);


            g2d.finish();
        } finally {
            IOUtils.closeQuietly(out);
        }


> Thanks Tim
> 
> 
> 
> Jeremias Maerki-2 wrote:
> > 
> > Finally got to look into that. Two things:
> > 
> > 1. There was a bug in PDFFactory that caused the bug you mention. I've
> > just fixed that: http://svn.apache.org/viewvc?rev=744690&view=rev
> > But that only really fixes part of a problem with SVG #svgView(viewBox())
> > functionality (as mentioned in the commit message). For reference, the
> > SVG test case to reproduce the problem can be found here:
> > http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/samples/tests/spec/linking/linkingViewBox.svg
> > 
> > 2. But you seem to want to use PDFDocumentGraphics2D outside an SVG
> > context. Looking at the code I don't think that was foreseen. The code
> > covers only the functionality required by above-mentioned #svgView stuff,
> > either external links or the viewBox() method (FitR in PDF). Things like
> > /XYZ cannot be done using PDFGraphics2D.addLink at the moment. For that,
> > the code would have to be refactored. 
> > 
> > If you pass "0 0 10 10" (or other 4 integers representing arguments to
> > the /FitR function) as "dest" parameter into addLink(), it should work.
> > But specifying the function itself will lead to errors in Acrobat Reader.
> > 
> > Patches to improve that (and above SVG problem) are welcome.
> > 
> > On 13.02.2009 12:05:17 useratnab wrote:
> >> 
> >> Hello,
> >> 
> >> I get an "Exception in thread "AWT-EventQueue-0"
> >> java.lang.IllegalArgumentException: Cannot reference this object. It
> >> doesn't
> >> have an object number"
> >> 
> >> Is there somehting wrong with using "addLink"?
> >> 
> >> <pre>
> >> PDFDocumentGraphics2D 	pdf2D;
> >> AffineTransform Tx = new AffineTransform( 1, 0, 0, 1, 0, 0);
> >> 
> >> Rectangle2D  rect = new Rectangle2D.Double ();
> >> rect.setRect (20., 20., 100., 50.);		 
> >> 			 
> >> // 0 --> other files
> >> // 1 --> another pos in same file
> >> // 2 --> URL 
> >> pdf2D.addLink(rect, Tx, "[/XYZ 0 0 null]", 1);
> >> </pre>
> >> 
> >> Thank you
> >> Tim
> >> -- 
> >> View this message in context:
> >> http://www.nabble.com/Making-Links-in-PDF-tp21994320p21994320.html
> >> Sent from the FOP - Users mailing list archive at Nabble.com.
> >> 
> > 
> > 
> > 
> > Jeremias Maerki
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22076342.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 
> 




Jeremias Maerki


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


Re: Making Links in PDF

Posted by useratnab <Ti...@gmx.net>.
Hey Jeremias,

thanks for looking on it. 
My intension is to add some internal links from one page to another like it
is done with pdfmarks in ps-files. I'm drawing some "shapes" on a JPanel and
these are painted onto the PDFDocumentGraphics2D. Now there should be a
frame around the shape, where a user can click on it to get redirected onto
another page in the pdf where there is a detailed view of that shape.

Somehow 
pdf2D.addLink(rect, Tx, "/FitR", 1); 

won't work either.

Thanks Tim



Jeremias Maerki-2 wrote:
> 
> Finally got to look into that. Two things:
> 
> 1. There was a bug in PDFFactory that caused the bug you mention. I've
> just fixed that: http://svn.apache.org/viewvc?rev=744690&view=rev
> But that only really fixes part of a problem with SVG #svgView(viewBox())
> functionality (as mentioned in the commit message). For reference, the
> SVG test case to reproduce the problem can be found here:
> http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/samples/tests/spec/linking/linkingViewBox.svg
> 
> 2. But you seem to want to use PDFDocumentGraphics2D outside an SVG
> context. Looking at the code I don't think that was foreseen. The code
> covers only the functionality required by above-mentioned #svgView stuff,
> either external links or the viewBox() method (FitR in PDF). Things like
> /XYZ cannot be done using PDFGraphics2D.addLink at the moment. For that,
> the code would have to be refactored. 
> 
> If you pass "0 0 10 10" (or other 4 integers representing arguments to
> the /FitR function) as "dest" parameter into addLink(), it should work.
> But specifying the function itself will lead to errors in Acrobat Reader.
> 
> Patches to improve that (and above SVG problem) are welcome.
> 
> On 13.02.2009 12:05:17 useratnab wrote:
>> 
>> Hello,
>> 
>> I get an "Exception in thread "AWT-EventQueue-0"
>> java.lang.IllegalArgumentException: Cannot reference this object. It
>> doesn't
>> have an object number"
>> 
>> Is there somehting wrong with using "addLink"?
>> 
>> <pre>
>> PDFDocumentGraphics2D 	pdf2D;
>> AffineTransform Tx = new AffineTransform( 1, 0, 0, 1, 0, 0);
>> 
>> Rectangle2D  rect = new Rectangle2D.Double ();
>> rect.setRect (20., 20., 100., 50.);		 
>> 			 
>> // 0 --> other files
>> // 1 --> another pos in same file
>> // 2 --> URL 
>> pdf2D.addLink(rect, Tx, "[/XYZ 0 0 null]", 1);
>> </pre>
>> 
>> Thank you
>> Tim
>> -- 
>> View this message in context:
>> http://www.nabble.com/Making-Links-in-PDF-tp21994320p21994320.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>> 
> 
> 
> 
> Jeremias Maerki
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p22076342.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Making Links in PDF

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Finally got to look into that. Two things:

1. There was a bug in PDFFactory that caused the bug you mention. I've
just fixed that: http://svn.apache.org/viewvc?rev=744690&view=rev
But that only really fixes part of a problem with SVG #svgView(viewBox())
functionality (as mentioned in the commit message). For reference, the
SVG test case to reproduce the problem can be found here:
http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/samples/tests/spec/linking/linkingViewBox.svg

2. But you seem to want to use PDFDocumentGraphics2D outside an SVG
context. Looking at the code I don't think that was foreseen. The code
covers only the functionality required by above-mentioned #svgView stuff,
either external links or the viewBox() method (FitR in PDF). Things like
/XYZ cannot be done using PDFGraphics2D.addLink at the moment. For that,
the code would have to be refactored. 

If you pass "0 0 10 10" (or other 4 integers representing arguments to
the /FitR function) as "dest" parameter into addLink(), it should work.
But specifying the function itself will lead to errors in Acrobat Reader.

Patches to improve that (and above SVG problem) are welcome.

On 13.02.2009 12:05:17 useratnab wrote:
> 
> Hello,
> 
> I get an "Exception in thread "AWT-EventQueue-0"
> java.lang.IllegalArgumentException: Cannot reference this object. It doesn't
> have an object number"
> 
> Is there somehting wrong with using "addLink"?
> 
> <pre>
> PDFDocumentGraphics2D 	pdf2D;
> AffineTransform Tx = new AffineTransform( 1, 0, 0, 1, 0, 0);
> 
> Rectangle2D  rect = new Rectangle2D.Double ();
> rect.setRect (20., 20., 100., 50.);		 
> 			 
> // 0 --> other files
> // 1 --> another pos in same file
> // 2 --> URL 
> pdf2D.addLink(rect, Tx, "[/XYZ 0 0 null]", 1);
> </pre>
> 
> Thank you
> Tim
> -- 
> View this message in context: http://www.nabble.com/Making-Links-in-PDF-tp21994320p21994320.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 



Jeremias Maerki


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