File indexing completed on 2024-04-14 10:50:19

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2012 Martin Kuettler <martin.kuettler@gmail.com>
0004 */
0005 
0006 #ifndef RENDERER_H
0007 #define RENDERER_H
0008 
0009 #include <QTextDocument>
0010 #include <QTextImageFormat>
0011 #include <QPixmap>
0012 #include <QSizeF>
0013 #include <QUrl>
0014 #include "latexrenderer.h"
0015 
0016 namespace Cantor
0017 {
0018 class RendererPrivate;
0019 
0020 class CANTOR_EXPORT Renderer
0021 {
0022   public:
0023     Renderer();
0024     ~Renderer();
0025 
0026     enum FormulaProperties {CantorFormula = 1, ImagePath = 2, Code = 3,
0027                             Delimiter = 4};
0028     enum FormulaType {LatexFormula = Cantor::LatexRenderer::LatexMethod,
0029                       MmlFormula = Cantor::LatexRenderer::MmlMethod};
0030     enum Method {PDF, EPS};
0031 
0032     QTextImageFormat render(QTextDocument *document, const Cantor::LatexRenderer* latex);
0033     QTextImageFormat render(QTextDocument *document, Method method, const QUrl& url, const QString& uuid);
0034 
0035     void setScale(qreal scale);
0036     qreal scale();
0037 
0038     void useHighResolution(bool b);
0039 
0040     QSizeF renderToResource(QTextDocument *document, Method method, const QUrl& url, const QUrl& internal);
0041 
0042     QImage renderToImage(const QUrl& url, Method method, QSizeF* size = nullptr);
0043     static QImage epsRenderToImage(const QUrl& url, double scale, bool useHighRes, QSizeF* size = nullptr, QString* errorReason = nullptr);
0044     static QImage pdfRenderToImage(const QUrl& url, double scale, bool useHighRes, QSizeF* size = nullptr, QString* errorReason = nullptr);
0045 
0046   private:
0047     RendererPrivate* d;
0048 };
0049 
0050 }
0051 
0052 #endif //RENDERER_H