Example #1
0
def main():
    text_frames, image_frames = get_placeholders()

    sla_template_filename = scribus.getDocName()
    sla_template_path = Path(sla_template_filename)

    if 'file' in CONFIGURATION['data'] and CONFIGURATION['data']['file']:
        data_path = str(
            sla_template_path.parent.joinpath(CONFIGURATION['data']['file']))
    elif CONFIGURATION['data']['format'] == 'json':
        data_path = sla_template_path.with_suffix('.json')
    else:
        data_path = sla_template_path.with_suffix('.csv')

    if not os.path.isfile(data_path):
        sys.exit()

    if CONFIGURATION['data']['format'] == 'json':
        pass
    else:
        data_file = open(data_path, 'rt')
        reader = csv.DictReader(data_file)

    pdf_base_filename = sla_template_path.stem
    pdf_path = Path(sla_template_path.parent)

    if CONFIGURATION['output']['pdf']:
        pdf = scribus.PDFfile()
        pdf.quality = 0
        pdf.fontEmbedding = 0
        pdf.version = 14

        scribus.setRedraw(False)
        for row in reader:
            for frame, placeholders in text_frames:
                fill_text_placeholders(frame, placeholders, row)
            for frame, placeholders in image_frames:
                fill_image_placeholders(frame, placeholders, row)

            pdf.file = str(
                pdf_path.joinpath(pdf_base_filename + '-' +
                                  next(iter(row.items()))[1].lower() + '.pdf'))
            pdf.save()

            scribus.docChanged(True)
            scribus.revertDoc()
        scribus.setRedraw(True)
    elif CONFIGURATION['output']['single-sla']:
        original_pages = list(range(1, scribus.pageCount() + 1))
        for row in reader:
            new_frames = duplicate_content(
                original_pages, [i[0] for i in text_frames + image_frames])

            for frame, placeholders in text_frames:
                fill_text_placeholders(new_frames[frame], placeholders, row)
            for frame, placeholders in image_frames:
                fill_image_placeholders(new_frames[frame], placeholders, row)
        for page in original_pages:
            scribus.deletePage(page)
Example #2
0
def main():
    # hole Pfad aus der geoeffneten Datei
    dateiPfad = os.path.split(scribus.getDocName())[0]
    # extrahiere den Dateinamen ohne Erweiterung
    dateiName = os.path.splitext(os.path.basename(scribus.getDocName()))[0]
    # pdf-Objekt erzeugen
    pdf = scribus.PDFfile()
    # PDF-Info fuer Konformitaet PDF-X[34] irgendwas reinschreiben
    pdf.info = "Scribus-Source file -" + dateiName + ".sla - created by Robert Johnen"
    # Dateiname fuer PDF-Objekt festlegen
    pdf.file = dateiPfad + "/" + dateiName + ".pdf"
    # PDF-Objekt speichern
    pdf.save()
Example #3
0
    def exportPDF(self, scribusFilePath, pdfFilePath):
        import scribus

        d = os.path.dirname(pdfFilePath)
        if not os.path.exists(d):
            os.makedirs(d)

        # Export to PDF
        scribus.openDoc(scribusFilePath)
        listOfPages = []
        i = 0
        while (i < scribus.pageCount()):
            i = i + 1
            listOfPages.append(i)

        pdfExport = scribus.PDFfile()
        pdfExport.info = CONST.APP_NAME
        pdfExport.file = str(pdfFilePath)
        pdfExport.pages = listOfPages
        pdfExport.save()
        scribus.closeDoc()
Example #4
0
try:
    opts, args = getopt.getopt(sys.argv[2:], "ho:t:v:", ["output=", "text="])
except getopt.GetoptError:
    print "exceptin"
    print(text_usage)
    sys.exit(2)

for opt, arg in opts:
    if opt == "-h":
        print(text_usage)
        sys.exit()
    elif opt in ("-o", "--output"):
        pdf_file = arg
    elif opt in ("-t", "--text"):
        text_placeholder = arg

print "pdf-file %s text %s" % (pdf_file, text_placeholder)

if (pdf_file == ""):
    print(text_usage)
    print opts
    sys.exit()

