tests/test_pdfgen_overprint.py
author robin <robin@reportlab.com>
Tue, 07 Mar 2017 10:00:34 +0000
changeset 4330 617ffa6bbdc8
parent 4252 fe660f227cac
permissions -rw-r--r--
changes for release 3.4.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4330
617ffa6bbdc8 changes for release 3.4.0
robin <robin@reportlab.com>
parents: 4252
diff changeset
     1
#Copyright ReportLab Europe Ltd. 2000-2017
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     2
#see license.txt for license details
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     3
# full screen test
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     4
"""Tests for overprint/knockout.
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     5
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     6
This has been placed in a separate file so output can be passed to printers
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     7
"""
4252
fe660f227cac changes for release 3.3.0
robin
parents: 4030
diff changeset
     8
__version__='3.3.0'
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
     9
from reportlab.lib.testutils import setOutDir,makeSuiteForClasses, outputfile, printLocation
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    10
setOutDir(__name__)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    11
import unittest
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    12
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    13
class OverprintTestCase(unittest.TestCase):
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    14
    "Testing overprint/knockout."
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    15
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    16
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    17
    def test0(self):
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    18
        "This should open in full screen mode."
3283
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    19
        import os
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    20
        from reportlab.pdfgen.canvas import Canvas
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    21
        from reportlab.lib.colors import PCMYKColor, PCMYKColorSep
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    22
        filename = 'test_pdfgen_overprint.pdf'
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    23
        desc = "Overprint/knockout tests for ReportLab library"
3283
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    24
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    25
        black = PCMYKColor(0,0,0,100)
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    26
        cyan = PCMYKColorSep(100,0,0,0,spotName='myCyan')
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    27
        magenta = PCMYKColorSep(0,100,0,0,spotName='myMagenta')
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    28
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    29
        c = Canvas(filename)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    30
        c.setFillColor(black)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    31
        c.setFont('Helvetica', 20)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    32
        c.drawString(100, 700, desc)
3283
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    33
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    34
        c.setFont('Helvetica', 10)
4030
f1703780841a test_pdfgen_overprint.py: fix typo
robin
parents: 3617
diff changeset
    35
        c.drawString(100, 670, "To view this page properly you probably need to enable 'overprint preview' in Acrobat Reader")
3423
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    36
        c.drawString(100, 658, "or use a tool like Illustrator, Quark or Acrobat to view separated plates. Starting in")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    37
        c.drawString(100, 646, "Acrobat Reader 9 there is a setting that lets you turn on the overprint preview, although")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    38
        c.drawString(100, 634, "it's not on by default (Preferences > Page Display > Use Overprint Preview: Always).")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    39
        
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    40
        c.drawString(100, 616, "In the top example, the magenta rectangle overprints the cyan one. In the lower one, it")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    41
        c.drawString(100, 604, "'knocks out' the cyan underneath which is the default in PDF. This means that the overlap")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    42
        c.drawString(100, 592, "area of the first example should show blue, because the two colours merge. However, in many")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    43
        c.drawString(100, 580, "PDF viewers and cheap printers, both examples will probably look the same - magenta")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    44
        c.drawString(100, 568, "rectangle knocks out part of the cyan one.")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    45
        
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    46
        c.drawString(100, 550, "If you can view the separated CMYK plates in a tool like Illustrator, on the cyan plate")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    47
        c.drawString(100, 538, "you should see the top rectangle as complete and the bottom one has a chunk knocked out of")
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    48
        c.drawString(100, 526, "the top right corner.")
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    49
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    50
        c.setFillOverprint(True)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    51
        c.setFillColor(cyan)
3423
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    52
        c.rect(100, 300, 200, 100, fill=True, stroke=False)
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    53
        c.setFillColor(magenta)
3423
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    54
        c.rect(200, 350, 200, 100, fill=True, stroke=False)
3283
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    55
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    56
        c.setFillOverprint(False)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    57
        c.setFillColor(cyan)
3423
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    58
        c.rect(100, 100, 200, 100, fill=True, stroke=False)
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    59
        c.setFillColor(magenta)
3423
e378447a72f4 More explanation of overprint
damian
parents: 3283
diff changeset
    60
        c.rect(200, 150, 200, 100, fill=True, stroke=False)
3283
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    61
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    62
        c.save()
3283
da3a386303fd test_pdfgen_overprint.py: make an overlap for showing the colour difference
rgbecker
parents: 3202
diff changeset
    63
        assert os.path.exists(filename)
3202
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    64
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    65
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    66
def makeSuite():
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    67
    return makeSuiteForClasses(OverprintTestCase)
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    68
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    69
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    70
#noruntests
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    71
if __name__ == "__main__":
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    72
    unittest.TextTestRunner().run(makeSuite())
de34544be47b added a test of knockout/overprint
andy
parents:
diff changeset
    73
    printLocation()