On Thu, Sep 21, 2017 at 11:43:29AM +0200, Stephan Witt wrote:
> 
> My question (again): how can I circumvent this and configure „my“ converter
> so it’s used to convert the SVG to PNG and run pdflatex with the PNG instead
> of the PDF (which would be rasterized anyway, when ImageMagick is used for
> SVG to PDF conversion).

Maybe you can use again Qt to convert the SVG to a rasterized PDF.
See the attached example. Note that this is not actually limited
to SVG but is able to convert to PDF any format natively understood
by Qt (even if the original vector format is lost).

-- 
Enrico
/*
set cflags=`env PKG_CONFIG_PATH=/usr/local/qt5/lib/pkgconfig pkg-config 
--cflags Qt5Widgets`
set libs=`env PKG_CONFIG_PATH=/usr/local/qt5/lib/pkgconfig pkg-config --libs 
--static Qt5Widgets`
g++ -std=gnu++11 $cflags qsvg2pdf.cpp -o qsvg2pdf $libs
*/
#include <iostream>
#include <QApplication>
#include <QPainter>
#include <QPdfWriter>

int main(int argc, char **argv)
{
    if (argc != 3) {
        std::cerr << "Usage: " << argv[0]
                  << " input.svgz output.pdf" << std::endl;
        return 1;
    }
    QApplication app(argc, argv);
    QPixmap pm;
    if (!pm.load(QString::fromLocal8Bit(argv[1]))) {
        std::cerr << "Cannot load image " << argv[1] << std::endl;
        return 1;
    }
    QSize size = pm.size();
    QPdfWriter pdfwriter(QString::fromLocal8Bit(argv[2]));
    int dpi = pdfwriter.logicalDpiX();
    QPageSize pagesize(size * qreal(72.0 / dpi));
    QMarginsF margins(0, 0, 0, 0);
    QPageLayout pagelayout(pagesize, QPageLayout::Portrait, margins);
    pdfwriter.setPageLayout(pagelayout);
    QPainter painter(&pdfwriter);
    painter.drawPixmap(0, 0, pm);
    painter.end();
    return 0;
}

Reply via email to