[poppler] Url links

vidhyapria.arunkumar at nokia.com vidhyapria.arunkumar at nokia.com
Thu Aug 5 06:28:14 PDT 2010


Hi

With NULL , I meant an empty list returned.
And this happens when I click on an url link in my pdf document.

Here's a code snippet of what  I do, shortTap is the slot invoked on tapping the page

void PdfPage::shortTap(QRectF rect)
{
    PdfPageWidget *widget=getWidgetAt(rect.center(), PDFPAGEWIDGET);  // func. definition below

    if (0 != widget) {
        QRectF widgetRect = rect;
        QPointF widgetPoint = mapToItem(widget, rect.center());
        widgetRect.moveCenter(widgetPoint);
        
        if (widget->linkTaped(widgetRect))    // func. definition below
        {
           ....
        }
    }    
}


PdfPageWidget * PdfPage::getWidgetAt(QPointF point, const QString &widgetName)
{
    PdfPageWidget *widget=0;
    QList<QGraphicsItem *> visibleItems;
    if (0 != scene()) {
          visibleItems = scene()->items(mapToScene(point));
    }      
    
    foreach(QGraphicsItem * item, visibleItems) { 
        PdfPageWidget *newitem = qgraphicsitem_cast<PdfPageWidget *>(item);
        if (0 != newitem &&  widgetName == newitem->objectName()) {
            widget = newitem;
            break;
        }
    }
    return widget;
}

bool PdfPageWidget::linkTaped(QRectF rect)
{
    bool retval = false;
    Poppler::Link *link=0;    
 
    QList<Poppler::Link *> links = loader->getLinks(pageIndex);
    if ( links.empty())
      qDebug() << "links is empty"; 
    ..... 
    .....

}

QList<Poppler::Link *> PdfLoader::getLinks(int pageIndex)
{
    QList<Poppler::Link *> list;
    PdfLoaderPrivate *data = getPageData(pageIndex);

    if (0 != data) {    
        list = data->page->links();   // This returns an empty list always. This function invokes the QList<Link*> Page::links() from qt4/src/poppler-page.cc
    }
    if ( list.empty())
      qDebug() << "list is empty";

    return list;
}
 
vidhya



More information about the poppler mailing list