Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QWebEnginePage print pdf in Landscape



  • I'm trying to save a pdf file from QWebEnginePage in Landscape ,

     QWebEnginePage *m_page;
    
     m_page->setHtml(m_inputPath);
    
    m_page->printToPdf(m_outputPath, QPageLayout( QPageSize(QPageSize::A4) ,
                                                       QPageLayout::Landscape,
                                                      QMarginsF()) );
    
    
    

    but Landscape mode not working and print always in Portrait.
    What wrong?



  • I made a little mistake.
    This CSS code in my html file caused this problem.

    @page {
                size: 8.27in 11.69in;
                margin: 0.86in;
            }
    

Log in to reply