The code basically boils down to: // create poppler pdf document This reflects an additional dependency on cairo, so I went ahead and converted the cairo based code to Qt, using libpopper-qt4. So I looked into the source code of pdf2svg and saw that it uses libpoppler with Cairo. The result was perfect: InkScape renders the svg file exactly like Okular renders the pdf file: So I first tested to convert the pdf to svg with this tool and then view it in InkScape. In theory, I then can use QSvgRenderer to load and render the SVG on-the-fly using QSvgRenderer::render(QPainter*, …). Next, I found pdf2svg that converts a pdf file into the scalable vector graphics format svg. This works, but whenever you scale the canvas the result looks ugly since png is not a vector graphic. So I could convert the dvi file to png through QProcess+dvipng, and then display the png file. It even supports transparent backgrounds. So I searched the net and found dvipng, which converts a dvi file to png. This works in principal, but there is a licensing problem: libpoppler is GPL, and I want to use it in a LGPL library. So I thought it would be nice and accurate to compile the TeX code to produce a pdf, and then use libpoppler-qt4 to draw the pdf. In a project I’m currently working on I need to display the result of TeX code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |