summaryrefslogtreecommitdiff
path: root/bin/reportlab/test/test_pdfbase_postscript.py
diff options
context:
space:
mode:
authorpinky <>2007-01-07 21:26:16 +0000
committerpinky <>2007-01-07 21:26:16 +0000
commitdb39be37af8e1f7947c186a2b4688f5963ed7cc7 (patch)
tree00228b8f6f6f2d14e30181376b2406d557b6e6de /bin/reportlab/test/test_pdfbase_postscript.py
parenteacf3d2a7007d9abe4fb00245d6fe833241fe283 (diff)
Reportlab 2.0
bzr revid: pinky-42646ca164f938abd312f6b2f8dccf73970f0c59
Diffstat (limited to 'bin/reportlab/test/test_pdfbase_postscript.py')
-rw-r--r--bin/reportlab/test/test_pdfbase_postscript.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/bin/reportlab/test/test_pdfbase_postscript.py b/bin/reportlab/test/test_pdfbase_postscript.py
new file mode 100644
index 00000000000..e5642502406
--- /dev/null
+++ b/bin/reportlab/test/test_pdfbase_postscript.py
@@ -0,0 +1,77 @@
+#!/bin/env python
+#Copyright ReportLab Europe Ltd. 2000-2004
+#see license.txt for license details
+#history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/test/test_pdfbase_postscript.py
+__version__=''' $Id'''
+__doc__="""Tests Postscript XObjects.
+
+Nothing visiblke in Acrobat, but the resulting files
+contain graphics and tray commands if exported to
+a Postscript device in Acrobat 4.0"""
+
+from reportlab.test import unittest
+from reportlab.test.utils import makeSuiteForClasses, outputfile, printLocation
+from reportlab.pdfgen.canvas import Canvas
+
+
+class PostScriptTestCase(unittest.TestCase):
+ "Simplest test that makes PDF"
+
+ def testVisible(self):
+ "Makes a document with extra text - should export and distill"
+ c = Canvas(outputfile('test_pdfbase_postscript_visible.pdf'))
+ c.setPageCompression(0)
+
+ c.setFont('Helvetica-Bold', 18)
+ c.drawString(100,700, 'Hello World. This is page 1 of a 2 page document.')
+ c.showPage()
+
+ c.setFont('Helvetica-Bold', 16)
+ c.drawString(100,700, 'Page 2. This has some postscript drawing code.')
+ c.drawString(100,680, 'If you print it using a PS device and Acrobat 4/5,')
+ c.drawString(100,660, 'or export to Postscript, you should see the word')
+ c.drawString(100,640, '"Hello PostScript" below. In ordinary Acrobat Reader')
+ c.drawString(100,620, 'we expect to see nothing.')
+ c.addPostScriptCommand('/Helvetica findfont 48 scalefont setfont 100 400 moveto (Hello PostScript) show')
+
+
+ c.drawString(100,500, 'This document also inserts two postscript')
+ c.drawString(100,480, ' comments at beginning and endof the stream;')
+ c.drawString(100,460, 'search files for "%PS_BEFORE" and "%PS_AFTER".')
+ c.addPostScriptCommand('%PS_BEFORE', position=0)
+ c.addPostScriptCommand('%PS_AFTER', position=2)
+
+ c.save()
+
+ def testTray(self):
+ "Makes a document with tray command - only works on printers supporting it"
+ c = Canvas(outputfile('test_pdfbase_postscript_tray.pdf'))
+ c.setPageCompression(0)
+
+ c.setFont('Helvetica-Bold', 18)
+ c.drawString(100,700, 'Hello World. This is page 1 of a 2 page document.')
+ c.drawString(100,680, 'This also has a tray command ("5 setpapertray").')
+ c.addPostScriptCommand('5 setpapertray')
+ c.showPage()
+
+ c.setFont('Helvetica-Bold', 16)
+ c.drawString(100,700, 'Page 2. This should come from a different tray.')
+ c.drawString(100,680, 'Also, if you print it using a PS device and Acrobat 4/5,')
+ c.drawString(100,660, 'or export to Postscript, you should see the word')
+ c.drawString(100,640, '"Hello PostScript" below. In ordinary Acrobat Reader')
+ c.drawString(100,620, 'we expect to see nothing.')
+ c.addPostScriptCommand('/Helvetica findfont 48 scalefont setfont 100 400 moveto (Hello PostScript) show')
+
+
+ c.save()
+
+def makeSuite():
+ return makeSuiteForClasses(PostScriptTestCase)
+
+
+#noruntests
+if __name__ == "__main__":
+ unittest.TextTestRunner().run(makeSuite())
+ print 'saved '+outputfile('test_pdfgen_postscript_visible.pdf')
+ print 'saved '+outputfile('test_pdfgen_postscript_tray.pdf')
+ printLocation()