Qt World Summit: Register Today!

QTextDocumentWriter - save To ASCII

  • Hi All,
    I have a filled QTextDocument. This prints fine to pdf. It contains text but also tables.

    I would like to save this to plain ASCII Text. This works fine but all lines are behind eachother in the file. So there is no CR/ LF inserted after each line. I AM ON WINDOWS 10 64 QT 5.3.
    I probably need a codec that adds CR/LF to the end of the lines. Any ideas? thanks!

    my code:

    QString ReportGenerator::saveReportToASCII(const QString& sFileName, std::shared_ptr<QTextDocument> report)
    	QTextDocumentWriter writer(sFileName);
    	auto codec = QTextCodec::codecForName("latin1");
    	return writer.write(report.get()) ? sFileName: QString();

  • Lifetime Qt Champion


    Can you post a text sample to try and reproduce what you get ?

Log in to reply