QPdfWriter convert html without breaking pages
Unsolved
General and Desktop
-
Hello,
I have a problem i define the margin with QPdfWriter and i create a html document but it does not break the pages when we reach out of the margins. I have defined the margins in thousands of ways but the method does not break the html when it reaches the margin. It goes out of the margins. and if i break the line using html with <div style="page-break-after:always"></div>, from this point it's not shown in the pdf. It is very weird. Is it a bug? . Thank you very much.
QPdfWriter pdfWriter("pdf_generated.pdf"); pdfWriter.setPageSize(QPagedPaintDevice::A4); pdfWriter.setPageMargins(QMargins(30, 30, 30, 30)); const qreal horizontalMarginMM = 2.0; // 2mm margin on each side const qreal verticalMarginMM = 2.0; QPagedPaintDevice::Margins margins; margins.left = margins.right = horizontalMarginMM; margins.bottom = margins.bottom = verticalMarginMM; pdfWriter.setMargins(margins); document.setHtml(html); QFont font; font.setPointSize(8); document.setDefaultFont(font); QPainter painter; painter.begin(&pdfWriter); document.drawContents(&painter);
-
Hi,
What version of Qt are you using ?
Can you provide a complete minimal compilable exemple showing that behaviour ?