1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QPrinter printer(QPrinter::PrinterResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation(QPrinter::Portrait);
printer.setPaperSize(QPrinter::A4);
//printer.setOutputFileName(fileName);
printer.setOutputFormat(QPrinter::NativeFormat);
QPrintDialog orintDialogue(&printer);
if(orintDialogue.exec() == 1)
{
QTextDocument doc;
QString html("<html><head><meta charset='utf-8' /><style>img{width:50px; height:50px;} ul{list-style-type: none;font-size:1.5em; width:22%; height:200px; float:right; margin-right:100px; margin-bottom:10px; margin-top:25px;}#p{margin-top:100px; margin-bottom:0px;} #titre_principal{color:blue; width:30%; margin-right:68%;} #logo{width:20%; height:150px; margin-bottom: 0px;} h1{font-size:2.2em; font-weight:normal; margin-left:-17px; width:20%;} h2{font-size:1.3em; font-weight:normal; margin-top:-30px; margin-bottom:50px; margin-left:30px;} header{font-family: Helvetica, Arial, serif;}</style><title>Premiers tests du CSS</title></head><body><header><nav><ul><li> Douala, le .............</li><li><div id='p'>Le Principal</li></ul></nav><div id='titre_principal'><img src='C:/Users/Gaël/Pictures/modif/logo.jpg' alt='Logo college' id='logo' /><h1>I.P.F.</h1><h2>Institut Polyvalent Fosso</h2></div></header></body></html>");
Qt::convertFromPlainText(html);
doc.setHtml(html);
//doc.setPageSize(printer.pageRect().size()); //permet de cacher le numero de page lord de l'impression
doc.print(&printer);
}
return a.exec();
} |
Partager