Python converts a webpage into a PDF code instance using pythonpyqt
The code is very simple, and the function is very simple = w =
Webpage2pdf
#! /Usr/bin/env python3 import sys try: from PyQt4 import QtWebKit from PyQt4.QtCore import QUrl from PyQt4.QtGui import QApplication, qprinterlace t ImportError: from PySide import QtWebKit from PySide. qtCore import QUrl from PySide. qtGui import QApplication, Q
Introduction
With the Psutil module (https://pypi.python.org/pypi/psutil/), it is very convenient to monitor the system's CPU, memory, disk IO, network bandwidth and other performance parameters, whether the following code to monitor the CPU resource consumption of a particular program, Prints the monitoring data, the final drawing is displayed, and is saved as a backup of the specified PDF document.
Demo Code
#!/usr/bin/env
The example in this article describes how Python implements the conversion of DOC documents to PDFs. Share to everyone for your reference. The implementation method is as follows:
Import sys, osfrom win32com.client import Dispatch, constants, Gencachedef usage (): sys.stderr.write ("doc2pdf.py input [ Output] ") Sys.exit (2) def doc2pdf (input, Output): W = Dispatch (" Word.Application ") Try:doc = W.documents.open (input, Rea DOnly = 1) doc. ExportA
WPS API, that is, COM, mainly divided into V8 and V9 two versions, the online easy to find examples, are V8. Now the official online can download, 2013 Rob Fresh version, is V9 API, the following code is based on V9.Python calls com to install Python for Windows Extensions, which is Pywin32The call is simple, the direct code:ImportSYSImportOSImportWIN32COM.CLIENTARGC=Len (SYS.ARGV)Print("Number of arguments
[Python] Call the WPS V9 API to convert PPT to PDF and pythonwps.
WPS APIs, that is, COM, are mainly divided into V8 and V9 versions. examples that are easy to find on the Internet are V8. You can download the V9 API on the official website.
Python needs to install Python for Windows Extensions to call COM, that is,
This example demonstrates Python's method of producing PDF files, which is a more practical function, consisting mainly of 2 files. The implementation methods are as follows:
pdf.py files are as follows:
#!/usr/bin/python from
reportlab.pdfgen import canvas
def hello ():
c = Canvas. Canvas ("Helloworld.pdf")
c.drawstring (100,100, "Hello,world")
c.showpage ()
c.save ()
Hello ()
This example demonstrates how Python generates PDF files and is a useful feature that consists of 2 files. The implementation method is as follows:
The pdf.py file is as follows:
#!/usr/bin/pythonfrom reportlab.pdfgen Import Canvasdef hello (): c = Canvas. Canvas ("Helloworld.pdf") c.drawstring (100,100, "Hello,world") c.showpage () c.save () Hello ()
The diskreport.py file is as follows:
#!/u
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.