QList<BookBlock::ItemInfo> BookImageBlock::createItems(const QPointF &position, int line) const
{
    Q_UNUSED(line);

    if (m_data->size.isValid()) {
        return QList<ItemInfo>() << ItemInfo {
            QStringLiteral("image"),
            {
                { "x", (pageWidth() - m_imageSize.width()) / 2 },
                { "y", position.y() },
                { "width", m_imageSize.width() },
                { "height", m_imageSize.height() },
                { "source", m_data->source }
            }
        };
    }

    return QList<ItemInfo>();
}
Exemple #2
0
WPaintDevice *WPdfRenderer::startPage(int page)
{
    if (page > 0)
        page_ = createPage(page);

#ifndef WT_TARGET_JAVA
    HPDF_Page_Concat (page_, 72.0f/dpi_, 0, 0, 72.0f/dpi_, 0, 0);
#endif

    WPdfImage *device = new WPdfImage(pdf_, page_, 0, 0,
                                      pageWidth(page), pageHeight(page));
#ifdef WT_TARGET_JAVA
    WTransform deviceTransform;
    deviceTransform.scale(72.0f/dpi_, 72.0f/dpi_);
    device->setDeviceTransform(deviceTransform);
#endif //WT_TARGET_JAVA

    for (unsigned i = 0; i < fontCollections_.size(); ++i)
        device->addFontCollection(fontCollections_[i].directory,
                                  fontCollections_[i].recursive);

    return device;
}