Recetas de Python: conversión de HTML y URL a PDF y PS

Para preparar la conversión de HTML y URL a PDF y PS, necesitamos el propio Python, el generador htmldoc y el complemento pyhtmldoc . (Di enlaces a mis tenedores, porque hice algunos cambios que aún no se han incluido en el repositorio original. También puede usar la imagen ya preparada ).

Primero, importe el complemento con el comando

from _pyhtmldoc import * 

Para convertir de HTML y URL a PDF y PS, use los 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/464613/


All Articles