Qt World Summit: Submit your Presentation

QPdfWriter convert html without breaking pages

  • 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.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;
    QFont font;
    QPainter painter;

  • Lifetime Qt Champion


    What version of Qt are you using ?
    Can you provide a complete minimal compilable exemple showing that behaviour ?

Log in to reply