html2image
html2image copied to clipboard
Cannot change browser after instanciating an Html2Image object
i´m trying to convert html to png files, but it always return this error:
Traceback (most recent call last):
File "c:\Users...\CDCConverterWatchDog.py", line 8, in
code:---------------------------------------------------------------------------------- from html2image import Html2Image hti = Html2Image() hti.browser = 'chrome' hti.output_path = "C:/Users/ArntV" hti.size = (1080,1920) file = 'C:/CDC_template.html'
hti.screenshot_loaded_file(file=file) hti.screenshot_loaded_file(file=file,size=(1080,1920))
HTML file contents:----------------------------------------------------------------------------------
Confira as nossas condições de *|MES|* de *|ANO|*
![](http://www.agcofinance.com.br/portal_dll/campanhas/Comunicados/Imagens_RD_Station/CDC%20Template/100financiado_AGCO.png)
![](http://www.agcofinance.com.br/portal_dll/campanhas/Comunicados/Imagens_RD_Station/CDC%20Template/AGROMAIS_logo.png)
PRAZO (MESES) |
TAXA% (periocidade mensal) |
TAXA% (periocidade anual) |
12 |
*|TAXAM12|* |
*|TAXAA12|* |
24 |
*|TAXAM24|* |
*|TAXAA24|* |
36 |
*|TAXAM36|* |
*|TAXAA36|* |
48 |
*|TAXAM48|* |
*|TAXAA48|* |
60 |
*|TAXAM60|* |
*|TAXAA60|* |
Vigência: até *|VIGENCIA|*
Carência: até 18 meses, de acordo com a safra do cliente
Forma de pagamento: mensal, bimestral, trimestral, quadrimestral, semestral ou anual
</div>
<div style="display: flex;padding-left: 10%;padding-top: 2%;padding-right: 10%;width:80%;height:20%; marign:0px;">
<div style="padding-left: 5%;padding-right: 5%;width:70%;height:100%; marign:0px;">
<p style="text-align: left;" ><span lang="PT-BR" style="font-size:18.0pt;font-family:"Franklin Gothic Book",sans-serif;color:#ffffff;mso-ansi-language:PT-BR">
Condições válidas para financiamentos através da linha CDC – Crédito Direto ao Consumidor. Condições válidas apenas para financiamentos com prazo de citados na tabela acima. Condições comerciais para Pessoas Físicas e Pessoas Jurídicas. Os vencimentos das parcelas serão ajustados em função dos finais de semana e/ou feriados; Para condições comerciais diferenciadas, consulte um representante comercial. Condições sujeitas a alterações em caso de flutuações de mercado e sem aviso prévio. Condições de CDC praticadas pelo Banco de Lage Landen Brasil S.A.. Condições sujeitas a aprovação de crédito pelo Banco De Lage Landen S.A.
</span>
</p>
</div>
<div style="width:20%;height:100%; marign:0px;">
<img style="width: 100%;height: 100%;object-fit:scale-down;" src="http://www.agcofinance.com.br/portal_dll/campanhas/Comunicados/Imagens_RD_Station/CDC Template/AGCO_Finance_logo.png">
</div>
</div>
<div style="display: flex;padding-left: 10%;padding-right: 10%;width:80%;height:1%; marign:0px;">
<p style="text-align: center;" ><span lang="PT-BR" style="font-size:15.0pt;font-family:"Franklin Gothic Book",sans-serif;color:#ffffff;mso-ansi-language:PT-BR">
AGCO FINANCE é uma marca registrada e unidade de negócios do Banco De Lage Landen Brasil S.A.
</span>
</p>
</div>
</div>
Hello, thanks for reporting this issue. There is indeed a problem when a browser is set after instanciating an Html2Image object. It will be fixed in a later release of the package.
For the moment, as chrome is the only browser available and is used by default, you can use the following code:
from html2image import Html2Image
hti = Html2Image()
# no need to set 'chrome' as the browser because it is the default option
hti.output_path = "C:/Users/ArntV"
hti.size = (1080,1920)
file = 'C:/CDC_template.html'
# use screenshote instead of screenshot_loaded_file
hti.screenshot(html_file=file)
Tell me if you still have any problem. Also please do not close the issue for the moment.