Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在pdf中显示中文/日文/韩文字体(来自QTextDocument)_Qt_Pdf_Chinese Locale_Qtextdocument - Fatal编程技术网

如何在pdf中显示中文/日文/韩文字体(来自QTextDocument)

如何在pdf中显示中文/日文/韩文字体(来自QTextDocument),qt,pdf,chinese-locale,qtextdocument,Qt,Pdf,Chinese Locale,Qtextdocument,我在从QTextDocument生成的.pdf中显示中文/日文/韩文字符时遇到问题。字符在QTextDocument小部件中显示良好。但是,然后我将文档输出到一个.pdf,它们的C/J/K字符不会出现。 在我寻找解决方案的过程中,我看到了很多关于安装字体系列的建议。但是,如果字符出现在屏幕上的小部件中,那么这并不意味着字体系列安装正确。所以,也许我的问题更多的是关于安装字体系列,而不是显示字符。在这一点上我不确定 示例代码: QTextDocument* pDocument = mpText

我在从QTextDocument生成的.pdf中显示中文/日文/韩文字符时遇到问题。字符在QTextDocument小部件中显示良好。但是,然后我将文档输出到一个.pdf,它们的C/J/K字符不会出现。 在我寻找解决方案的过程中,我看到了很多关于安装字体系列的建议。但是,如果字符出现在屏幕上的小部件中,那么这并不意味着字体系列安装正确。所以,也许我的问题更多的是关于安装字体系列,而不是显示字符。在这一点上我不确定

示例代码:

  QTextDocument* pDocument = mpTextEdit->document();
  QTextCursor cursor(pDocument);

  QFont defaultFont("Calibri", 12);
  pDocument->setDefaultFont(defaultFont);
  QString str = "<h1>Hello, World!</h1>
  str += "<br/>";
  str += QString("名称不能为空。");
  str += "<br/>";
  str += "ABC";
  str += "</p>";
  pDocument->setHtml(str);

// Print to .pdf
QPrinter printer(QPrinter::PrinterResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4);
printer.setOutputFileName("c:/temp/foo.pdf");
printer.setFontEmbeddingEnabled(true);
pDocument->setPageSize(printer.pageRect().size()); 
pDocument->print(&printer);
QTextDocument*pDocument=mptextdedit->document();
QTextCursor(pDocument);
QFont defaultFont(“Calibri”,12);
p文档->设置默认字体(默认字体);
QString str=“你好,世界!
str+=“
”; str+=QString(“名称不能为空。"); str+=“
”; str+=“ABC”; str+=“

”; pDocument->setHtml(str); //打印至.pdf QPrinter打印机(QPrinter::PrinterResolution); 打印机.setOutputFormat(QPrinter::PdfFormat); 打印机。设置纸张大小(QPrinter::A4); printer.setOutputFileName(“c:/temp/foo.pdf”); 打印机。setFontEmbeddingEnabled(真); pDocument->setPageSize(printer.pageRect().size()); p文档->打印(&打印机);
任何帮助都将不胜感激

迈克·德姆博吉