Python Recipes: Converting from HTML and URLs to PDF and PS

To prepare the conversion from HTML and URL to PDF and PS, we need python itself, the htmldoc generator and the pyhtmldoc plugin. (I gave links to my forks, because I made some changes that have not yet been crammed into the original repository. You can also use the ready-made image .)



First, import the plugin with the command



from _pyhtmldoc import *
      
      





To convert from HTML and URL to PDF and PS, use the commands



 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     
      
      






All Articles