我正试图用Selenium WebDriver从包含不同字体的html文件中生成图像。但当我截图时,我得到的图像总是返回相同的字体,但与html文件中的字体不同。有人知道如何处理这个问题吗?
python中的代码示例
Font in html:
草写的Parkavenue
但我们从截图中得到的图片中的字体是
Arial
.
## python
html ="""
<style>
html{background-color: white}
table{font-family:Parkavenue, cursive, serif;text-align:center;border-collapse:inherit; border-spacing: 0}
td,th{width: 339px; height : 50px;border:3px dotted black;}
</style>
</head>
<table>
<tr><th rowspan="2"><span id=4>shipments % S.A. sher,AD.; common </span></th>
<th colspan=3><span id=5>% </span></th>
<th rowspan="2"><span id=6>.KAZG.O.,,, C AND S.A. </span></th>
</tr><tr><th colspan=0><span id=7>WARD, S.L. </span></th>
<th colspan=0><span id=8>Gross body Buena Contains   AT   Sciences surface </span></th></tr>
</table>
</body>
</html>
driver = Firefox()
driver.get("data:text/html," + html)
png = driver.get_screenshot_as_png()