Adding 'DRAFT' to a document: Difference between revisions

From Scribus Wiki
Jump to navigation Jump to search
mNo edit summary
m (Add DRAFT works on 1.3.9svn)
Line 1: Line 1:
Script temporarily removed - Looks like some setFontSize needs fixing
#!/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
getActiveLayer
setActiveLayer
createText
setUnit
setText
setTextColor
setFontSize
rotateObject
Tested on 1.3.8 and A0, 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
    al = getActiveLayer()                    # Identify the working layer
    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)  # 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
 
    rotateObject(45, T)                      # Turn it round antclockwise 45 degrees
    setUnit(u)                              # return to original document units
    setActiveLayer(al)                      # return to the original active layer

Revision as of 23:09, 21 September 2010

  1. !/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
getActiveLayer
setActiveLayer
createText
setUnit
setText
setTextColor
setFontSize
rotateObject

Tested on 1.3.8 and A0, A2, A4, A5, Letter

from scribus import *

  1. Could be expanded to include localization here

draft = "DRAFT"

  1. draft = "ENTWURF"
  2. 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
   al = getActiveLayer()                     	# Identify the working layer
   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)  # 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
   rotateObject(45, T)                      	# Turn it round antclockwise 45 degrees
   setUnit(u)                               	# return to original document units
   setActiveLayer(al)                       	# return to the original active layer