Adding 'DRAFT' to a document: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
(Script for adding 'DRAFT' to a document)
 
No edit summary
Line 1: Line 1:
#!/usr/bin/env python
<pre><nowiki>
'''
 
A script to place a light grey watermark 'DRAFT' on a new layer.  
#!/usr/bin/env python
Requires an existing document, but can be modified to  
'''
create a new document if it does not exist
A script to place a light grey watermark 'DRAFT' on a new layer.  
uses (See the API in Help->Scribus Manual->For Developers->Scripter API;
Requires an existing document, but can be modified to  
  haveDoc
create a new document if it does not exist
  createLayer
 
  setActiveLayer
uses (See the API in Help->Scribus Manual->For Developers->Scripter API;
  createText
haveDoc
  setUnit
createLayer
  setText
setActiveLayer
  setTextColor
createText
  setFontSize
setUnit
  rotateObject
setText
Tested on 1.3.3.12 and A2, A4, A5, Letter
setTextColor
'''
setFontSize
from scribus import *
rotateObject
# Could be expanded to include localization here
Tested on 1.3.3.12 and A2, A4, A5, Letter
draft = "DRAFT"
'''
#draft = "ENTWURF"
from scribus import *
#draft = "BROUILLON"
 
L = len(draft)                                # The length of the word  
# Could be expanded to include localization here
                                              # will determine the font size
draft = "DRAFT"
defineColor("gray", 11, 11, 11, 11)          # Set your own color here
#draft = "ENTWURF"
if haveDoc():
#draft = "BROUILLON"
    u = getUnit()                            # Get the units of the document
 
    setUnit(UNIT_MILLIMETERS)                # Set the document units to mm,                                             
L = len(draft)                                # The length of the word  
    (w,h) = getPageSize()                    # needed to set the text box size
                                              # will determine the font size
    createLayer("c")
defineColor("gray", 11, 11, 11, 11)          # Set your own color here
    setActiveLayer("c")
 
    T = createText(w/6, 6*h/10 , h, w/2.5)    # Create the text box
if haveDoc():
    setText(draft, T)                        # Insert the text
    u = getUnit()                            # Get the units of the document
    setTextColor("gray", T)                  # Set the color of the text
    setUnit(UNIT_MILLIMETERS)                # Set the document units to mm,                                             
    setFontSize((w/210)*(180 - 10*L), T)      # Set the font size according to length  
    (w,h) = getPageSize()                    # needed to set the text box size
                                              # and width of the document
 
    rotateObject(45, T)                      # Turn it round antclockwise 45 degrees
    createLayer("c")
    setUnit(u)                                # return to original document units
    setActiveLayer("c")
 
    T = createText(w/6, 6*h/10 , h, w/2.5)    # Create the text box
    setText(draft, T)                        # Insert the text
    setTextColor("gray", T)                  # Set the color of the text
    setFontSize((w/210)*(180 - 10*L), T)      # Set the font size according to length  
                                              # and width of the document
 
    rotateObject(45, T)                      # Turn it round antclockwise 45 degrees
    setUnit(u)                                # return to original document units

Revision as of 01:37, 15 February 2009

<nowiki>

#!/usr/bin/env python

A script to place a light grey watermark 'DRAFT' on a new layer. 
Requires an existing document, but can be modified to 
create a new document if it does not exist

uses (See the API in Help->Scribus Manual->For Developers->Scripter API;
 haveDoc
 createLayer
 setActiveLayer
 createText
 setUnit
 setText
 setTextColor
 setFontSize
 rotateObject
Tested on 1.3.3.12 and A2, A4, A5, Letter

from scribus import *

# Could be expanded to include localization here
draft = "DRAFT"
#draft = "ENTWURF"
#draft = "BROUILLON"

L = len(draft)                                # The length of the word 
                                              # will determine the font size
defineColor("gray", 11, 11, 11, 11)           # Set your own color here

if haveDoc():
    u = getUnit()                             # Get the units of the document
    setUnit(UNIT_MILLIMETERS)                 # Set the document units to mm,                                            
    (w,h) = getPageSize()                     # needed to set the text box size

    createLayer("c")
    setActiveLayer("c")

    T = createText(w/6, 6*h/10 , h, w/2.5)    # Create the text box
    setText(draft, T)                         # Insert the text
    setTextColor("gray", T)                   # Set the color of the text
    setFontSize((w/210)*(180 - 10*L), T)      # Set the font size according to length 
                                              # and width of the document

    rotateObject(45, T)                       # Turn it round antclockwise 45 degrees
    setUnit(u)                                # return to original document units