if scribus.haveDoc():
    #scribus.setText(text_placeholder, "placeholder")
    pdf = scribus.PDFfile()
    pdf.file = pdf_file
    pdf.save()
else:
    print("No file open")
Example #5
0
def main():
    try:
        import scribus
    except ImportError:
        # if the script does not run inside of scribus, launch scribus with this script as paremeter

        filename = []

        if (len(sys.argv) == 2):
            print("launching the script for " + sys.argv[1])
            filename.append(sys.argv[1])
        else:
            print("launching the script for each .sla in the directory.")
            for file in os.listdir('.'):
                filenameSplit = os.path.splitext(file)
                if filenameSplit[-1] == '.sla' and filenameSplit[0].find(
                        '_autosave_') == -1:
                    filename.append(file)

        arguments = []
        for argument in sys.argv[1:]:
            if argument[0] == '-':
                # arguments.append('--python-arg')
                arguments.append('-pa')
                arguments.append(argument.strip('-'))

        print(arguments)
        for file in filename:
            call(['scribus', '-g', '-py', sys.argv[0]] + arguments +
                 ['--', file])

        sys.exit(1)

    if scribus.haveDoc():

        page_sizes = {(210, 297): 'A4', (148, 210): 'A5', (105, 148): 'A6'}

        filename = os.path.splitext(scribus.getDocName())[0]
        pdf = scribus.PDFfile()
        page_size = tuple(int(round(s)) for s in scribus.getPageSize())
        print(page_sizes[page_size])
        page_size = page_sizes[page_size]

        pdf.file = filename + '-' + page_size.lower() + '.pdf'
        pdf.save()

        single_sided = 'single' in sys.argv
        print(sys.argv)
        print(single_sided)
        # sys.exit(1)

        pdf = scribus.PDFfile()
        pdf.file = filename + "-reordered.pdf"
        pdf.pages = get_a4_pages(page_size, single_sided, scribus.pageCount())
        print(page_size)
        print(single_sided)
        print(scribus.pageCount())
        print(pdf.pages)
        pdf.save()

        # os.system("pdfnup --nup 2x2 --frame false --no-landscape " + filename + "-reordered.pdf --outfile " + filename.replace("a6", "a4") + ".pdf")
        call([
            'pdfnup', '--nup', '2x2', '--frame', 'false', '--no-landscape',
            filename + '-reordered.pdf', '--outfile', filename + "-a4.pdf"
        ])
        os.remove(pdf.file)
    else:
        print("No file open")
