如何解决RichView导出Html看不到中文问题

解决RichViewEdit导出HTML文件中文码问题
本文详细介绍了使用RichViewEdit组件导出HTML文件时遇到中文码问题的解决方案,通过设置特定参数即可解决。具体步骤及参数解释详述于此。

1、 问题描述:

调用RichViewEdit.SaveHTMLToStream的方法可以生成html文件,但是默认导出的不是中文码,而是ASCII码。如何解决这个问题呢?

2、解决办法:

这个方法的最后一个参数可以用来解决这个问题

SaveHTMLToStream(Stream: TStream; const Path, Title, ImagesPrefix: String; Options: TRVSaveOptions):Boolean;

将Options参数设置为[rvsoUTF8]即可,参数说明如下:

{ Options for saving HTML files, TCustomRichView.SaveHTML and SaveHTMLEx methods }
TRVSaveOption = (
rvsoOverrideImages, // Overwrite image files (if not set - use unique)
rvsoFirstOnly, // Save only heading part of HTML
rvsoMiddleOnly, // Save only middle part of HTML (document itself)
rvsoLastOnly, // Save only ending part of HTML
rvsoDefault0Style, // Do not save properties for the 0-th text style
rvsoNoHypertextImageBorders, // Supress borders for hypertext images
rvsoImageSizes, // Write image size
rvsoForceNonTextCSS,// Always use CSS for non-text items
rvsoUseCheckpointsNames, // Use "checkpoint names" instead of indices
rvsoMarkersAsText, // Save paragraph bullets/numbering without <UL>/<OL>
rvsoInlineCSS, // Write CSS directly in <P> and <SPAN> tags
// (only for SaveHTMLEx)
rvsoNoDefCSSStyle, // Use named CSS for all text styles, even for
// TextStyles[0] (by default, properties of
// TextStyles[0] are assigned to BODY and TABLE).
// This option generates larger HTML (not recommended).
// (only for SaveHTMLEx)
rvsoUseItemImageFileNames, // If set, images having specified
// (in extra string properties) file names will not
// be saved, but their file names will be written
// in HTML (relative to the HTML file path)
rvsoXHTML, // Save XHTML
rvsoUTF8); // Use UTF8 encoding
TRVSaveOptions = set of TRVSaveOption;

TRichView 是Delphi/C++Builder 控件,主要用于显示、编辑和打印超文本文档。新版本解决多个兼容性问题,更新了字符串标签、剪贴板、RTF和DB组件。 兼容性问题 Item tags是字符串,不再是整数型 OnRVFPictureNeeded参数改变 TRichView.LoadText, LoadTextFromStream, SaveText, SaveTextToStream, TRichViewEdit.InsertTextFromFile 有了新的参数。 TRVLongOperation的声明类型已经改变 以下全局变量从RVTable.pas中移除:RichViewTableGridStyle, RichViewTableGridStyle2, RichViewTableGridColor,被替换为TRVStyle属性。 风格模板 默认情况下,风格模板不能被使用,需激活风格模板,设置TRichView.UseStyleTemplates = True。 在TRichViewEdit中,你可以应用指定的模板样式到选定区域,使用这些方法:ApplyStyleTemplate, ApplyTextStyleTemplate, ApplyParaStyleTemplate. 样式模板可用ChangeStyleTemplates方法编辑。 RTF TRichView.RTFOptions中的新选项:rvrtfSavePngAsPng。如果默认有这个选项,PNG图像也会被保存为PNG格式。 打印 表格行的新属性: KeepTogether; 新的表格方法: SetRowPageBreakBefore, SetRowKeepTogether; table.PrintOptions新选项: rvtoContinue; 新属性:TCustomRVPrint.IgnorePageBreaks。 旋转 表格单元格可旋转 90°, 180°或 270。 一个新的方法返回项坐标: GetItemCoordsEx; 它考虑到了单元格的旋转。 字符串标签 新属性:cell tags; 从13.2版本开始,项目标签是字符串(Unicode for Delphi 2009或更高,ANSI老版本的Delphi),从整数到PChar无需类型转换! 64-bit 32-bit 和 64-bit编译器均支持RAD Studio XE2+。 注意: TRVOfficeConverter 可以编译为64-bit应用程序,但列表的转换器将为空 (因为转换器是32-bit DLLs,不能再64-bit应用中使用)。 HTML存储 TRichView.SaveHTMLEx可保存扩展的背景图像; TRichView.SaveHTMLEx 能更好的保存列表标记 (无论是在常规或rvsoMarkersAsText 模式); TRichView.OnSaveImage2事件新增"hidden"参数。 DB组件 如果rvfoLoadBack在 RVFOptions中, TDBRichView会在加载数据前清空 BackgroundBitmap; 如果rvfoLoadBack在RVFOptions 和 FieldFormat=rvdbRVF中, TDBRichViewEdit会在加载数据前清空 BackgroundBitmap。 剪贴板 TRichViewEdit 可以粘贴URL,新增方法:PasteURL; 新属性:AcceptPasteFormats允许限制格式列表; 新属性:DefaultPictureVAlign定义一个对齐以粘贴和放置图像。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值