示例#1
0
文件: test_php.py 项目: dnet/ppcg
	def test_new(self):
		php = PHP()
		dt = php.new('DateTime')
		ts = dt.getTimestamp()
		php.echo(ts)
		output = str(php)
		self.assertAlmostEquals(int(output), time(), delta=10)
示例#2
0
 def test_new(self):
     php = PHP()
     dt = php.new('DateTime')
     ts = dt.getTimestamp()
     php.echo(ts)
     output = str(php)
     self.assertAlmostEquals(int(output), time(), delta=10)
示例#3
0
def main():
	php = PHP()
	php.include('tcpdf/config/lang/eng.php')
	php.include('tcpdf/tcpdf.php')

	pdf = php.new('TCPDF', 'P', 'mm', 'A4', True, 'UTF-8')
	
	pdf.setFontSubsetting(False)
	pdf.setAuthor('VSzA')
	pdf.setCreator('PPCG')
	pdf.setTitle('TCPDF in Python!?')
	pdf.setPrintHeader(False)
	pdf.setMargins(10, 10)

	pdf.AddPage()
	pdf.SetFont('dejavusans', 'B', 12)
	pdf.Cell(0, 0, 'Hello Python')
	pdf.Ln()

	x = pdf.GetX()
	y = pdf.GetY()
	pdf.setXY(30, 30)
	pdf.Cell(0, 0, 'GOTOs are bad')
	pdf.setXY(x, y + 2.5)
	pdf.Cell(0, 0, 'I can has PHP variables')

	pdf.Output()
	pdf_data = str(php)

	with file('output.pdf', 'wb') as pdf_file:
		pdf_file.write(pdf_data)
	print '{0} bytes of PDF have been written'.format(len(pdf_data))