Example #6
0
    def main(self):

        # Load up all the file and record information.
        # Use CSV reader to build list of record dicts
        records = self.loadCSVData(self.dataFile)
        totalRecs = len(records)

        # Reality check first to see if we have anything to process
        if totalRecs <= 0:
            scribus.messageBox('Not Found', 'No records found to process!')
            sys.exit()

        pageNumber = 1
        recCount = 0
        row = 0
        pageSide = 'Odd'
        scribus.progressTotal(totalRecs)
        paIndex = {}
        lastName = ''
        firstName = ''
        photoFirstName = ''
        verseRef = ''
        verseText = ''

        # Get the page layout coordinates for this publication
        crds = self.getCoordinates(self.dimensions)

        # Make a new document to put our records on
        if scribus.newDocument(
                getattr(scribus, self.dimensions['page']['scribusPageCode']),
            (self.dimensions['margins']['left'],
             self.dimensions['margins']['right'],
             self.dimensions['margins']['top'],
             self.dimensions['margins']['bottom']), scribus.PORTRAIT, 1,
                scribus.UNIT_POINTS, scribus.NOFACINGPAGES,
                scribus.FIRSTPAGERIGHT, 1):

            self.setPageNumber(crds, pageSide, row, pageNumber)

            while recCount < totalRecs:

                # Output a new page on the first row after we have done the first page
                if row == 0 and recCount != 0:
                    scribus.newPage(-1)
                    if pageSide == 'Odd':
                        pageSide = 'Even'
                    else:
                        pageSide = 'Odd'

                    self.setPageNumber(crds, pageSide, row, pageNumber)

                ########### Now set the current record in the current row ##########

                # Set the last name
                lastName = records[recCount]['NameLast']

                # Adjust the NameFirst field to include the spouse if there is one
                if records[recCount]['Spouse'] != '':
                    firstName = records[recCount][
                        'NameFirst'] + ' & ' + records[recCount]['Spouse']
                else:
                    firstName = records[recCount]['NameFirst']

                # Make the photo file name
                photoFirstName = firstName.replace('&', '-').replace(
                    '.', '').replace(' ', '')

                # Set our record count for progress display and send a status message
                scribus.progressSet(recCount)
                scribus.statusMessage('Placing record ' + ` recCount ` +
                                      ' of ' + ` totalRecs `)

                # Add a watermark if a string is specified
                if self.outputWatermark:
                    self.addWatermark()

                # Put the last name element in this row
                nameLastBox = scribus.createText(crds[row]['nameLastXPos'],
                                                 crds[row]['nameLastYPos'],
                                                 crds[row]['nameLastWidth'],
                                                 crds[row]['nameLastHeight'])
                scribus.setText(lastName, nameLastBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, nameLastBox)
                scribus.setTextDistances(0, 0, 0, 0, nameLastBox)
                scribus.setFont(self.fonts['nameLast']['bold'], nameLastBox)
                scribus.setFontSize(self.fonts['nameLast']['size'],
                                    nameLastBox)
                scribus.setTextShade(80, nameLastBox)
                scribus.rotateObject(90, nameLastBox)

                # Place the first name element in this row
                nameFirstBox = scribus.createText(crds[row]['nameFirstXPos'],
                                                  crds[row]['nameFirstYPos'],
                                                  crds[row]['nameFirstWidth'],
                                                  crds[row]['nameFirstHeight'])
                scribus.setText(records[recCount]['Caption'], nameFirstBox)
                scribus.setTextAlignment(scribus.ALIGN_LEFT, nameFirstBox)
                scribus.setFont(self.fonts['nameFirst']['boldItalic'],
                                nameFirstBox)
                scribus.setFontSize(self.fonts['nameFirst']['size'],
                                    nameFirstBox)

                # Place the image element in this row
                # We will need to do some processing on the first pass
                # The default output format is JPG
                orgImgFileName = records[recCount]['Photo']
                orgImgFile = os.path.join(self.orgImgDir, orgImgFileName)
                baseImgFileName = lastName + '_' + photoFirstName
                if self.willBePngImg:
                    ext = 'png'
                else:
                    ext = 'jpg'
                if not self.rgbColor:
                    imgFile = os.path.join(
                        getattr(self, ext + 'ImgDir'),
                        baseImgFileName + '-gray' + '.' + ext)
                else:
                    imgFile = os.path.join(getattr(self, ext + 'ImgDir'),
                                           baseImgFileName + '.' + ext)

                # Process the image now if there is none
                if not os.path.exists(imgFile):
                    self.img_process.sizePic(orgImgFile, imgFile,
                                             self.maxHeight)
                    #                    self.img_process.outlinePic(imgFile, imgFile)
                    self.img_process.scalePic(imgFile, imgFile,
                                              self.imgDensity)
                    self.img_process.addPoloroidBorder(imgFile, imgFile)
                    # Color RGB is the default
                    if not self.rgbColor:
                        self.img_process.makeGray(imgFile, imgFile)

                # Double check the output and substitute with placeholder pic
                if not os.path.exists(imgFile):
                    imgFile = self.placeholderPic
                # Create the imageBox and load the picture
                imageBox = scribus.createImage(crds[row]['imageXPos'],
                                               crds[row]['imageYPos'],
                                               crds[row]['imageWidth'],
                                               crds[row]['imageHeight'])
                if os.path.isfile(imgFile):
                    scribus.loadImage(imgFile, imageBox)
                scribus.setScaleImageToFrame(scaletoframe=1,
                                             proportional=1,
                                             name=imageBox)

                # Place the country element in this row (add second one if present)
                countryBox = scribus.createText(crds[row]['countryXPos'],
                                                crds[row]['countryYPos'],
                                                crds[row]['countryWidth'],
                                                crds[row]['countryHeight'])
                countryLine = records[recCount]['Country1']
                try:
                    if records[recCount]['Country2'] != '':
                        countryLine = countryLine + ' & ' + records[recCount][
                            'Country2']
                except:
                    pass
                scribus.setText(countryLine, countryBox)
                scribus.setTextAlignment(scribus.ALIGN_RIGHT, countryBox)
                scribus.setFont(self.fonts['text']['boldItalic'], countryBox)
                scribus.setFontSize(self.fonts['text']['size'], countryBox)

                # Place the assignment element in this row
                assignBox = scribus.createText(crds[row]['assignXPos'],
                                               crds[row]['assignYPos'],
                                               crds[row]['assignWidth'],
                                               crds[row]['assignHeight'])
                scribus.setText(self.fixText(records[recCount]['Assignment']),
                                assignBox)
                # Assign style to box
                #                scribus.createParagraphStyle(name='assignStyle', alignment=0, leftmargin=10, firstindent=-10)
                #                scribus.setStyle('assignStyle', assignBox)
                # Hard formated box
                scribus.setTextAlignment(scribus.ALIGN_LEFT, assignBox)
                scribus.setFont(self.fonts['text']['italic'], assignBox)
                scribus.setFontSize(self.fonts['text']['size'], assignBox)
                scribus.setLineSpacing(self.fonts['text']['size'] + 1,
                                       assignBox)
                scribus.setTextDistances(4, 0, 0, 0, assignBox)
                # Resize the frame height and determine the difference for
                # placing the next frame below it
                assignHeightNew = self.resizeFrame(assignBox)
                assignHeightDiff = crds[row]['assignHeight'] - assignHeightNew

                # Place the verse element in this row
                verseYPosNew = crds[row]['verseYPos'] - assignHeightDiff
                verseBox = scribus.createText(crds[row]['verseXPos'],
                                              verseYPosNew,
                                              crds[row]['verseWidth'],
                                              crds[row]['verseHeight'])
                # The verse element may be either a Scripture verse or a prayer request
                # If it is Scripture, and it has a verse ref, we want to set that
                # seperatly so we need to do a little preprocess on the text to find
                # out if it has a ref. This script will only recognize references
                # at the end of the string that are enclosed in brackets. See the
                # findVerseRef() function for more details
                verseRef = self.findVerseRef(records[recCount]['Prayer'])
                if verseRef:
                    verseText = self.removeVerseRef(
                        self.fixText(records[recCount]['Prayer']))
                    scribus.setText(verseText, verseBox)
                else:
                    scribus.setText(self.fixText(records[recCount]['Prayer']),
                                    verseBox)
                # Can't find a way to set alignment to justified using setTextAlignment()
