def addWatermark(self): '''Create a Draft watermark layer. This was taken from: http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document''' L = len(self.watermark) # The length of the word # will determine the font size scribus.defineColor("gray", 11, 11, 11, 11) # Set your own color here u = scribus.getUnit() # Get the units of the document al = scribus.getActiveLayer() # Identify the working layer scribus.setUnit( scribus.UNIT_MILLIMETERS) # Set the document units to mm, (w, h) = scribus.getPageSize() # needed to set the text box size scribus.createLayer("c") scribus.setActiveLayer("c") T = scribus.createText(w / 6, 6 * h / 10, h, w / 2) # Create the text box scribus.setText(self.watermark, T) # Insert the text scribus.setTextColor("gray", T) # Set the color of the text scribus.setFontSize( (w / 210) * (180 - 10 * L), T) # Set the font size according to length and width scribus.rotateObject(45, T) # Turn it round antclockwise 45 degrees scribus.setUnit(u) # return to original document units # FIXME: It would be nice if we could move the watermark box down to the lowest layer so # that it is under all the page text. Have not found a method to do this. For now we just # plop the watermark on top of everything else. scribus.setActiveLayer(al) # return to the original active layer
def addWatermark (self) : '''Create a Draft watermark layer. This was taken from: http://wiki.scribus.net/canvas/Adding_%27DRAFT%27_to_a_document''' L = len(self.watermark) # The length of the word # will determine the font size scribus.defineColor("gray", 11, 11, 11, 11) # Set your own color here u = scribus.getUnit() # Get the units of the document al = scribus.getActiveLayer() # Identify the working layer scribus.setUnit(scribus.UNIT_MILLIMETERS) # Set the document units to mm, (w,h) = scribus.getPageSize() # needed to set the text box size scribus.createLayer("c") scribus.setActiveLayer("c") T = scribus.createText(w/6, 6*h/10 , h, w/2) # Create the text box scribus.setText(self.watermark, T) # Insert the text scribus.setTextColor("gray", T) # Set the color of the text scribus.setFontSize((w/210)*(180 - 10*L), T) # Set the font size according to length and width scribus.rotateObject(45, T) # Turn it round antclockwise 45 degrees scribus.setUnit(u) # return to original document units # FIXME: It would be nice if we could move the watermark box down to the lowest layer so # that it is under all the page text. Have not found a method to do this. For now we just # plop the watermark on top of everything else. scribus.setActiveLayer(al) # return to the original active layer
""" USAGE You must have a document open. This script moves all images to a new layer called "Ghostlayer", the idea being that you can show/hide, print-export/not as desired. """ import scribus if scribus.haveDoc(): fantome = "Ghostlayer" scribus.createLayer(fantome) working = scribus.getActiveLayer() page = 1 pagenum = scribus.pageCount() while (page <= pagenum): scribus.gotoPage(page) scribus.setActiveLayer(working) # maybe not necessary? pageitems = scribus.getPageItems() for item in pageitems: if (item[1] == 2): imagebox = item[0] scribus.selectObject(imagebox) scribus.copyObject(imagebox) scribus.setActiveLayer(fantome) scribus.pasteObject(imagebox) scribus.deleteObject(imagebox)
def main(argv): scribus.setUnit(scribus.UNIT_MILLIMETERS) # get page size pagesize = scribus.getPageSize() ########################################### # size and position of the exit buttons linksize = pagesize[0] / 30 linkpos = pagesize[0] - linksize - 2 # set up exit to page pagenum = scribus.pageCount() exittopage = scribus.valueDialog( "Exit to page", "Exit buttons should go to page (1-" + str(pagenum) + ") :", "1") #error #if exittopage > pagenum: # scribus.messageBox("Error", "This page doesn't exist.") # sys.exit() # get active layer, create new layer for exit buttons, set it as active activelayer = scribus.getActiveLayer() scribus.createLayer("Exitbuttons") scribus.setActiveLayer("Exitbuttons") #progressbar max scribus.progressTotal(pagenum) # iterate through all the pages page = 1 while (page <= pagenum): #messagebar text scribus.messagebarText("Create exit buttons...") scribus.progressSet(page) scribus.gotoPage(page) # create rectangle exitrect = scribus.createRect(linkpos, 2, linksize, linksize, "exitrect" + str(page)) scribus.setFillColor("White", exitrect) # create text in rectangle exittext = scribus.createText(linkpos, 4, linksize, linksize, "exittext" + str(page)) scribus.setText("X", exittext) scribus.setFontSize(20, exittext) scribus.setTextAlignment(1, exittext) # create link annotation exitlink = scribus.createText(linkpos, 2, linksize, linksize, "exitlink" + str(page)) #setLinkAnnotation(page,x,y,["name"]) scribus.setLinkAnnotation(int(exittopage), 0, 0, exitlink) # add page number to iteration page += 1 # go back to active layer scribus.setActiveLayer(activelayer)
from itertools import cycle import sys try: import scribus except ImportError: print "This script only works from within Scribus" sys.exit(1) unit_current=scribus.getUnit() #get unit and change it to mm scribus.setUnit(scribus.UNIT_MILLIMETERS) page = scribus.getPageSize() margin = scribus.getPageMargins() layer = scribus.getActiveLayer() if ('guides' in scribus.getLayers()) : scribus.setActiveLayer('guides') else: scribus.createLayer('guides') # add the baseline grid (when it's not too close to a guide) baseline_start = 0 # in mm baseline = 14.4 # in pt multiplicator = 10000 baseline = int(baseline * 0.352777 * multiplicator) # 14.4 pt in mm #baseline = int(baseline * 0.351459 * multiplicator) # 14.4 pt in mm
def main(argv): ########################################### scribus.newDocDialog() if scribus.haveDoc: scribus.setUnit(scribus.UNIT_MILLIMETERS) (w, h) = scribus.getPageSize() ################### # ask for workdir workdir = scribus.fileDialog("Open directory with images", "", haspreview=False, issave=False, isdir=True) #workdir = "/media/sda7/StudioSession3/PDFTools/pics" #workdir = "/media/sda7/ISG/Itex/PhotoVisit/Boilerroom" # file filter filefilter = scribus.valueDialog( "File filter", "File filter examples: \n\n* or *.* = add all files\n*.jpg = add .jpg files only\nIMG_*.* = add all files starting with IMG_\n\nThis filter is case sensitive!", "*.*") # get image paths filelist = sorted(glob.glob(os.path.join(workdir, filefilter))) #scribus.messageBox("Help", str(filelist)) # count files filesinworkdir = len(filelist) #scribus.messageBox("Help", str(filesinworkdir)) #messagebar text scribus.messagebarText("Importing images...") #error if filesinworkdir == 0: scribus.messageBox("Error", "This directory is empty.") sys.exit() # add filename text? addfilenames = scribus.messageBox("Import images", "Files found in workdir : " + str(filesinworkdir) + "\n\nAdd file names to images?", button1=scribus.BUTTON_YES, button2=scribus.BUTTON_NO) #create text layer if addfilenames == 16384: activelayer = scribus.getActiveLayer() scribus.createLayer("Filenames") scribus.setActiveLayer(activelayer) #progressbar max scribus.progressTotal(filesinworkdir) page = 1 #create page, add and load image for i in filelist: scribus.progressSet(page) scribus.gotoPage(page) scribus.createImage(0, 0, w, h, "imagename" + str(page)) scribus.loadImage(filelist[page - 1], "imagename" + str(page)) scribus.setScaleImageToFrame(True, proportional=True, name="imagename" + str(page)) #scribus.setImageOffset(0, 0, "imagename"+str(page)) #scribus.setScaleFrameToImage(name="imagename"+str(page)) # add filename on page? if addfilenames == 16384: scribus.setActiveLayer("Filenames") filename = scribus.createText(2, 2, 50, 10, filelist[page - 1]) scribus.setText(os.path.basename(filelist[page - 1]), filename) scribus.setTextColor("White", filename) scribus.setActiveLayer(activelayer) scribus.newPage(-1) page += 1 #delete last blank page scribus.deletePage(filesinworkdir + 1)