[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kviewshell/plugins/pdf
From: Wilfried Huss <Wilfried.Huss () gmx ! at>
Date: 2006-06-03 19:32:22
Message-ID: 1149363142.403554.26236.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 547895 by whuss:
Add basic hyperlink support to the PDF plugin.
M +40 -2 pdfRenderer.cpp
--- trunk/KDE/kdegraphics/kviewshell/plugins/pdf/pdfRenderer.cpp #547894:547895
@@ -39,6 +39,7 @@
#include "documentWidget.h"
+#include "hyperlink.h"
#include "kvs_debug.h"
#include "pagetransition.h"
#include "pdfRenderer.h"
@@ -119,7 +120,12 @@
Poppler::Page* pdfPage = document->page(pageNumber);
if (page)
{
- image = pdfPage->splashRenderToImage(res, res);
+ if (page->getId().isThumbnail)
+ image = pdfPage->splashRenderToImage(res, res);
+ else
+ {
+ image = pdfPage->splashRenderToImage(res, res, -1, -1, -1, -1, true);
+ }
// Create Text information
fillInText(page, pdfPage, res);
@@ -134,6 +140,38 @@
page->setTransition(transition);
}
+
+ if (!page->getId().isThumbnail)
+ {
+ // Set hyperlinks
+ QList<Poppler::Link*> links = pdfPage->links();
+
+ for (int i = 0; i < links.size(); i++)
+ {
+ Poppler::Link* link = links[i];
+ if (link->linkType() == Poppler::Link::Goto)
+ {
+ QRect area = link->linkArea().normalized().toRect();
+ Poppler::LinkGoto* gotoLink = dynamic_cast<Poppler::LinkGoto*>(link);
+ if (!gotoLink)
+ {
+ kError() << "Cast to Poppler::LinkGoto failed." << endl;
+ continue;
+ }
+
+ Poppler::LinkDestination destination = gotoLink->destination();
+ QString url(destination.toString());
+ Length y;
+ y.setLength_in_pixel(destination.top(), res);
+ Anchor anchor(destination.pageNumber(), y);
+ //kDebug() << "Anchor: url = " << destination.toString() << " (page = " << \
destination.pageNumber() << ", y = " << destination.top() << ")" << endl; + \
//kDebug() << "Hyperlink: (" << area.x() << ", " << area.y() << ", " << area.width() \
<< ", " << area.height() << ")" << endl; + anchorList[url] = anchor;
+ Hyperlink hyperlink(area.bottom(), area, url);
+ page->hyperLinkList.push_back(hyperlink);
+ }
+ }
+ }
delete pdfPage;
}
@@ -144,7 +182,7 @@
return;
}
-
+
page->setImage(image);
#ifdef PDFSYNC_DEBUG
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic