我构建了一个 SOW 模板生成器,它将 Word Doc 的邮件合并字段替换为来自相关数据库字段的富文本(使用 html 标记)内容。一切都按预期工作,但我遇到了一些问题,试图让格式看起来正确。
我的两个主要问题是列表中的项目符号和自动换行。
为了获得我需要的项目符号样式,Word 实际上使用了“o”并将“courier new”指定为字体。我无法指定字体,因为 word 将始终覆盖 doc 样式。
Word 在进行合并时似乎不尊重列表项,因此一旦文本到达文档的边缘,它就会从文档的最左侧开始,而不是为项目符号添加标签。word转换为html时生成的页面源对于每个列表和级别都有特定的样式和ID。我尝试使用内联样式等效项来获得换行效果,但它不起作用。
任何人都对如何正确设置这些元素的样式有建议,以便 Word 尊重格式?
这是我的标记示例,它保留了迄今为止最好的格式:
<p style="margin:0;">Here is a bunch of random text:</p>
<p style="margin:0 0 0 1in;">•&nbsp; Executive Summary</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Here is a lot more random text and stuff. Super fun.</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> More superfluous stuff. If I knew Latin I would do that instead.</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Summarized steps of nonsense.</p>
<p style="margin:0 0 0 1in;">•&nbsp; Stuff Description</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Description of the stuff and how the stuff was suppose to to meet the needs of the peoples in the places.</p>
<p style="margin:0 0 0 1in;">•&nbsp; Reporting and stuff</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Description of blah blah etc and more stuff. This is a lot of useless text.</p>
<p style="margin:0 0 0 1in;">•&nbsp; Scope of stuff and methodlogy of stuff</p>
<p style="margin:0 0 0 1in;">•&nbsp; Findings and Recommendations of stuff</p>
<p style="margin:0 0 0 1.75in;text-indent:-.25in;"><span style="font-family: Courier New; mso-fareast-font-family: Courier New;">o</span> Scoring stuff and making sure people got the right stuff for the stuff. Keeping the stuff safe one day at a time. yay.</p>
<p style="margin:0;">Appendices: I had enough of this stuff so I'm going to stop typing.</p>