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
# (at your option) any later version. """ 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)
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)
random_degree = 120 elif i == 2: random_degree = 240 scribus.rotateObject(random_degree, bars) scribus.sentToLayer("randombars", bars) #################################################################################### # create new document (landscape) #################################################################################### if scribus.newDocument((document_width,document_height), (document_margin,document_margin,document_margin,document_margin), scribus.PORTRAIT, 1, scribus.UNIT_MILLIMETERS, scribus.PAGE_2, 0, 1): scribus.setMargins(0,6.35,3.175,3.175) # create some layers; so objects appear front/background scribus.createLayer("randombars") scribus.createLayer("randomcircles") scribus.createLayer("textlayer") distros.keys().sort() for distro in sorted(distros.iterkeys()): # extract the dictionary content description = distros[distro][0] filesizeiso = distros[distro][1] md5sum = distros[distro][2] modified = distros[distro][3] # create page title/header B = scribus.createText(left_page_x, 10, 100, 10)
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 if baseline > 0 : guide_i = 0 guide_list = scribus.getHGuides() guide_list.append(page[1]) guide = guide_list[guide_i]
# add a "crossed frame" for missing images for item in scribus.getAllObjects(): if scribus.getObjectType(item) == 'ImageFrame': image = scribus.getImageFile(item) if image == '': pos = scribus.getPosition(item) size = scribus.getSize(item) rectangle = scribus.createRect(pos[0], pos[1], size[0], size[1]) scribus.setFillColor('none', rectangle) scribus.setLineColor('Black', rectangle) scribus.setLineWidth(0.4, rectangle) line = scribus.createLine(pos[0], pos[1] , pos[0] + size[0], pos[1] + size[1]) scribus.setLineColor('Black', line) scribus.setLineWidth(0.4, line) line = scribus.createLine(pos[0], pos[1] + size[1], pos[0] + size[0], pos[1]) scribus.setLineColor('Black', line) scribus.setLineWidth(0.4, line) layer = scribus.getActiveLayer() if ('placeholder' in scribus.getLayers()) : scribus.setActiveLayer('placeholder') else: scribus.createLayer('placeholder') for page in range(1, scribus.pageCount() + 1): scribus.gotoPage(page) drawPlaceholders() scribus.setActiveLayer(layer)
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)
''' Add gradient background to every pages of the document''' import scribus import random topMargin, leftMargin, rightMargin, bottomMargin = scribus.getPageMargins() pageWidth, pageHeight = scribus.getPageSize() printAreaWidth = pageWidth - leftMargin - rightMargin printAreaHeight = pageHeight - topMargin - bottomMargin xPos = 0 yPos = 0 pageNumber = scribus.pageCount() currentPage = 1 scribus.createLayer("background") while (currentPage <= pageNumber): scribus.gotoPage(currentPage) c = random.randint(0,150) m = random.randint(0,150) y = random.randint(0,150) k = random.randint(0,150) gradientType = random.randint(1,5) scribus.defineColor("color1", c, m, y, k) scribus.defineColor("color2", k, y, m, c) rect = scribus.createRect(xPos, yPos, pageWidth, pageHeight) scribus.setGradientFill(gradientType, "color1", 90, "color2", 90, rect) #scribus.setGradientFill(1, "Black", 90, "White", 90, rect) currentPage += 1
if image == '': pos = scribus.getPosition(item) size = scribus.getSize(item) rectangle = scribus.createRect(pos[0], pos[1], size[0], size[1]) scribus.setFillColor('none', rectangle) scribus.setLineColor('Black', rectangle) scribus.setLineWidth(0.4, rectangle) line = scribus.createLine(pos[0], pos[1], pos[0] + size[0], pos[1] + size[1]) scribus.setLineColor('Black', line) scribus.setLineWidth(0.4, line) line = scribus.createLine(pos[0], pos[1] + size[1], pos[0] + size[0], pos[1]) scribus.setLineColor('Black', line) scribus.setLineWidth(0.4, line) layer = scribus.getActiveLayer() if ('placeholder' in scribus.getLayers()): scribus.setActiveLayer('placeholder') else: scribus.createLayer('placeholder') for page in range(1, scribus.pageCount() + 1): scribus.gotoPage(page) drawPlaceholders() scribus.setActiveLayer(layer)
scribus.setFont(font, text_id) scribus.setTextColor(text_colour, text_id) scribus.setTextDistances(3*spacing, spacing, 0, spacing, text_id) scribus.sentToLayer(layer, text_id) scribus.setFontSize(fontsize, text_id) def loadimages(img_id, img_x, img_y, img_width, img_height, img_path, layer, scaletoframe): scribus.createImage(img_x, img_y, img_width, img_height, img_id) scribus.loadImage(img_path, img_id) scribus.sentToLayer(layer, img_id) # create new document (smallsquare) if scribus.newDocument((document_width,document_height), (0,6.35,3.175,3.175), scribus.PORTRAIT, 1, scribus.UNIT_MILLIMETERS, scribus.PAGE_2, 1, 0): i = 0 scribus.createLayer("images") scribus.createLayer("text") textframes("titel", 42.5, 50, 129.7, 17.99, "White","Black", 39, "FreeSans Bold", 0, "DIE SCHWÄRZUNG","text", 0, 0) scribus.createLine(20.2,67.5,190.2,67.5) scribus.createImage(55, 72.7, 99.5, 20.2, "logo") scribus.loadImage("handydandy_logo.eps", "logo") scribus.sentToLayer("images", "logo") scribus.setScaleImageToFrame(1,1,"logo") textframes("jahr", 81.7, 216.7, 46.1, 18.5, "White","Black", 22, "FreeSans Medium", 0, "2006 - 2012","text", 0, 0) scribus.newPage(-1) slike = glob.glob("pics/*.jpg") slike.sort()
def main(argv): scribus.setUnit(scribus.UNIT_MILLIMETERS) # get page size and page count pagesize = scribus.getPageSize() pagenum = scribus.pageCount() #create on page selectedpage = scribus.valueDialog( "Select page", "Create arrows and annotation links on page (1-" + str(pagenum) + ") :", "1") # get active layer, create new layer for exit buttons, set it as active #activelayer = scribus.getActiveLayer() scribus.createLayer("Arrowlinks") scribus.setActiveLayer("Arrowlinks") #progressbar max scribus.progressTotal(pagenum) arrowinitxpos = 10 arrowinitypos = 30 scribus.gotoPage(int(selectedpage)) page = 1 ########################################### for i in range(pagenum): # create rectangle #exitrect = scribus.createRect(arrowinitxpos, 50, 30, 30, "exitrect") #messagebar text scribus.messagebarText( "Creating arrows and annotation links on page " + selectedpage + "...") #progress bar scribus.progressSet(page) #create and distribute arrow arrowpoly = [ 10, 30, 30, 10, 50, 30, 40, 30, 40, 50, 20, 50, 20, 30, 10, 30 ] arrowup = scribus.createPolygon(arrowpoly) scribus.sizeObject(10, 10, arrowup) scribus.moveObjectAbs(arrowinitxpos, arrowinitypos, arrowup) scribus.setFillColor("White", arrowup) #create and distribute links arrowlink = scribus.createText(arrowinitxpos, arrowinitypos + 11, 10, 10, "link_to_page_" + str(page)) #setLinkAnnotation(page,x,y,["name"]) scribus.setLinkAnnotation(int(page), 0, 0, arrowlink) arrowinitxpos += 11 if arrowinitxpos > 250: arrowinitypos += 24 arrowinitxpos = 10 # add page number to iteration page += 1