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);
    	writer.setFormat("plaintext");
    	auto codec = QTextCodec::codecForName("latin1");
    	writer.setCodec(codec);
    	return writer.write(report.get()) ? sFileName: QString();
    }
    

  • Lifetime Qt Champion

    Hi,

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.