Hi,
I'm trying to understand how to work with internal links in PDF.
Here is the simple code:
#include <QTextDocument>
#include <QPdfWriter>
#include <QApplication>
#include <QTextCharFormat>
#include <QTextCursor>
int main( int argc, char ** argv )
{
QApplication app( argc, argv );
QPdfWriter pdf( "/home/igor/test.pdf" );
QTextDocument doc;
QTextCharFormat fmt;
fmt.setAnchorName( "title" );
fmt.setAnchor( true );
QTextCursor c( &doc );
c.insertText(
"Title\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", fmt );
QTextCharFormat link;
link.setAnchorHref( "title" );
link.setAnchor( true );
c.insertText( "Go to title", link );
doc.print( &pdf );
return 0;
}
But when I click on "Go to title" in PDF, viewer tries to open file
"title" instead of navigating through the PDF.
How to correctly set anchors and links in QTextDocument?
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest