def main(argv): if not scribus.haveDoc(): sys.exit(1) thecommand = "" infile = os.getcwd() + "/this-is-a-temporary-file.sla" reimposed = os.getcwd() + "/reimposed-from-laidout.sla" thecommand="laidout --command 'Import(filename=\"" \ +infile+"\", keepmystery=2)" \ +" Reimpose(orientation=landscape, paper=\"Tabloid\", imposition=\"Booklet\") " \ +" Export(filter=ScribusExportConfig(filename=\"" \ +reimposed+"\", layout=\"Papers\"))' " #print "command:\n", thecommand try: print "Creating temporary file ", infile, "..." scribus.saveDocAs(infile) except: print "Could not save as ", infile sys.exit(1) try: os.system("/home/tom/p/sourceforge/laidout/src/laidout") #os.system(thecommand) except: print "An error occured trying to run the system command:\n", thecommand sys.exit(1) scribus.closeDoc( ) #closes the "original" document, which has been rename to infile upon saveDocAs() scribus.openDoc(reimposed) #open the brand spanking new reimposed document #if (os.path.isfile(reimposed)): os.remove(reimposed) <-- keep this around print "Removing temporary file ", infile, "..." os.remove(infile)
def main(argv): if not scribus.haveDoc(): sys.exit(1) thecommand="" infile=os.getcwd()+"/this-is-a-temporary-file.sla" reimposed=os.getcwd()+"/reimposed-from-laidout.sla" thecommand="laidout --command 'Import(filename=\"" \ +infile+"\", keepmystery=2)" \ +" Reimpose(orientation=landscape, paper=\"Tabloid\", imposition=\"Booklet\") " \ +" Export(filter=ScribusExportConfig(filename=\"" \ +reimposed+"\", layout=\"Papers\"))' " #print "command:\n", thecommand try: print "Creating temporary file ",infile,"..." scribus.saveDocAs(infile) except: print "Could not save as ",infile sys.exit(1) try: os.system("/home/tom/p/sourceforge/laidout/src/laidout") #os.system(thecommand) except: print "An error occured trying to run the system command:\n",thecommand sys.exit(1) scribus.closeDoc() #closes the "original" document, which has been rename to infile upon saveDocAs() scribus.openDoc(reimposed) #open the brand spanking new reimposed document #if (os.path.isfile(reimposed)): os.remove(reimposed) <-- keep this around print "Removing temporary file ",infile,"..." os.remove(infile)
def init(): scribus.openDoc(pwd("init.sla")) scribus.saveDocAs("/tmp/{}.sla".format(time.time())) scribus.setUnit(scribus.UNIT_MM)
del app #--------------------------------------------------------------------------------------# #------------------------------------ Hauptprogramm -----------------------------------# #--------------------------------------------------------------------------------------# # je nach Taetigkeit anderes Feld ausfuehren if __name__ == "__main__": # Hauptfunktion ausfuehren main() # versuche jetzt Modul scribus zu importiern try: # klapp nur, wenn Script aus Scribus gestartet wurde import scribus # teste ob Dokument geoeffnet ist if scribus.haveDoc(): # wenn ja, dann speichere das im Zielverzeichnis scribus.saveDocAs(std.zielVerzeichnis+"/"+std.datenVerzeichnis+".sla") else: # wenn nicht, lege ein neues Dokument an scribus.newDoc(std.zielVerzeichnis+"/"+std.datenVerzeichnis+".sla") except: # sribusmodul konnte nicht importiert werden, dann versuche scribus zu starten if (os.system("scribus")): # hat nicht geklappt / Fehlermeldung print("Scribus konnte nicht gestartet werden") # Programm beenden # sys.exit()
def endDocument(self): """Save and close document""" self.flow() scribus.saveDocAs(self.document) scribus.closeDoc()
page_number = args.page - 1 insert_position = 0 if args.before is True else 1 # 0 = before; 1 = after master_page = args.masterpage total_pages = get_pages_range(import_file) # Output path output_file = args.output if output_file is not None: output_file = os.path.abspath(args.output) # Importing `import_file` scribus.openDoc(base_file) scribus.importPage( import_file, total_pages, 1, insert_position, page_number ) # Applying masterpage(s) if master_page is not None: for number in range(page_number + 2, page_number + len(total_pages) + 2): scribus.applyMasterPage(master_page, number) # Either overwriting `base_file` .. if output_file is None: scribus.saveDoc() # .. or creating new `output` file (requires `--output`) else: scribus.saveDocAs(output_file) scribus.closeDoc()
def handleEnd(self): self.linkType = self.gui.getLinkType() self.gliederung = self.gui.getGliederung() self.includeSub = self.gui.getIncludeSub() self.start = self.gui.getStart() self.end = self.gui.getEnd() pos1, pos2, tbox = self.toBeDelPosParam scribus.selectText(pos1, pos2 - pos1, tbox) scribus.deleteText(tbox) pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue self.textbox = item[0] self.evalTemplate() # hyphenate does not work # pagenum = scribus.pageCount() # for page in range(1, pagenum + 1): # scribus.gotoPage(page) # pageitems = scribus.getPageItems() # for item in pageitems: # if item[1] != 4: # continue # self.textbox = item[0] # b = scribus.hyphenateText(self.textbox) # seems to have no effect! pagenum = scribus.pageCount() for page in range(1, pagenum + 1): scribus.gotoPage(page) pageitems = scribus.getPageItems() for item in pageitems: if item[1] != 4: continue tbox = item[0] tbox2 = tbox while scribus.textOverflows(tbox2): tbox2 = self.createNewPage(tbox2) self.frameLinks[ tbox2] = tbox # frame tbox2 has tbox as root scribus.redrawAll() ausgabedatei = self.ausgabedatei if ausgabedatei is None or ausgabedatei == "": ausgabedatei = "ADFC_" + self.gliederung + ( "_I_" if self.includeSub else "_" ) + self.start + "-" + self.end + "_" + self.linkType[0] + ".sla" try: scribus.saveDocAs(ausgabedatei) except Exception as e: print("Ausgabedatei", ausgabedatei, "konnte nicht geschrieben werden") raise e finally: self.touren = [] self.termine = [] # self.gui.destroy() # self.gui.quit() self.gui.disableStart()
def main(argv): """This is a documentation string. Write a description of what your code does here. You should generally put documentation strings ("docstrings") on all your Python functions.""" ######################### # YOUR CODE GOES HERE # ######################### script = "Aufschlussdoku.py" version = "20140107" csvfile = scribus.fileDialog("csv2table :: open file", "*.csv") fname_ext = csvfile[csvfile.rfind("/") + 1:] fname_noext = fname_ext[:fname_ext.rfind(".")] reader = csv.reader(open(csvfile, "rb"), delimiter=";") boxes = [["strat_d", 2.25], ["strat_n", 2.25], ["strat_b", 6.5], ["strat_p", 2.3], ["strat_a", 3.9]] start_x = float(1.9075) start_y = float(10.5) strats = [] strat_ct = int(0) strat_ok = float(0.0) print getpass.getuser() for line in reader: if line[0].find("Tiefe bis [m]") <> 0: start_x_0 = start_x strat_ct = strat_ct + 1 strat_d = line[0].replace(",", "."); strat_uk = float(strat_d) + float(strat_ok) strat_draw = float(strat_d) * 2.0 strat_uk_draw = start_y + strat_draw if strat_uk_draw > 26.4: nPage = scribus.currentPage() + 1 pageendtext = "Fortsetzung nächste Seite" #print nPage scribus.createText(start_x_0 + 0.1, start_y + 0.1, 17, 0.5, "box_txt_pageend") scribus.sentToLayer("profil_txt", "box_txt_pageend") scribus.setText(pageendtext, "box_txt_pageend") scribus.setStyle("Buchner_sehrklein", "box_txt_pageend") scribus.newPage(-1,"Buchner_Standard") scribus.gotoPage(nPage) start_y = float(5.5) strat_uk_draw = start_y + strat_draw box_nr = int(0) #print strat_uk #print "aktuelle Seite:", scribus.currentPage() #print strat_uk strat_uk_txt = str(strat_uk).replace(".", ","); #print strat_uk_txt strat_h = line[0] strat_n = line[1] strat_b = line[2] strat_p = line[3] strat_a = line[4] strat = [strat_d, strat_uk, strat_h, strat_n, strat_b, strat_p, strat_a] #print strat strats.append(strat) for box in boxes: box_n = box[0] + str(strat_ct) box_txt = strat[box_nr + 2] box_txt_n = box_n + "txt" #print box_nr #print box_txt #print box_n, box_txt_n, dimensions[1], position scribus.createRect(start_x_0, start_y, float(box[1]), strat_draw, box_n) scribus.setLineWidth(0.567, box_n) scribus.sentToLayer("profil_rahmen", box_n) if box_nr == 0: scribus.createText(start_x_0 + 0.1, start_y + (strat_draw) - 0.4, float(box[1]) - 0.2, 0.4, box_txt_n) #print strat_uk_txt scribus.setText(strat_uk_txt, box_txt_n) else: scribus.createText(start_x_0 + 0.1, start_y + 0.1, float(box[1]) - 0.2, (strat_draw) - 0.1, box_txt_n) scribus.setText(box_txt, box_txt_n) scribus.setStyle("Buchner_Standard schmal", box_txt_n) scribus.sentToLayer("profil_txt", box_txt_n) start_x_0 = start_x_0 + float(box[1]) box_nr = box_nr + 1 #print "end: strat count:", strat_ct start_y = strat_uk_draw start_x_0 = start_x strat_ok = strat_ok + float(strat_d) print "end: all" scribus.createText(start_x_0 + 0.1, start_y + 0.1, 17, 0.5, "box_txt_end") scribus.sentToLayer("profil_txt", "box_txt_end") endtext = "Erstellt von " + getpass.getuser() + " mit " + fname_ext + ", " + script + " (V" + version + ")" scribus.setText(endtext, "box_txt_end") scribus.setStyle("Buchner_sehrklein", "box_txt_end") scribus.saveDocAs(fname_noext + ".sla")
page_count = range(1, scribus.pageCount() + 1) scribus.closeDoc() return tuple(page_count) # Variables base_file = args.files[0] import_file = args.files[1] page_number = args.page - 1 insert_position = 0 if args.before is True else 1 # 0 = before; 1 = after master_page = args.masterpage total_pages = get_pages_range(import_file) # Importing `import_file` scribus.openDoc(base_file) scribus.importPage(import_file, total_pages, 1, insert_position, page_number) # Applying masterpage(s) for number in range(page_number + 2, page_number + len(total_pages) + 2): scribus.applyMasterPage(master_page, number) # Either overwriting `import_file` .. if args.output is None: scribus.saveDoc() # .. or creating new `output` file (requires `--output`) else: scribus.saveDocAs(args.output) scribus.closeDoc()
if not os.path.exists(baseDirName): os.makedirs(baseDirName) else: for the_file in os.listdir(baseDirName): file_path = os.path.join(baseDirName, the_file) try: if os.path.isfile(file_path): os.unlink(file_path) except Exception, e: print e #Make Document Temporary scribus.saveDoc() scribus.saveDocAs(tmpFileName) scribus.messagebarText("Dokument in Bearbeitung, bitte warten") scribus.closeDoc() scribus.messagebarText("Dokument in Bearbeitung, bitte warten") scribus.openDoc(tmpFileName) scribus.selectText(0, 1, idtextstring) idfont = scribus.getFont(idtextstring) idfonSize = scribus.getFontSize(idtextstring) idtextcolor = scribus.getTextColor(idtextstring) idtextshade = scribus.getTextShade(idtextstring) scribus.selectText(0, 1, gertextstring) gerfont = scribus.getFont(gertextstring) gerfonSize = scribus.getFontSize(gertextstring)
def main(argv): if not scribus.haveDoc(): sys.exit(1) os.chdir(os.path.expanduser("~")) #### #### If you have a different location of your laidout program change it here: #### laidoutexecutable="/usr/bin/laidout" if os.path.exists(laidoutexecutable)==False: laidoutexecutable="/usr/local/bin/laidout" if os.path.exists(laidoutexecutable)==False: print "Could not find Laidout!" print "Please change scribus-call-laidout-to-impose-gui.py to have a correct path!" #scribus.messageBox("Could not find Laidout!", # "Please change line 37 in scribus-call-laidout-to-impose-gui.py to have a correct path!") #laidoutexecutable=scribus.valueDialog("Laidout path","You do not appear to have Laidout installed! Please enter a valid path for running Laidout","/usr/bin/laidout") laidoutexecutable=scribus.fileDialog('Please locate Laidout executable!!', defaultname='/usr/bin/laidout', issave=False) print "New laidout executable path: "+laidoutexecutable #fail if still not found if os.path.exists(laidoutexecutable)==False: scribus.messageBox("Could not find Laidout!", "Please either change line for \'laidoutexecutable=\"/usr/bin/laidout\"\' in scribus-call-laidout-to-impose-gui.py" " to have a correct path, or enter a valid path.") sys.exit(1) thecommand="" infile=os.getcwd()+"/this-is-a-temporary-file.sla" #note this saves to a very random area usually!! reimposed=os.getcwd()+"/this-is-reimposed-from-laidout.sla" # seems like directory of the plugin #infile =tempfile.NamedTemporaryFile() <-- maybe this can be used instead?? how to create, get filename, then let laidout open?? #outfile=tempfile.NamedTemporaryFile() <-- maybe this can be used instead?? size=scribus.getPageSize() units=scribus.getUnit() width=0 height=0 print "size "+str(size[0])+","+str(size[1]) print "units "+str(units) if (units==scribus.UNIT_MILLIMETERS): width=size[0]/10/2.54 height=size[1]/10/2.54 elif (units==scribus.UNIT_PICAS): width=size[0]/6 height=size[1]/6 elif (units==scribus.UNIT_POINTS): width=size[0]/72 height=size[1]/72 elif (units==scribus.UNIT_INCHES): width=size[0] height=size[1] else: print "unknown units!!!" scribus.messageBox("Unknown units!","For some reason, scribus.getUnit() did not return units known to this script!" "This is probably a bug with the script.") #thecommand="/bin/ls" thecommand=laidoutexecutable+" --impose-only " \ +"'in=\""+infile+"\" " \ +" out=\""+reimposed+"\" " \ +" prefer=\"booklet\"" \ +" width=\""+str(width)+"\"" \ +" height=\""+str(height)+"\"" \ +"'" #print "command:\n", thecommand try: print "Creating temporary file ",infile,"..." scribus.saveDocAs(infile) except: print "Could not save as ",infile sys.exit(1) try: print "Trying: "+thecommand os.system(thecommand) except: print "An error occured trying to run the system command:\n",thecommand sys.exit(1) if os.path.exists(reimposed)==False: print "Reimposed file was not generated!" sys.exit(1) #scribus.closeDoc() #closes the "original" document, which has been rename to infile upon saveDocAs() scribus.openDoc(reimposed) #open the brand spanking new reimposed document #if (os.path.isfile(reimposed)): os.remove(reimposed) <-- might cause problems, but keep around for research print "Removing temporary file ",infile,"..." os.remove(infile) print "All done!"
def main(argv): if not scribus.haveDoc(): sys.exit(1) os.chdir(os.path.expanduser("~")) #### #### If you have a different location of your laidout program change it here: #### laidoutexecutable = "/usr/bin/laidout" if os.path.exists(laidoutexecutable) == False: laidoutexecutable = "/usr/local/bin/laidout" if os.path.exists(laidoutexecutable) == False: print "Could not find Laidout!" print "Please change scribus-call-laidout-to-impose-gui.py to have a correct path!" #scribus.messageBox("Could not find Laidout!", # "Please change line 37 in scribus-call-laidout-to-impose-gui.py to have a correct path!") #laidoutexecutable=scribus.valueDialog("Laidout path","You do not appear to have Laidout installed! Please enter a valid path for running Laidout","/usr/bin/laidout") laidoutexecutable = scribus.fileDialog( 'Please locate Laidout executable!!', defaultname='/usr/bin/laidout', issave=False) print "New laidout executable path: " + laidoutexecutable #fail if still not found if os.path.exists(laidoutexecutable) == False: scribus.messageBox( "Could not find Laidout!", "Please either change line for \'laidoutexecutable=\"/usr/bin/laidout\"\' in scribus-call-laidout-to-impose-gui.py" " to have a correct path, or enter a valid path.") sys.exit(1) thecommand = "" infile = os.getcwd( ) + "/this-is-a-temporary-file.sla" #note this saves to a very random area usually!! reimposed = os.getcwd( ) + "/this-is-reimposed-from-laidout.sla" # seems like directory of the plugin #infile =tempfile.NamedTemporaryFile() <-- maybe this can be used instead?? how to create, get filename, then let laidout open?? #outfile=tempfile.NamedTemporaryFile() <-- maybe this can be used instead?? size = scribus.getPageSize() units = scribus.getUnit() width = 0 height = 0 print "size " + str(size[0]) + "," + str(size[1]) print "units " + str(units) if (units == scribus.UNIT_MILLIMETERS): width = size[0] / 10 / 2.54 height = size[1] / 10 / 2.54 elif (units == scribus.UNIT_PICAS): width = size[0] / 6 height = size[1] / 6 elif (units == scribus.UNIT_POINTS): width = size[0] / 72 height = size[1] / 72 elif (units == scribus.UNIT_INCHES): width = size[0] height = size[1] else: print "unknown units!!!" scribus.messageBox( "Unknown units!", "For some reason, scribus.getUnit() did not return units known to this script!" "This is probably a bug with the script.") #thecommand="/bin/ls" thecommand=laidoutexecutable+" --impose-only " \ +"'in=\""+infile+"\" " \ +" out=\""+reimposed+"\" " \ +" prefer=\"booklet\"" \ +" width=\""+str(width)+"\"" \ +" height=\""+str(height)+"\"" \ +"'" #print "command:\n", thecommand try: print "Creating temporary file ", infile, "..." scribus.saveDocAs(infile) except: print "Could not save as ", infile sys.exit(1) try: print "Trying: " + thecommand os.system(thecommand) except: print "An error occured trying to run the system command:\n", thecommand sys.exit(1) if os.path.exists(reimposed) == False: print "Reimposed file was not generated!" sys.exit(1) #scribus.closeDoc() #closes the "original" document, which has been rename to infile upon saveDocAs() scribus.openDoc(reimposed) #open the brand spanking new reimposed document #if (os.path.isfile(reimposed)): os.remove(reimposed) <-- might cause problems, but keep around for research print "Removing temporary file ", infile, "..." os.remove(infile) print "All done!"
i += 1 if (i > 796): break scribus.newPage(-1) scribus.newPage(-1) credits = """Credits: the handydandy Bernhard Bauch Luc Gross Nicolaj Kirisits Gordan Savicic Julia Staudacher Florian Waldner Nickelsdorf, 2012 http://thehandydandy.yugo.at Danksagung: Gunther Grasser, etxt...""" textframes("credits", 26, 140, 160, 110, "White","Black", 10, "FreeSerif Medium", 0, credits,"text", 0, 0) # final // save doc && export PDF scribus.saveDocAs("schwarzung.sla") pdf = scribus.PDFfile() #pdf.file = 'hd.pdf' #pdf.save() #scribus.closeDoc()
def frontPage(LogoPath, ChurchPath, ChurchImage, Citation, CitationLocation): #scribus.setText('Gemeindebrief DIGITAL Buxtehude',"Oben") #Line upper left corner l_line = scribus.createLine(10,10,10,33,"l_Line") scribus.setLineWidth(0.75, l_line) scribus.setLineColor("NAK-blau 100%", l_line) scribus.setLineShade("NAK-blau 100%", l_line) #Headline t_headline = scribus.createText(10,22,128,20,"t_Headline") scribus.setText("Gemeindebrief", t_headline) scribus.selectText(1, 100, t_headline) scribus.setCharacterStyle( "Erste Seite - Gemeindebrief - gross", t_headline) scribus.deselectAll() # Digital - Text t_digitalText = scribus.createText(107,27,30,7, "t_Digital") scribus.selectText(1, 100, t_digitalText) scribus.setCharacterStyle( "Erste Seite - Gemeindebrief - gross", t_digitalText) scribus.deselectAll() # Congregation - Text t_congregationText = scribus.createText(10,35.250, 70, 6, "t_Congregation") scribus.selectText(1, 100, t_congregationText) scribus.setCharacterStyle( "Erste Seite - Gemeindebrief - klein", t_congregationText) scribus.deselectAll() # Month Year t_monthYear = scribus.createText(56, 46.500, 82, 10, "t_MonthYear") scribus.selectText(1, 100, t_monthYear) scribus.setCharacterStyle( "Erste Seite - Gemeindebrief - Monat", t_monthYear) scribus.deselectAll() # Logo charitable i_charitable = scribus.createImage(10, 46, 35.5, 9, "i_NAC_charitable") scribus.loadImage(LogoPath + "Logo_NAK_karitativ_HQ.tiff", i_charitable) scribus.setImageScale(0.0613, 0.0613, i_charitable) # Church image i_churchImage = scribus.createImage(10,57,128,100,"i_Church") scribus.loadImage(ChurchPath + ChurchImage, i_churchImage) scribus.setImageScale(1, 1, i_churchImage) scribus.setImageOffset(-18.244, -0.342, i_churchImage) # Citation t_citation = scribus.createText(42.500, 162.500,95.500,4.500, "t_Citation") # OverflowCheck scribus.setText(Citation, t_citation) scribus.selectText(1, 100, t_citation) scribus.setCharacterStyle("Erste Seite - Bibelzitat - Text", t_citation) scribus.deselectAll() # Citation Location t_citationLocation = scribus.createText(42.500, 170, 95.500, 3, "t_CitationLocation") scribus.setText(CitationLocation, t_citationLocation) scribus.selectText(1, 100, t_citationLocation) scribus.setCharacterStyle( "Erste Seite - Bibelzitat - Ort", t_citationLocation) scribus.deselectAll() # NAC t_nac = scribus.createText(52.500,195,66,5,"t_NAC") scribus.setText("Neuapostolische Kirche", t_nac) scribus.selectText(1, 100, t_nac) scribus.setCharacterStyle("Erste Seite - NAK", t_nac) scribus.deselectAll() # North and east germany t_northEastGermany = scribus.createText(52.500, 195, 66, 5, "t_NorthEastGermany") scribus.setText("Nord- und Ostdeutschland", t_northEastGermany) scribus.selectText(1, 100, t_northEastGermany) scribus.setCharacterStyle( "Erste Seite - Nord- und Ostdeutschland", t_northEastGermany) scribus.deselectAll() # NAC Logo i_nacLogo = scribus.createImage(122, 184, 16, 16,"i_Logo") scribus.loadImage("L:\\GB\\Bilder\\Logos\\Logo_NAK_HQ.tif", i_nacLogo) scribus.setImageScale(0.0384, 0.0384, i_nacLogo) scribus.saveDocAs()