使用图像从HTML创建Word文档
我在从一些格式化的HTML生成word文档时遇到了一些小问题 我一直在使用下面这个链接的代码。 我唯一的问题是,当我将文档发送到没有本地存储图像的地方时,我得到了图像应该位于的图像未找到链接。我希望有人能给我指出正确的方向。我很想用python编写一些东西来处理这个问题,但遗憾的是,由于工作原因,我只能使用HTML和其他一些东西(我的javascript还不是很好)。感谢您的帮助 代码如下 提前谢谢使用图像从HTML创建Word文档,html,ms-word,vml,Html,Ms Word,Vml,我在从一些格式化的HTML生成word文档时遇到了一些小问题 我一直在使用下面这个链接的代码。 我唯一的问题是,当我将文档发送到没有本地存储图像的地方时,我得到了图像应该位于的图像未找到链接。我希望有人能给我指出正确的方向。我很想用python编写一些东西来处理这个问题,但遗憾的是,由于工作原因,我只能使用HTML和其他一些东西(我的javascript还不是很好)。感谢您的帮助 代码如下 提前谢谢 <html xmlns:v="urn:schemas-microsoft-com
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
xmlns="http://www.w3.org/TR/REC-html40">
<head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><title></title>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<style>
body
{
font-family: Arial;
}
th{
text-align: left;
text-decoration: underline;
}
.header
{
text-align: center;
}
#title{
font-size: 18px;
font-weight: bold;
}
#subtitle{
font-size: 16px;
font-weight: bold;
text-decoration: underline;
}
#footer{
text-align: right;
font-size: 10px;
}
#conditions{
width: 100%;
text-align: justify;
}
.first {
vertical-align: top;
width: 40%;
font-weight: bold;
}
#signing{
width: 100%;
}
.ownersignature{
text-align: center;
}
#pageheader{
position: relative;
text-align: right;
}
/*#signing td{
width: 40%;
}*/
#h1{
text-align: right;
}
@page
{
mso-page-orientation: Portrait;
size:21cm 29.7cm;
margin:1.8cm 1cm 1cm 1cm;
}
@page Section1 {
mso-header-margin:.2cm;
mso-footer-margin:.2in;
mso-title-page: yes;
mso-first-header: fh1;
mso-footer: f1;
}
div.Section1 {
page:Section1;
}
div#hrdftrtbl
{
margin:0in 0in 0in 900in;
width:1px;
height:1px;
overflow:hidden;
}
div.MsoHeader{
text-align: right;
}
p.MsoFooter, li.MsoFooter, div.MsoFooter
{
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:center 3.0in right 6.0in;
font-size:12.0pt;
float: right;
}
</style>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>100</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
</head>
<body>
<div id="pageheader">
<p class=header><span id='title'>Title!</span><br/><br/><span id='subtitle'>subtitle!</span></p>
</div>
<div class=Section1>
<!-- Header section -->
<div id='hrdftrtbl'>
<div style='mso-element:footer' id=f1><span style='position:relative;#hz-index:-1'>
<!-- FOOTER-tags -->
<div id='footer'><br/><br/>This is my footer</div>
</span>
</p>
</div>
<div id='hrdftrbl'>
<div style='mso-element:header' id=fh1 >
<span style='mso-no-proof:yes'>
<!--[if gte vml 1]>
<v:shapetype id="_x0000_t75"
coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe"
filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype>
<v:shape id="_x0000_s1025" type="#_x0000_t75" alt="" style='position:absolute;
margin-left:0;margin-top:2pt;width:537pt;height:57pt;z-index:251659264'>
<v:imagedata src="/home/user/Documents/image.jpg"/>
<w:wrap type="square"/>
</v:shape>
<![endif]-->
</span>
</div>
</div>
<div style='mso-element:header' id=fh1>
<p class=MsoHeader><span lang=EN-US style='mso-ansi-language:EN-US'> <o:p></o:p></span></p>
</div>
<div style='mso-element:footer' id=ff1>
<p class=MsoFooter><span lang=EN-US style='mso-ansi-language:EN-US'> <o:p></o:p></span></p>
</div>
</div>
</body>
</html>
v\:*{behavior:url(#default#VML);}
o\:*{behavior:url(#default#VML);}
w\:*{behavior:url(#default#VML)}
.shape{behavior:url(#default#VML);}
身体
{
字体系列:Arial;
}
th{
文本对齐:左对齐;
文字装饰:下划线;
}
.标题
{
文本对齐:居中;
}
#头衔{
字号:18px;
字体大小:粗体;
}
#副标题{
字体大小:16px;
字体大小:粗体;
文字装饰:下划线;
}
#页脚{
文本对齐:右对齐;
字体大小:10px;
}
#条件{
宽度:100%;
文本对齐:对齐;
}
.首先{
垂直对齐:顶部;
宽度:40%;
字体大小:粗体;
}
#签字{
宽度:100%;
}
.所有者签名{
文本对齐:居中;
}
#页眉{
位置:相对位置;
文本对齐:右对齐;
}
/*#签署运输署{
宽度:40%;
}*/
#h1{
文本对齐:右对齐;
}
@页面
{
mso页面方向:纵向;
尺寸:21厘米29.7厘米;
边距:1.8厘米1厘米1厘米1厘米;
}
@第1页{
mso割台边距:.2cm;
mso页脚边距:.2in;
mso标题页:是;
mso第一头:fh1;
mso页脚:f1;
}
第1节{
第页:第1节;
}
部门#hrdftrtbl
{
余量:0英寸0英寸0英寸900英寸;
宽度:1px;
高度:1px;
溢出:隐藏;
}
司令官{
文本对齐:右对齐;
}
p、 姆索沃特,李。姆索沃特,分区姆索沃特
{
边距:0英寸;
边缘底部:.0001pt;
mso分页:寡妇孤儿;
止动块:居中3.0英寸,右侧6.0英寸;
字号:12.0pt;
浮动:对;
}
印刷品
100
标题
字幕
这是我的页脚