#                scribus.setTextAlignment(scribus.ALIGN_LEFT, verseBox)
# Because of this, we make a style which seems to work
                scribus.createParagraphStyle(name='vBoxStyle', alignment=3)
                scribus.setStyle('vBoxStyle', verseBox)
                scribus.setFont(self.fonts['verse']['regular'], verseBox)
                scribus.setFontSize(self.fonts['verse']['size'], verseBox)
                scribus.setLineSpacing(self.fonts['verse']['size'] + 1,
                                       verseBox)
                scribus.setTextDistances(4, 0, 4, 0, verseBox)
                if self.hyphenate:
                    scribus.hyphenateText(verseBox)
                # Get the height difference in case we need to set ref box
                verseHeightNew = self.resizeFrame(verseBox)
                verseHeightDiff = crds[row]['verseHeight'] - verseHeightNew
                if verseRef:
                    # Set coordinates for this box
                    vRefBoxX = crds[row]['verseXPos']
                    vRefBoxY = (verseYPosNew + verseHeightNew)
                    vRefBoxH = crds[row]['nameFirstHeight'] / 2
                    vRefBoxW = crds[row]['verseWidth']
                    verseRefBox = scribus.createText(vRefBoxX, vRefBoxY,
                                                     vRefBoxW, vRefBoxH)
                    scribus.setText(verseRef, verseRefBox)
                    scribus.setTextAlignment(scribus.ALIGN_RIGHT, verseRefBox)
                    scribus.setFont(self.fonts['verse']['italic'], verseRefBox)
                    scribus.setFontSize(self.fonts['verse']['size'] - 2,
                                        verseRefBox)
                    scribus.setLineSpacing(self.fonts['verse']['size'],
                                           verseRefBox)
                    scribus.setTextDistances(2, 0, 0, 0, verseRefBox)

                # Up our counts
                if row >= self.dimensions['rows']['count'] - 1:
                    row = 0
                    pageNumber += 1
                else:
                    row += 1

                recCount += 1

            # Create the index page here
            # Output a new page for the index
            if row == 0 and recCount != 0:
                scribus.newPage(-1)
                if pageSide == 'Odd':
                    pageSide = 'Even'
                else:
                    pageSide = 'Odd'

                self.setPageNumber(crds, pageSide, 0, pageNumber)

        # Outut the index entries at this point
