如何将HTML标签转换成WordDoc文本格式?使用 DOCX.js 库
How To Convert HTML Tags Into WordDoc Text Format? Using DOCX.js Library
我在将 HTML 文本转换为 word 文档支持格式时遇到问题,因此我可以使用 docx.js 库生成文档文件。现在 HTML 标签显示为计划文本。
这是我正在使用的库:https://docx.js.org/
<p>
<strong>voice:</strong>
During an address to Congress, George Washington said “If you can’t send money, send cigars.” [pause] Or something like that. [pause] There’s no question that Washington was a wise man. He knew that premium quality cigars are worth their weight in gold. And if he were alive today, he’d be running the country from the lounge at
<strong>No Name Cigar Company.</strong>
Where the conversation never comes to an end – and neither does their premier cigar selection. Mingle with legends – at
<strong>No Name Cigar Company.</strong>
</p>
<p> </p>
<p>Visit them online at <strong>NoNameWebsite.com</strong></p>`
您好请使用googoose
这工作得非常快而且没有故障
这里是完整的代码示例
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/aadel112/googoose@master/jquery.googoose.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var o = {
filename: 'test.doc'
};
$(document).googoose(o);
});
</script>
</head>
<body>
The content that is rendered to a Word doc will need to be wrapped in a div with the classname googoose-wrapper, by default.
<div class="googoose-wrapper">
<p><strong>voice:</strong> During an address to Congress, George Washington said “If you can’t send money, send cigars.” [pause] Or something like that. [pause] There’s no question that Washington was a wise man. He knew that premium quality cigars are worth their weight in gold. And if he were alive today, he’d be running the country from the lounge at <strong>No Name Cigar Company.</strong> Where the conversation never comes to an end – and neither does their premier cigar selection. Mingle with legends – at <strong>No Name Cigar Company.</strong></p> <p> </p> <p>Visit them online at <strong>NoNameWebsite.com</strong></p>
</div>
</body>
</html>
我在将 HTML 文本转换为 word 文档支持格式时遇到问题,因此我可以使用 docx.js 库生成文档文件。现在 HTML 标签显示为计划文本。
这是我正在使用的库:https://docx.js.org/
<p>
<strong>voice:</strong>
During an address to Congress, George Washington said “If you can’t send money, send cigars.” [pause] Or something like that. [pause] There’s no question that Washington was a wise man. He knew that premium quality cigars are worth their weight in gold. And if he were alive today, he’d be running the country from the lounge at
<strong>No Name Cigar Company.</strong>
Where the conversation never comes to an end – and neither does their premier cigar selection. Mingle with legends – at
<strong>No Name Cigar Company.</strong>
</p>
<p> </p>
<p>Visit them online at <strong>NoNameWebsite.com</strong></p>`
您好请使用googoose 这工作得非常快而且没有故障
这里是完整的代码示例
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/aadel112/googoose@master/jquery.googoose.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var o = {
filename: 'test.doc'
};
$(document).googoose(o);
});
</script>
</head>
<body>
The content that is rendered to a Word doc will need to be wrapped in a div with the classname googoose-wrapper, by default.
<div class="googoose-wrapper">
<p><strong>voice:</strong> During an address to Congress, George Washington said “If you can’t send money, send cigars.” [pause] Or something like that. [pause] There’s no question that Washington was a wise man. He knew that premium quality cigars are worth their weight in gold. And if he were alive today, he’d be running the country from the lounge at <strong>No Name Cigar Company.</strong> Where the conversation never comes to an end – and neither does their premier cigar selection. Mingle with legends – at <strong>No Name Cigar Company.</strong></p> <p> </p> <p>Visit them online at <strong>NoNameWebsite.com</strong></p>
</div>
</body>
</html>