I'm running into an issue when trying to create clickable links within a PDF generated with wxPdfDocument. The problem is that, during generation of a page, I'll do something like:
Code: Select all
int linknum = m_pdf->AddLink();
m_pdf->Link(x, y, width, height, page_link);
which works fine in that it creates a clickable link — but an issue arises if I'm generating this on page 1 and trying to link to something on page 2, the link is invalid. I think this is because the links are added when closing the page, but since no object reference yet exists for page 2, it can't resolve it properly.
Has anyone done anything like this and gotten it to work?
For example, take a look at the sample "tutorial 6" coming with wxPdfDocument. It demonstrates how to link from page 1 to page 2.
For internal link references you always have to use method AddLink first to get the link reference number, which you then use on setting the active link area and on setting the link target (using method SetLink). If you know the link target in advance, you can use method SetLink of the class wxPdfLink. Alternatively you can use method SetLink of class wxPdfDocument when you process the page on which the target of the link is located.
Method SetLink of class wxPdfDocument can be used to set the link target as long as you haven't called method Close, or SaveAsFile, or CloseAndGetBuffer, that is, as long as you haven't finished producing PDF page content.
If it still doesn't work for you, show some source code exposing the problem.