#        for key in paIndex.keys() :

# Report we are done now before we loose focus
        scribus.statusMessage('Process Complete!')

        ###############################################################################
        ############################## Output Results #################################
        ###############################################################################

        # Now we will output the results to PDF if that is desired
        if self.makePdf:
            pdfExport = scribus.PDFfile()
            pdfExport.info = self.pdfFile
            pdfExport.file = self.pdfFile
            pdfExport.save()

        # View the output if set
        if self.makePdf and self.viewPdf:
            cmd = ['evince', self.pdfFile]
            try:
                subprocess.Popen(cmd)
            except Exception as e:
                result = scribus.messageBox(
                    'View PDF command failed with: ' + str(e),
                    scribus.BUTTON_OK)
def run_script():
    args = get_args_scribus()
    print('booooklet ' + str(args.booklet))

    if not scribus.haveDoc():
        print("No file open")
        return

    filename = os.path.splitext(scribus.getDocName())[0]

    # scribus.getPageSize()
    # create a PDF with the original size
    pdf = scribus.PDFfile()
    pdf.file = filename + ".pdf"
    pdf.save()

    # create a pdf with the page reordered
    # get it to be steared by facing pages and first page left / right
    # it's booklet if it has facing pages and first page right
    # (the function are probably not in the API yet)
    n = scribus.pageCount()
    pdf = scribus.PDFfile()
    pdf.file = filename + "-reordered.pdf"
    if (n == 1):
        pdf.pages = [1, 1, 1, 1]
    elif (n == 2):
        pdf.pages = [1, 1, 1, 1, 2, 2, 2, 2]
    elif (n == 4):
        if args.booklet:
            pdf.pages = [4, 1, 4, 1, 2, 3, 2, 3]
        else:
            pdf.pages = [1, 3, 1, 3, 4, 2, 4, 2]
    elif (n == 8):
        if args.booklet:
            pdf.pages = [8, 1, 6, 3, 2, 7, 4, 5]
        else:
            pdf.pages = [1, 3, 5, 7, 4, 2, 8, 6]
    elif (n == 12):
        if args.booklet:
            pdf.pages = [12, 1, 2, 11, 10, 3, 4, 9, 8, 5, 6, 7]
        else:
            pass
    elif (n == 16):
        if args.booklet:
            pdf.pages = [
                16, 1, 14, 3, 2, 15, 4, 13, 12, 5, 10, 7, 6, 11, 8, 9
            ]  # <- first join top/down , then staple 1/2
        else:
            pass
    elif (n == 24):
        if args.booklet:
            pass
        else:
            pdf.pages = [
                1, 3, 5, 7, 4, 2, 8, 6, 9, 11, 13, 15, 12, 10, 16, 14, 17, 19,
                21, 23, 20, 18, 24, 22
            ]  # mit starter cards
    else:
        print('{} are not yet supported'.format(n))
    pdf.save()

    call_args = [
        'pdfnup', '--nup', '2x2', '--frame', 'false', '--no-landscape'
    ]
    call_args += ['--', 'outfile', filename.replace("a6", "a4") + ".pdf"]
    call_args += [filename + '-reordered.pdf']
    subprocess.call(call_args)

    os.system("pdfnup --nup 2x2 --frame false --no-landscape " + filename +
              "-reordered.pdf --outfile " + filename.replace("a6", "a4") +
              ".pdf")
    os.remove(pdf.file)
