Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am using QTextDocument to write html code and convert it to pdf file

code as below:

QPrinter html_printer(QPrinter::ScreenResolution);
html_printer.setPageSize(QPrinter::A4);
html_printer.setOutputFormat(QPrinter::PdfFormat);

html_printer.setOutputFileName(_file_path);

QString q_h5 = "<....>"    
QTextDocument text_document;    
text_document.setHtml(q_h5);    
html_printer.newPage();    
text_document.print(&html_printer);
text_document.end();


I found that it's impossible to set the font size and family to some paragraph.

What I have tried:

I have tried

q_h5 = "<p style=\"color:red;font-size:16px;\">aaaaaaaabbbbbb</p>"
     
q_h5 = "<font size =\"6\">aaaaaaaabbbbbbb"
     
q_h5 = "<p style=\"font-family:verdana;font-size:200%;color:green\">"


only color can be changed ,font size and family can't take effect.
Posted
Updated 7-Mar-17 21:54pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900