谢谢版主及时回复,
因为C1Editor保存的是html格式数据,我们这边不能用C1Word直接读取以下格式:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<style type="text/css">
body { font-family: Verdana; font-size: 9pt; }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Nikola Tesla</h1>
<p>Nikola Tesla (10 July 1856 - 7 January 1943) was an inventor and a mechanical and electrical engineer.</p>
<p>Tesla was born in the village of Smiljan near the town of Gospić, Vojna Krajina, in the territory of today's Croatia. He was an ethnic Serb subject of the Austrian Empire and later became an American citizen.</p>
<p>Tesla is often described as an important <span style="color:Red">scientist and inventor of the modern age, a man who "shed light over the face of Earth". He is best known for many revolutionary contributions in the field of electricity and magnetism in the late 19th and early 20th centuries.</span></p>
<p><span style="color:Red">Tesla's patents and theoretical work formed the basis of modern alternating current electric power (AC) systems, including the polyphase power distribution</span> systems and the AC motor, with which he helped usher in the Second Industrial Revolution. After his demonstration of wireless communication (radio) in 1894 and after being the victor in the "War of Currents", he was widely respected as one of the greatest electrical engineers who worked in America.<img width="321" height="241" src="file:///C:/Users/Public/Pictures/Sample Pictures/Tulips.jpg" alt="" /></p>
<p>.</p>
</body>
</html>
我们用System.IO.File.ReadAllText(xmlPath)读取后提取出文字与图片位置、尺寸,
再用C1Word的以下方法合成rtf格式并保存:
c1Word.AddParagraph(imgText.text, font, Color.Black, RtfHorizontalAlignment.Undefined);
c1Word.AddPicture(img, RtfHorizontalAlignment.Undefined);
保存后rtf格式内容:
\rtf1\ansi\ansicpg932\deff0\nouicompat\deflang1041\deflangfe1041{\fonttbl{\f0\froman\fcharset128{\*\panose 02020603050405020304}Times New Roman}{\f1\fswiss\fcharset128{\*\panose 020B0400000000000000}\u28216 ?\u12468 ?\u12471 ?\u12483 ?\u12463 ?}}{\colortbl;\red0\green0\blue0;\red255\green255\blue255;}{\stylesheet{\ql \li0\ri0\aspalpha\faauto \lang127\langfe127 \f0\fs24\cf1\lang127\langfe127 \snext0 Normal;}{\*\cs10 \additive\ssemihidden DefaultParagraphFont;}{\*\ts1 \tsrowd\trftsWidthB3\trpaddl78\trpaddr78\trpaddfl3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrr\tsbrdrb\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv \ql \li0\ri0\aspalpha\faauto \lang127\langfe127 \f0\fs24\cf1\lang127\langfe127 \snext0 \ssemihidden TableNormal;}{\*\ls11 NoList;}}{\*\generator GrapeCity C1Word;}{\info{\title Unknown}{\author C1WordCreator}{\operator C1Word}{\creatim\yr2019\mo9\dy25\hr9\min35}{\revtim\yr2019\mo9\dy25\hr9\min35}{\company GrapeCity}}\paperw11906\paperh16838\margl1701\margr851\margt1134\margb1134 \fet0\sectd \pard\plain\nowidctlpar\ql \li0\ri0\aspalpha\faauto \lang127\langfe127 {\f1\fs19\cf1\lang127\langfe127 asdfasdf\u28216 ?\u12468 ?\u12471 ?\u12483 ?\u12463 ?FASDFASF}\par\pard\plain\nowidctlpar\ql \li0\ri0\aspalpha\faauto \lang127\langfe127 {\pict\pngblip\picw1470\pich375\picwgoal1470\pichgoal375\piccropl0\piccropr0\piccropt0\piccropb0 89504E470D0A1A0A0000000D4948445200000062000000190806000000CA40FB0C000000017352474200AECE1CE90000000467414D410000B18F0BFC6105000000097048597300000EC300000EC301C76FA864000001BB494441546843ED97C171C4200C45530BD5B8154AA1135DDC851A7125E47F6C6C201E67931CD06C7478335EBC7867F4FC25F6635DD7ECCCA788D8B6CD99888B30828B30828B30828B30828B308231119AD3127208AFB124FDF5DE106296EEB7E76250C49293DEDD1B907823A229AE6A96E139AA02FA352BBC59221A111015A5DEDBD1145F933C01D389B80A27392E29EB97EFB71C2220A0178667A465581B25CEC7AC0845F16AB1783D16B2D0C96913C16BDEC7E79A004D790978CEB742E76052448C6C2B90803EAF9C05287ADF66EE1282B563000BF627A489CF2872301B624C59983049B8C6ACE8F6CEC7A088F6ADBED2F19C06B28B48112229ADCE084A389E79B63ACA3D7FC70666458CADE9A544B46B4504F70BE4ECEB2529B55519C39888BD98420948C3E38C18457006A0E5D4CFD7BD3B69F6B025E228A66236F4FF139094F36DBE5A56B7B7FD7E27052246898D302B9812D1B6A3BDB052062C872B8FA53CF53029E3FF0322B119E8A3084FC44F18DEF4211114421111C398C7D254FA7FDDCBB7BE19BE2EE20FB0F06DCBA88940E179C261E1AF621E62EAC98747524AC39EAE053D614C8EA144
以上rtf格式与windows标准的rtf不同,会出现有个“GrapeCity C1Word”的信息,
请问如何能生成纯净的rtf格式呢? |