Example #8
0
def processFile():
   

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()

def colors():
    scribus.defineColorCMYKFloat("NAK-blau 100%", 68.0, 34.0, 0.0, 0.0)
    scribus.defineColorRGB("Tabelle-Hintergrund", 215, 225, 243)
    scribus.deleteColor("Blue")
    scribus.deleteColor("Cool Black")
    scribus.deleteColor("Cyan")
    scribus.deleteColor("Green")
    scribus.deleteColor("Magenta")
    scribus.deleteColor("Red")
    scribus.deleteColor("Registration")
    scribus.deleteColor("Rich Black")
    scribus.deleteColor("Warm Black")
    scribus.deleteColor("Yellow")

def createCharStyle(Name, Font, FontSize, Features="", BaseLineOffset = 0, Tracking = 0):
    scribus.createCharStyle(
        Name,
        font=Font,
        fontsize=FontSize,
        features=Features,
        fillcolor="",
        fillshade=1.0,
        strokecolor="Black",
        strokeshade=1.0,
        baselineoffset=BaseLineOffset,
        shadowxoffset=0,
        shadowyoffset=0,
        outlinewidth=0,
        underlineoffset=0,
        underlinewidth=0,
        strikethruoffset=0,
        strikethruwidth=0,
        scaleh=1,
        scalev=1,
        tracking=Tracking
    )


def createParagraphStyle(Name, LineSpacingMode, Alignment, LeftMargin, RightMargin, GapBefore, GapAfter, FirstIndent, CharStyle, LineSpacing = 0, HasDropCap = 0, DropCapLines = 0 ):
    
    if (LineSpacingMode != 0 and HasDropCap != 0 ):
        scribus.createParagraphStyle(
            Name,
            linespacingmode=LineSpacingMode,
            alignment=Alignment,
            leftmargin=LeftMargin,
            rightmargin=RightMargin,
            gapbefore=GapBefore,
            gapafter=GapAfter,
            firstindent=FirstIndent,
            hasdropcap=HasDropCap,
            dropcaplines=DropCapLines,
            charstyle=CharStyle)
    if (LineSpacingMode == 0 and HasDropCap != 0):
        scribus.createParagraphStyle(
            Name,
            linespacingmode=LineSpacingMode,
            linespacing=LineSpacing,
            alignment=Alignment,
            leftmargin=LeftMargin,
            rightmargin=RightMargin,
            gapbefore=GapBefore,
            gapafter=GapAfter,
            firstindent=FirstIndent,
            hasdropcap=HasDropCap,
            dropcaplines=DropCapLines,
            charstyle=CharStyle)
    if (LineSpacingMode != 0 and HasDropCap == 0):
        scribus.createParagraphStyle(
            Name,
            linespacingmode=LineSpacingMode,
            alignment=Alignment,
            leftmargin=LeftMargin,
            rightmargin=RightMargin,
            gapbefore=GapBefore,
            gapafter=GapAfter,
            firstindent=FirstIndent,
            hasdropcap=HasDropCap,
            charstyle=CharStyle)
    if (LineSpacingMode == 0 and HasDropCap == 0):
        scribus.createParagraphStyle(
            Name,
            linespacingmode=LineSpacingMode,
            linespacing=LineSpacing,
            alignment=Alignment,
            leftmargin=LeftMargin,
            rightmargin=RightMargin,
            gapbefore=GapBefore,
            gapafter=GapAfter,
            firstindent=FirstIndent,
            hasdropcap=HasDropCap,
            charstyle=CharStyle)


def processInterfaceFile(InterfaceFile):
     with open(InterfaceFile) as lfiInterfaceFile:
        larrData = json.load(lfiInterfaceFile)

    # Output: {'name': 'Bob', 'languages': ['English', 'Fench']}
    print(larrData)

    for larrAction in larrData:
        print(lstrFile)
        scribus.openDoc(lstrFile)
        lstrFilename = os.path.splitext(scribus.getDocName())[0]
        pdf = scribus.PDFfile()
        pdf.compress = True
        pdf.compressmtd = 1
        pdf.quality = 2
        pdf.file = lstrFilename+".pdf"
        pdf.save()
        scribus.closeDoc()