mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Some bugfixing
This commit is contained in:
@@ -18,14 +18,28 @@
|
||||
#include "outputpreviewdialog.h"
|
||||
#include "ui_outputpreviewdialog.h"
|
||||
|
||||
#include "pdfcms.h"
|
||||
#include "pdfrenderer.h"
|
||||
#include "pdfdrawspacecontroller.h"
|
||||
|
||||
namespace pdfplugin
|
||||
{
|
||||
|
||||
OutputPreviewDialog::OutputPreviewDialog(QWidget* parent) :
|
||||
OutputPreviewDialog::OutputPreviewDialog(const pdf::PDFDocument* document, pdf::PDFWidget* widget, QWidget* parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::OutputPreviewDialog)
|
||||
ui(new Ui::OutputPreviewDialog),
|
||||
m_inkMapper(document),
|
||||
m_document(document),
|
||||
m_widget(widget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->pageIndexScrollBar->setMinimum(1);
|
||||
ui->pageIndexScrollBar->setValue(1);
|
||||
ui->pageIndexScrollBar->setMaximum(int(document->getCatalog()->getPageCount()));
|
||||
|
||||
m_inkMapper.createSpotColors(true);
|
||||
updateImage();
|
||||
}
|
||||
|
||||
OutputPreviewDialog::~OutputPreviewDialog()
|
||||
@@ -33,4 +47,32 @@ OutputPreviewDialog::~OutputPreviewDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OutputPreviewDialog::updateImage()
|
||||
{
|
||||
const pdf::PDFPage* page = m_document->getCatalog()->getPage(ui->pageIndexScrollBar->value() - 1);
|
||||
if (!page)
|
||||
{
|
||||
ui->imageLabel->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
QRectF pageRect = page->getRotatedMediaBox();
|
||||
QSizeF pageSize = pageRect.size();
|
||||
pageSize.scale(ui->imageLabel->width(), ui->imageLabel->height(), Qt::KeepAspectRatio);
|
||||
QSize imageSize = pageSize.toSize();
|
||||
|
||||
if (!imageSize.isValid())
|
||||
{
|
||||
ui->imageLabel->setPixmap(QPixmap());
|
||||
}
|
||||
|
||||
QMatrix pagePointToDevicePoint = pdf::PDFRenderer::createPagePointToDevicePointMatrix(page, QRect(QPoint(0, 0), imageSize));
|
||||
pdf::PDFDrawWidgetProxy* proxy = m_widget->getDrawWidgetProxy();
|
||||
pdf::PDFCMSPointer cms = proxy->getCMSManager()->getCurrentCMS();
|
||||
pdf::PDFTransparencyRenderer renderer(page, m_document, proxy->getFontCache(), cms.data(), proxy->getOptionalContentActivity(), &m_inkMapper, pagePointToDevicePoint);
|
||||
|
||||
renderer.beginPaint(imageSize);
|
||||
renderer.processContents();
|
||||
renderer.endPaint();
|
||||
}
|
||||
|
||||
} // namespace pdfplugin
|
||||
|
@@ -18,6 +18,10 @@
|
||||
#ifndef OUTPUTPREVIEWDIALOG_H
|
||||
#define OUTPUTPREVIEWDIALOG_H
|
||||
|
||||
#include "pdfdocument.h"
|
||||
#include "pdfdrawwidget.h"
|
||||
#include "pdftransparencyrenderer.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui
|
||||
@@ -33,11 +37,16 @@ class OutputPreviewDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OutputPreviewDialog(QWidget* parent);
|
||||
explicit OutputPreviewDialog(const pdf::PDFDocument* document, pdf::PDFWidget* widget, QWidget* parent);
|
||||
virtual ~OutputPreviewDialog() override;
|
||||
|
||||
private:
|
||||
void updateImage();
|
||||
|
||||
Ui::OutputPreviewDialog* ui;
|
||||
pdf::PDFInkMapper m_inkMapper;
|
||||
const pdf::PDFDocument* m_document;
|
||||
pdf::PDFWidget* m_widget;
|
||||
};
|
||||
|
||||
} // namespace pdf
|
||||
|
@@ -48,7 +48,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QScrollBar" name="verticalScrollBar">
|
||||
<widget class="QScrollBar" name="pageIndexScrollBar">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
|
@@ -62,7 +62,7 @@ std::vector<QAction*> OutputPreviewPlugin::getActions() const
|
||||
|
||||
void OutputPreviewPlugin::onOutputPreviewTriggered()
|
||||
{
|
||||
OutputPreviewDialog dialog(m_widget);
|
||||
OutputPreviewDialog dialog(m_document, m_widget, m_widget);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user