Receitas Python: Convertendo de HTML e URLs para PDF e PS

Para preparar a conversão de HTML e URL para PDF e PS, precisamos do próprio python, do gerador htmldoc e do plugin pyhtmldoc . (Forneci links para meus garfos, porque fiz algumas alterações que ainda não foram colocadas no repositório original. Você também pode usar a imagem pronta .)

Primeiro, importe o plug-in com o comando

from _pyhtmldoc import * 

Para converter de HTML e URL para PDF e PS, use os comandos

 pdf = file2pdf('file.html'.encode(), None) #  FILE  PDF ps = file2ps('file.html'.encode(), None) #  FILE  PS file2pdf('file.html'.encode(), 'file.pdf') #  FILE  PDF      file2ps('file.html'.encode(), 'file.pdf') #  FILE  PS  PDF      pdf = file2pdf(['file1.html'.encode(), 'file2.html'.encode()], None) #   FILE  PDF ps = file2ps(['file1.html'.encode(), 'file2.html'.encode()], None) #   FILE  PS file2pdf(['file1.html'.encode(), 'file2.html'.encode()], 'file.pdf') #   FILE  PDF      file2ps(['file1.html'.encode(), 'file2.html'.encode()], 'file.pdf') #   FILE  PS  PDF      pdf = html2pdf(', !'.encode(), None) #  HTML  PDF ps = html2ps(', !'.encode(), None) #  HTML  PS html2pdf(', !'.encode(), 'file.pdf') #  HTML  PDF      html2ps(', !'.encode(), 'file.pdf') #  HTML  PS  PDF      pdf = html2pdf([', !'.encode(), ' , !'.encode()], None) #   HTML  PDF ps = html2ps([', !'.encode(), ' , !'.encode()], None) #   HTML  PS html2pdf([', !'.encode(), ' , !'.encode()], 'file.pdf') #   HTML  PDF      html2ps([', !'.encode(), ' , !'.encode()], 'file.pdf') #   HTML  PS  PDF      pdf = url2pdf('https://google.com'.encode(), None) #  URL  PDF ps = url2ps('https://google.com'.encode(), None) #  URL  PS url2pdf('https://google.com'.encode(), 'file.pdf') #  URL  PDF  PDF      url2ps('https://google.com'.encode(), 'file.pdf') #  URL  PS  PDF      pdf = url2pdf(['https://google.com'.encode(), 'https://google.ru'.encode()], None) #   URL  PDF ps = url2ps(['https://google.com'.encode(), 'https://google.ru'.encode()], None) #   URL  PS url2pdf(['https://google.com'.encode(), 'https://google.ru'.encode()], 'file.pdf') #   URL  PDF  PDF      url2ps(['https://google.com'.encode(), 'https://google.ru'.encode()], 'file.pdf') #   URL  PS  PDF      

Source: https://habr.com/ru/post/pt464613/


All Articles