Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Print multiple tabs to single pdf

$
0
0
Alright, so I figured out how to access the data of a custom component: ‘property alias’ did the magic :) Now for the second part (creating a pdf), I am almost done, but I have a weird issue: My goal is to have several tables with only a single pixel border…unfortunately ‘border-collapse’ is not supported by QT’s html subset. Kind of a workaround is to set the cell spacing to -1. However, then there is a weird issue with the colors/borders, as can be seen in the following pictures: The code to produced the above pdf is: QTextDocument doc2;     QTextCursor myCursor(&doc2);     myCursor.insertText("This is the first page");       QTextTableFormat myTableFormat;     myTableFormat.setBorder( QTextFrameFormat::BorderStyle_Solid );     myTableFormat.setBorder(1);     myTableFormat.setBorderBrush(QBrush(QColor(200, 200, 200)));     myTableFormat.setCellPadding(0);     myTableFormat.setCellSpacing(-1);     myTableFormat.setWidth( QTextLength(QTextLength::PercentageLength, 100) );     myTableFormat.setAlignment( Qt::AlignLeft );     myCursor.insertTable(4, 2, myTableFormat);       printer.setOutputFileName(currPath + "/test02.pdf");     printer.setOutputFormat( QPrinter::PdfFormat );     printer.setPaperSize(QPrinter::A4);     printer.setPageMargins( 20, 20, 20, 20, QPrinter::Millimeter);     doc2.print(&printer);     printer.newPage(); I tested different colors and my impression is that the table always consists of two colors…Is there a way to assign these colors? I know I could use the webkit as well for printing (https://qt-project.org/forums/viewthread/22137). However, the dll is about 30Mb and I would like to avoid it if possible.

Viewing all articles
Browse latest Browse all 4972

Trending Articles