Giter VIP home page Giter VIP logo

scribusgenerator's Introduction

ScribusGenerator

Mail-Merge-like extension to Scribus, to generate Scribus and pdf documents automatically from external data (spreadsheet, database and more).

Scribus Generator. Generate beautiful documents from data. Scribus Generator: Create beautiful documents with data.

Open source high-quality pdf template and mail-merge alternative. Your imagination is the limit for creating beautiful yearbooks, personalised weedings invitations, game cards decks, clubs rosters, art or work portfolio and many more.

What is Scribus Generator?

Scribus comes with a broad set of page layout features and functionality. One feature missing is to replace text with data dynamically. This kind of feature you may already know as the typical mail merge functionality in your preferred office application.

Scribus Generator provides this functionality. It allows you to:

  • replace texts and images dynamically
  • change object colors, position, text font or size dynamically
  • generate separate PDF (or Scribus) files for each data entry, or a single file from all your data
  • work directly in Scribus with a nice user interface, or from the command line
  • use any data source (Excel, OpenOffice, MySQL, Notepad, ...) that can export to CSV.
  • and much more...

Generally speaking, Scribus Generator replaces text with data to automatically generate files (e.g. SLA, PDF). It has been originally written by Ekkehard Will and further extended by Berteh.

A short how to video introduces this Scribus Generator. 6 first minutes for the basic overview, 12 last for some more advanced features.

Scribus Generator how to - high quality pdf generation

How to install Scribus Generator ?

For recent Scribus (1.5.6+, 1.6.x,..): download the latest ScribusGenerator version. A few added features, including GUI for MacOS users.

For legacy Scribus 1.4.x to 1.5.5: Download the older ScribusGenerator archived script. It is not supported any longer, but just works with older (python2-based) systems.

Uncompress the script anywhere on the local machine in a folder your user can write to. Scribus Generator can then be started by choosing the script (ScribusGenerator.py) within the dialog: «Scribus → Script → Execute Script», or from the command line.

How to use Scribus Generator

Create your Scribus "template" file

Create and design your Scribus file as any other. At the positions where you need to replace text with data, just add %VAR_name% where name is the column your data file. Check out our gallery of examples to see what others did. Any existing Scribus file can be used as template.

You can place the variable at any position within a Text Frame. Apply all format and style to the variable that you wish to apply to the final text.

Illustration: Scribus File for Generator

If you wish to generate one page (or many) for each data entry you're done, congratulations ! If you would rather display many data entries on a single page simply add the text %SG_NEXT-RECORD% before each entry but the first: ScribusGenerator will automatically load the new data record as soon as it detects this token.

Create your (csv) Data File

Scribus Generator expects a CSV file (Comma Separated Values), which is very simple to create with a standard spread sheet editor (such as LibreOffice, Excel or GoogleDoc): enter the data and save/export as CSV. Just make sure your CSV file is encoded in UTF-8 to have a full character set (accents, braille, math, cyrillic, symbols,...).

Illustration: Data File for Generator

It is important to make sure the columns have the same name as the variables (%VAR_name%) you reference in the Scribus template file you have designed.

We recommend saving in UTF-8 encoding to enable the full set of accentuated characters, chinese, cyrillic, math symbols, arrows, braille, symbols and many more. Simply copy-paste those for which you lack a keyboard combination.

To export well-formated CSV in UTF-8 encoding is easy as pie with OpenOffice or LibreOffice Calc, less so with Excel. If you are using Microsoft's Excel you may be interested in this free add-in that provides good export/import features: http://www.csvio.net/

CSV files can easily be generated from many existing data sources (incl. enterprise-grade ETL platforms, most databases like MySQL, PostgreSQL, SQLite3 and more, ), see our wiki page for using other data sources

Run the Generator Script - Settings (Linux and Windows)

Run the script via the menu: Script > execute Script and launch ScribusGenerator.py.

In the script dialog you can configure the input and output settings for Scribus Generator.

Illustration: Input and Output Settings

Input Setting explanation
Scribus File Choose the Scribus File containing the variables to replace. Click ⏏ to open a file explorer, and ↺ to load the Scribus Generator settings from that file.
Data File Choose the Data File containing the comma separated values. Click ⏏ to open a file explorer.
Data Field Separator Character that delimitates data field in your CSV file, comma (,) by default.
From - To To run Scribus Generator on a subset of your data mention the starting and/or last lines of this subset, not counting the header line. Simply leave empty to generate from the beginning (or to the last) data entry.
Output Setting explanation
Output Directory Choose the path to an existing directory where to save the result. Click ⏏ to open a file explorer.
Output File Name You can use the same variables as defined in the Scribus File/Data File. You can also use variables and the dedicated %VAR_COUNT% index reflecting the row position in the Data File. It is used by default if you leave the field empty.
Save Settings Store the current Scribus Generator settings in the source SLA file, for future use.
Merge in Single File Select to generate a single output (SLA and/or PDF) file that combines all data rows.
Output Format Choose the Output Format of the generated files, either PDF or Scribus.
Keep Scribus Files Select to keep the generated Scribus Files. Otherwise they will be deleted after pdf generation. This option has no effect if you choose Scribus output format.

Additional (more technical) options can be set to tailor the automatic recording of Scribus Generators actions in your system by editing the logging.conf file. You may, for instance, want to move the location of the log file (scribusGenerator.log by default) to a directory that does not need admin rights to edit in Windows (C:\tmp\scribusGenerator.log), or replace file-logging with your default system logger (SysLogHandler in Linux, NTEventLogHandler on Windows). All settings (and more) are described in the Python logging documentation.

Run the Generator Script - Settings (MacOS)

Run the appropriate script via the menu: Script > execute Script and launch ScribusGeneratorMac.py.

The Mac version of the script uses the Scribus Plugin API which has support for a very limited GUI, so you will instead have to enter and confirm your settings in a series of dialog boxes:

Illustration: Splash Dialog

This dialog just lets you know that Scribus Generator is now running, and tells you that you will be presented with a series of dialogs collecting the needed input infos. Kindly follow the very detailed ScribusGeneratorMac guide for a step-by-step walktrough. Many thanks to kmcreative for this nice addition to ScribusGenerator.

Mac users can also use the command line version of Scribus Generator, from a terminal window.

Dynamic Images

Images references can also be dynamically modified with Scribus Generator. See the screencast video @6:10.

All images supported by Scribus can be used. However, to work with ScribusGenerator, they must all be located in a single folder containing all images. This folder can be located anywhere on your PC. Duplicate any image in this folder and rename it %VAR_pic% (and similarly for any other variable name you need to use for pictures, %VAR_pic2%, %VAR_photo%).

Add an Image Frame anywhere in the Scribus file («Scribus → Insert → Insert Image Frame») and open the dialog for getting an image (e.g. right click Image Frame → Get Image... on selected frame). Select the needed "placeholder" picture.

Illustration: Insert variable instead of image

The images file can be defined just like any other variable described in earlier. There just has to be a column with a column-name corresponding to the variable-name in the Scribus template file. Just make sure to handle the file extension either in the file name, or in the CSV data, but not in both.

Illustration: Data file referencing images

Importing vector images (SVG, PDF or other) as image frames does work in ScribusGenerator, just as with PNG or JPG images; just make sure your (relative or absolute) SVG file path matches the generator output directory, as that is the place Scribus will be looking from when transforming the SLA into your PDF format.

Scribus sometimes renders the included image in really low resolution, so you should check out the resolution (dpi) (and or size) or your source material. To quickly batch export SVG objects in multiple resolutions you may be interested in Inkscape's object export script.

There is unfortunately no way to include dynamically vector files (pdf or svg) with ScribusGenerator, because of the way Scribus imports them (from the menu File > Import > Vector) by converting them one-the-fly to scribus objects. Which is great for direct editing in Scribus, but not for including external files by reference.

Dynamic Colors

Colors can be dynamically replaced just like text. See the screencast video @8:31, or simply

  1. edit the colors of your Scribus file (edit > colours) and rename the colors you want to replace with variable names (typically replace FromSVG#whatever with the now well known form %VAR_name%).
  2. define the colors you want to use in the final document, and use their Scribus names as values in your color data field.

Illustration: Replace colors dynamically

Use this together with the many renown color palettes directly included in Scribus to make your documents design rich and appealing !

Dynamic Links

A clickable (web)link can be inserted on nearly any scribus object in 2 steps:

  1. right-click > PDF Options, activate Is PDF Annotation
  2. right-click > PDF Options > Annotation Properties, select type External Web-Link and enter the target url, where you can obviously use variables to be substituted too, as illustrated below.

Illustration: Include dynamic clickable (web)links

Merged output - single document

Instead of generating a single (sla or pdf) file for each data row, you can generate a single file that merges all these. Simply select the option accordingly to get the result illustrated below in a single Scribus (and/or pdf) file. If your document layout has multiple pages (double sided, or folded leaflet), it is important for Scribus Generator to be able to merge the files that your template has the same number of pages (or a multiple thereof). For instance, for a 3-fold document, your source sla should have 3, 6, or 9 pages (or any multiple of 3).

Illustration: Single output to merge all generated files

Multiple records on a single page

Scribus Generator allows you to display mupliple data entries in a single document. Great to generate your own listings, team charts, game cards, who's who posters and more.

Simply drop the text %SG_NEXT-RECORD% in your document before each data entry except the first record, following our example document. Kindly note this token is case sensitive and must be upper-case. Scribus Generator will automatically load the next record as soon as it detects %SG_NEXT-RECORD%, and when it reaches the end of your template.

A full example to generate Monsters Game Cards based on Dungeon World is available in the MonsterCards directory, created by Dustin Andrews:

Illustration: Example card deck of monsters, by Dustin Andrew

Advanced layout, groups and layers

The Scribus Generator script prioritizes items based on their Level in Scribus. For advanced layouts (groups, layers,...) we thus recommend to put your main item on the first level, together with the %SG_NEXT-RECORD% token before you group them together, for it to behave properly (assuming you call next record at the beginning of your 2nd item and next ones).

Changes in NEXT-RECORD syntax

Please note Scribus Generator v2.8 (from January 2019) changed the syntax of the "Next Record" feature to a less confusing name, as per suggestion #118

Update your older templates manually, changing %VAR_NEXT-RECORD% to %SG_NEXT-RECORD%, or all at once by calling, for instance:

python ./ConvertVAR_NEXT-RECORDToSG28.py ~/ScribusProjects/*/*.sla

Dynamic output file location

Scribus Generator allows you to customize the name (and location) of the generated document easily. Add the output file name you wish in your data, and use the corresponding variable (or combination of multiple variables) in the field "Output File Name". Kindly note this file name is always relative to the output directory, and has no extension.

A dedicated variable %VAR_COUNT% can be used anywhere in the file output option that will be substituted with the position of the related data entry in the data file. Force that count figure to have a specific length by setting the OUTPUTCOUNT_FILL accordingly (only in Scribus 1.5.6+ version)

Have a look at the combination of values of parent and outfile in our example dataset and related example template.

Illustration: Name your generated documents as like

More advanced uses

Scribus Generator allows more tech-savvy users you to customize the generated documents even more, changing virtually any attribute of any object, such as the fill or outline color of a line, the color of some text, a line thickness, an object position,... See the screencast video @13:13.

For instance, to change dynamically the font of an object, add an attribute to it («righ-click on object → Attributes → Add »). The Parameter attribute must be set to SGAttribute, it's name to the object property you want to change (in this case FONT) and its value to the desired dynamic value (typically some %VAR_name%). Your data (CSV) file should then contain the font name to use in the column of the given variable, such as "Arial Regular" or "Courier New Bold".

Illustration: Use Attributes to modify advanced object properties

To change the properties of a sub-element (such as one particular text line in a text frame), you may use the RelationshipTo field to define which sub-elements should receive the new property. Use * to modify all direct children, or any other simplified XPATH expression to modify only a subset.

Selected examples of SGAttributes:

Name Value Parameter RelationshipTo Explanation
FONT %VAR_font% SGAttribute //ITEXT[2] Font of the 2d text line in a frame, like "Arial Regular"
FONTSIZE %VAR_size% SGAttribute //ITEXT Text size of all text lines in a frame, like "14"
LINESP %VAR_spacing% SGAttribute //para[last()] Fixed line spacing of the last paragraph in a frame, like "9.5"
YPOS %VAR_top% SGAttribute Margin from the top for vertical element position, like "22.04"
ROT %VAR_degrees% SGAttribute rotation of the current object, in degrees, [0 , 359]

Please note ScribusGenerator does not create the attribute, but only looks to update its value. So you may need to slightly rotate the object (just put any value but 0 in the rotation box, it will be replaced anyway), to make sure the ROT attribute is indeed used by Scribus when saving the file.

Changes in SGAttribute syntax

Since ScribusGenerator v2.7 (released in April 2018), the syntax of the SGAttributes has been slightly changed to support Scribus 1.5.3. If you had templates written for an older version of the script kindly update your templates according to the documentation above.

This can be done using the classical Scribus Editors windows, simply moving your values of Parameter to RelationshipTo, and setting Parameter to SGAttribute.

If you have many such files, or attributes, a script is proposed to make this update automatically. Run it from the command line as follows, it creates automatically a backup of your old files:

python ./ConvertSGAttributesToSG27.py *.sla

Running Scribus Generator from the command line

It is possible to run Scribus Generator from the command line, and it's fast! Great to automate your workflow or integrate with other tools.

Please note only the SLA generation works from the command line. PDF generation is at the moment not supported from the Scribus Generator command line.

Find all needed information from the script help: ./ScribusGeneratorCLI.py --help

positional arguments:
  infiles               SLA file(s) to use as template(s) for the generation,
                        wildcards are supported

optional arguments:
  -h, --help            show this help message and exit
  -c DATAFILE, --dataFile DATAFILE
                        CSV/JSON file containing the data to substitute in each
                        template during generation. Default is scribus source
                        file(s) name with "csv" extension instead of "sla". If
                        csv file is not found, generation from this particular
                        template is skipped.
  -d CSVDELIMITER, --csvDelimiter CSVDELIMITER
                        CSV field delimiter character. Default is comma: ","
  -n OUTNAME, --outName OUTNAME
                        name of the generated files, with no extension.
                        Default is a simple incremental index. Using SG variables
                        is allowed to define the name of generated documents.
                        Use %VAR_COUNT% as a unique counter defined automatically
                        from the data entry position.
  -o OUTDIR, --outDir OUTDIR
                        directory were generated files are stored. Default is
                        the directory of the scribus source file. outputDir
                        will be created if it does not exist.
  -m, --merge, --single
                        generate a single output (SLA) file that combines all
                        data rows, for each source file.
  -from FIRSTROW, --firstrow FIRSTROW
                        Starting row of data to merge (not counting the header
                        row), first row by default.
  -to LASTROW, --lastrow LASTROW
                        Last row of data to merge (not counting the header
                        row), last row by default.
  -s, --save            Save current generator settings in (each) Scribus
                        input file(s).
  -l, --load            Load generator settings from (each) Scribus input
                        file(s). Overloads all default values, not provided
                        command line arguments.

requirements
    This program requires Python 3.0+

examples:

  ScribusGeneratorCLI.py my-template.sla
    generates Scribus (SLA) files for each line of 'my-template.csv'
    by substituting the provides values into 'my-template.sla' to the 
    current directory.

  ScribusGeneratorCLI.py --outDir "/home/user/tmp" example/Business_Card.sla
    generates Scribus files for each line of example/Business_Card.csv
    in the "/home/user/tmp" subdirectory.

  ScribusGeneratorCLI.py --outName "card-%VAR_COUNT%-%VAR_email%"  */*.sla
    generates Scribus files for each sla file in any subdirectory
    that has a csv file with a similar name in the same directory.
    Generated files will have a name constructed from the entry position
    and "email" field, and are stored in their respective sla file directory.

  ScribusGeneratorCLI.py --single -c translations.csv -n doc_  lang/*.sla
    generates a single Scribus file for each sla file in the lang/ subdirectory
    using all rows of the translations.csv data file.
    Generated files will have a name constructed from the "doc_" prefix
    and the input sla file name.

 more information: https://github.com/berteh/ScribusGenerator/

More details

Clean output

Scribus Generator will remove unused variables from the generated documents, along with their containing text frame if that text frame contained nothing but variable(s).

Illustration: Variables not substituted are removed

If you want to keep these unused variables and empty texts, simply change the default setting accordingly in ScribusGeneratorBackend.py, setting CLEAN_UNUSED_EMPTY_VARS to 0.

Similarly, if these unused variables or empty texts were preceded by a simple text (such as a single linefeed, or a character like any of ,;-), these list-like separators will be removed, so you can have a clean enumaration by appending your variables in a simple manner such as %VAR_n1%, %VAR_n2%, %VAR_n3%, %VAR_n4%., or in a more tabular layout using (single) linefeeds:

The following will show nicely even if some variable is empty or missing:
%VAR_n1%
%VAR_n2%
%VAR_n3%
%VAR_n4%

If you want to keep these separators, simply change the default setting accordingly in ScribusGeneratorBackend.py, setting REMOVE_CLEANED_ELEMENT_PREFIX to 0.

Linebreaks and tabulations in your csv data are replaced by the scribus equivalent (newlines and tabulations). To remove them and turning them to simple spaces set the setting KEEP_TAB_LINEBREAK to 0.

Logging and debug

ScribusGenerator records all its actions in a log file located (by default) in your user (home) directory. If you encounter an unexpected behaviour check out the content of .scribusGenerator.log to find out more. You can change the logging settings in logging.conf (see Python log configuration for more options).

Kindly copy-paste the relevant (usually last) lines of your .scribusGenerator.log if you want to report an issue.

Variable Names

Try to use plain word characters (A-Za-a0-9_) for variable names, with no whitespaces or other special characters (like '&'). E.g. use %VAR_first_name% and %VAR_zip_code% instead of %VAR_first name% and %VAR_&zip#code%. The columns of the data file (CSV) then would be first_name and zip_code.

This is only important for variable names in the scribus file and column names of the data file. The data FIELDS (the rows of the CVS) of course may contain ANY characters.

Database source

To use data from a database instead a (manual) spreadsheet you can simply export the related query result to a CSV file. Some examples below for common database engines. Find out more about using external data sources in our wiki .

Mysql:

mysql --delimiter="," -u myuser -p mydb -e "select f1,f2 from mytable" > /tmp/mydata.txt

or

mysql  -u myuser -p  mydatabase -e
"select field1 , field2 FROM mytable INTO OUTFILE
'/tmp/myfilename.csv' FIELDS TERMINATED BY ','
ENCLOSED BY '\"' LINES TERMINATED BY '\n' "

More over INTO OUTFILE at http://dev.mysql.com/doc/refman/5.1/en/select.html

Postgresql

toggle unaligned output with the \a switch, activate a comma as a separator with \f ,. Send output to a file with \o myfile.csv, then query your database.

Sqlite3

You can use sqlite3 -csv in command line or .mode csv in sqlite's interactive shell

Scripts

Various scripts are available in the utils folder to facilitate your use of Scribus Generator. Check out the related README !

Known Issues

Mac OSX/macOS troubleshooting

Some installs of Python on Mac OSX and macOS do not ship a working Tkinter package, that is required for regular ScribusGenerator GUI. Your options are to:

If you would like to improve the API dialog version or contribute another GUI to Scribus Generator that works on Macs don't hesitate! Simply fork, branch, code and pull a request to get your contribution reviewed !

Support

Check out the wiki for more ideas, look at the solved and open issues, and then kindly report an issue online, and copy there the few last lines of your log file (it's .scribusGenerator.log, inside your user (home) directory, to help find the reason of this bad behaviour, along with a short explanation of your problem.

Licence

The MIT License
Copyright
(c) 2011, Ekkehard Will (www.ekkehardwill.de)
(c) 2014-2024, Berteh (https://github.com/berteh/)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealing in the software.

scribusgenerator's People

Contributors

4n70w4 avatar berteh avatar bjarnesvanberg avatar dustinandrews avatar hynekcer avatar kmhcreative avatar luzpaz avatar mikini avatar s1syphos avatar sunstrom avatar ta-ichihashi avatar ultrasalem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scribusgenerator's Issues

support linked frames in merged mode

reported by @garydale

I am flowing text through several text frames. When I create individual Scribus files, it works. However when I create a single output file, the subsequent page contain a group of frames with no text flow - I only see the first text frame's text.

In merged output mode, generated text frames become unlinked.

Scribus Generator in non-interactive mode

I would like to automate the creation of photobook from scribus template. Though scribus generator does the job, I don't want to manually open scribus generator each time I want to generate pdfs. It there any way to run scribus generator to run non interactively so that I can automate programatically??

"saving PDF" popup-message is blocking computer during run of script

Dear script-whisperers,
in 2015 I had pulled a copy and made my own humble fork for special needs. Today I have come back here and I am amazed how this script has developed, respect! (I keep getting e-mails every so often, so I know this tool is very active and alive. I tried the latest version today - and it also shows my "trouble", so here is my contribution/request):

(I am a total newbie at Python, so I cannot submit my own hacks. If you are interested, the latest change I hacked, was to offer the user a box to enter an offset. So if I run several batches of the script, the numbers will not always start at 1, 2, 3 again but maybe go 201, 202, 203 and so no previous output gets overwritten. I just fear that my cody is bad and ugly and illegal and unpythonic.)

Today I come with a request for help please: As our database is growing, our exports are taking longer. (I also have to cut my runs into batches, because, depending on Scribus-file, my Scribus crashes after some 80+ runs of the (old) script. That was one reason why I invented the offset. But the crashes are solved, not the issue here.)

I notice this: every few seconds, as the script is creating yet another PDF-file, Scribus brings up a popup-window saying "saving PDF" and giving several progress bars. Those are fun, when I manually create a PDF. But when I run the script, they come all the way up and somehow grab the focus. This means that I cannot use my computer at all, while the script is running. I tried minimizing Scribus and fiddling with several screens, but the stuff is just too deep for me.

If there is a workaround, please advise. And in general, I humbly propose as a new feature to remove (maybe optional for users to chose) those endless popup-progress-windows if at all possible. Or maybe make them less agressive, if they cannot be turned off?

support range for data

add options to specify a range of data entries to use for generation, eg from 97 to 104, to ease template development testing.
empty (in GUI) or missing (in CLI) would mean 1 and last, respectively.

Errors with CLI on Windows

I have tried to run the ScribusGeneratorCLI.py from a normal windows command prompt which resulted in this error:

C:\Users\Bjarne\Programming\ScribusGenerator>python ScribusGeneratorCLI.py
  File "ScribusGeneratorCLI.py", line 86
    print ''.join(msg)
            ^
SyntaxError: invalid syntax

After fixing this and a few other bugs I committed the changes to branch clifix (5b42327)

I am not sure if I see these errors because I am on windows or because of the Python version (3.4.3) I am using or something like that. Anyway I have left the changes in the clifix branch. It would be nice if someone else could test this on windows before merging into the master branch.

Error Launching Script

Hi,
on Windows 10 with scribus-1.4.5-windows-x64 (tried also with 1.5.0) and ScribusGenerator-master trying to launch the script, I get the following:

Traceback (most recent call last): File "", line 8, in File "E:\users\myusername\Documenti\scribus\ScribusGenerator-master\ScribusGenerator.py", line 341, in main_wrapper(sys.argv) File "E:\users\myusername\Documenti\scribus\ScribusGenerator-master\ScribusGenerator.py", line 329, in main_wrapper main(argv) File "E:\users\myusername\Documenti\scribus\ScribusGenerator-master\ScribusGenerator.py", line 318, in main dlg = GeneratorDialog(root, ctrl) File "E:\users\myusername\Documenti\scribus\ScribusGenerator-master\ScribusGenerator.py", line 197, in **init** self.**ico=PhotoImage(file=self.__pluginDir+'/pic/ScribusGenerator_logo.png') File "C:\Program Files\Scribus 1.4.5\lib\lib-tk\Tkinter.py", line 3323, in __init** Image.**init**(self, 'photo', name, cnf, master, **kw) File "C:\Program Files\Scribus 1.4.5\lib\lib-tk\Tkinter.py", line 3279, in **init** self.tk.call(('image', 'create', imgtype, name,) + options) TclError: couldn't recognize data in image file "E:\users\myusername\Documenti\scribus\ScribusGenerator-master/pic/ScribusGenerator_logo.png"

My total ignorance does not allow me to understand a bit of the above.
Thanks in advance,
Frankie

Scribus Generator error with new version

The same .csv & .sla files that used to work with the previous version (just downloaded the new version today) is now generating an error "Could likely not replace a variable with its value, please check your Data File and Data Separator settings. moreover: invalid literal for int() with base10: '595.28'"

Now when I used to work, I mean that loosely. It would generate 78 output files when I expected 79. Moreover the first variable / field name didn't substitute on any of the files I looked at. I don't believe this is a fault of the .csv file because I loaded and re-saved it from LibreOffice Calc but got the same error. Also the file looks OK when I open it in a text editor.

I thought perhaps the script didn't properly recognize s as a line terminator. I tried opening the file in Wordpad and resaving it, which replaced the s with s (verified by opening in Notepad) but still got the same error.

Any ideas?

Image path assumed to be relative to Output directory

Hi, love your program.

I had some trouble replacing images. Inspecting the generated Scribus files for missing images, it appeared the document was expecting them on a path relative to the Output directory.

Cheers

Klaas

add test suite

Add a test suite to prevent regression on development of new features, as suggested by @superdweebie in #37.

Should test for support in Scribus 1.4.3 and 1.5, from both GUI and CLI clients.

@bjarnesvanberg wanna give it a try? (even just a few partial test)

support for XML data input & repeating fields

request by @garydale:

.csv doesn't allow me to include all the data I'd like. My original XML file has repeated fields and I can't find a .csv converter that will keep them. The .csv file I've included, for example, handle them as separate .csv files, which would mean I'm doing a lot of cut and pasting. Others take just the first instance of a repeated field, which is just as bad.

Don't suppose you could make it work with XML as well?

not ever CSV-file is separated by commas...

Hello, in our data-files we typically cannot use commas nor semi-colons for delimiters, because they feature as part of our data.

So I am using a private delimiter. (If you are curious, I am using '#' but that does not matter).

So I have manually enhanced the code like this, to allow me to set my personal delimiter:

def getCsvData(self, csvfile):
    # Read CSV file and return  2-dimensional list containing the data
    reader = csv.reader(file(csvfile), delimiter='#') # set your personal delimiter in this line
    result = []
    for row in reader:
        rowlist = []
        for col in row:
            rowlist.append(col)
        result.append(rowlist)
    return result

I hope to write a version, where the GUI will ask the user, what delimiter he wants to use (while proposing the good ole comma)

Please integrate the choice of delimiter into the script, if you like the idea (because it took me a long time to read the script and find the command csv.reader and to look up the syntax re delimiter...

greetings and good job,

Martin Zaske

Feature Request: Single Document Creation with GUi/wizard

Hi!
A great feature to improve your Generator Script and Scribus as a whole would be to offer a GUI to insert data for a single document (corresponding to a single line in the CSV). The effort to create a CSV for a single document is quite annoying and the usecase should be common.

This feature would be a benefit for several reasons:

  1. Variables can be used in a way (even much more powerful) like text variables are used in Adobe InDesign (in opposition to "mail-merge" functionality this is useful for the creation of single documents based on a template with some variable content like magazines/periodic newsletters with variable release date, issue number, etc.)
  2. It allows to create single items from a mail-merge batch. E.g. creating business cards for the whole staff of 100 employees and later recreate single cards for individuals (e.g. new employees).
  3. Allows to easily create a "preview" of a single item before batch-creation of a mail-merge job.

My personal need is case no. 1 - I'm used to work with InDesign. In my workflow I open the template to create the new document, edit the variables for issue number and release month and start filling the content. To achieve the same in Scribus I would need to edit the CSV for a single line containing the data of the current issue, then create the document from the template with script generator.
For the data of a single line in the CSV, a wizard like GUI would be great as it avoids the need for the external data source.

Kind regards and thanks for your great work!
Peter

Work with Scribus

I wrote a simple code Scribus, I want working with ScribusGenerator but this does not happen.

I always get the error n. 9, Bad Descriptor ......

I followed the examples, tried countless times, no, it does not work, help me find where I'm wrong. Thank you.

I attach some files.

csv
result
scribus
scribusgenerator

remember user settings in GUI

store user settings for the current project (sla, csv, format, -range-) to be used in the GUI next time it's called.
maybe in a scribus "session" or global variable?
or maybe as annotation in the project xml file?

generated styles sometimes incoherent

reported by @garydale in #56 :
One problem: The first text element on each page (clubname) always exists but the second (website) doesn't. If the second element is blank, the first element picks up the paragraph style for the second. In this case the first element is in a separate text frame from the subsequent elements. The subsequent elements flow into a second frame with different margins. I don't know if that is relevant or not.

logging.conf issue in Gentoo

reported by Alan at http://forums.scribus.net/index.php/topic,1965.0.html

I'm trying to use Scribus Generator to add addresses to a newsletter and have been working my way through error messages (Tk not compiled into Python, etc.) but now it's just hanging when I tell it to generate.

The script is in my user directory and permissions seem OK, user has read/write to directory and files.

Scribus 1.5.2.svn
Python 2.7.10 (3.4.3 is also installed and is the system default)
Gentoo Linux

It seems like it may not be parsing logging.conf but I don't do Python, so I'll leave it to the experts. By running Scribus via console and running the script, I get this error message:

Exception in Tkinter callback
Traceback (most recent call last):                                                                       
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1536, in __call__                                 
    return self.func(*args)                                                                             
  File "/home/alan/Downloads/ScribusGenerator-master/ScribusGenerator.py", line 147, in buttonOkHandler 
    generator = ScribusGenerator(dataObject)                                                             
  File "/home/alan/Downloads/ScribusGenerator-master/ScribusGeneratorBackend.py", line 56, in __init__   
    logging.config.fileConfig("logging.conf")                                                           
  File "/usr/lib64/python2.7/logging/config.py", line 77, in fileConfig                                 
    formatters = _create_formatters(cp)                                                                 
  File "/usr/lib64/python2.7/logging/config.py", line 113, in _create_formatters                         
    flist = cp.get("formatters", "keys")                                                                 
  File "/usr/lib64/python2.7/ConfigParser.py", line 607, in get                                         
    raise NoSectionError(section)                                                                       
NoSectionError: No section: 'formatters'

support for \n \t and \v

Merging database field with pre-formatted text i.e. text with \n, \t, \v etc.etc. does not seem to work.
Gives ParseError : not well-formed (invalid token)

It's not possible to use "Dynamic Colors" and "More advanced uses" while using Scribus 1.5.1

Hi Berteh,

Firstly, what a fantastic tool did you create! Many thanks for that!

I Use to work with Scribus 1.4.6 but recently I started using Scribus 1.5.1. Main reason: The possibility to verticaly align text within a textbox.

But now i'm facing a problem with your ScribusGenerator. It's not possible to use "Dynamic Colors" and "More advanced uses" anymore. I'll give you a short description of what happens. I tried your business card example with both Scribus 1.4.6 en Scribus 1.5.1.

"Dynamic Colors"

%VAR_color1% is pink in the template. After generating 1.sla the color Blue1 became pink. So, it seems to be that %VAR_color1% is replaced by Blue1 and became pink in stead of using the color blue.

"More advanced uses"

Using SGAttribute there's nothing happening at all. No error, and also no change in Font.

Are you familiar with the problem? Am I doing something wrong? Is there a sollution for these problems?

I hope to hear from you.

Once again, thanks again for this good job!

Greatings
Erwinius

missing one file in the generated files

@garydale let's find out about the missing 79th file ;)

do you let ScribusGenerator generate the output files names automatically, or do you provide a field name to get the filenames from (eg the club name or code). In case it's the second, please check you don't have the same name twice, as ScribusGenerator will overwrite the file with no warning... and you will thus loose one.

by the way: I did not get any attachment, you can either send them by mail (berteh - at - gmail doth com) or upload them anywere you like and add links in the gallery wiki of scribusgenerator.

trouble with quote symbol in csv file

Generator has been working great for me but I can't figure out how to put a quote symbol (") into the csv file. When the symbol is present generator stops with a parse error. The generator log stops at "merging content" for the row with the symbol. I've tried using python escape sequences like " and """ but I get the same error. If I remove the symbol the generator works on this csv. Am I missing something?

I opened up the csv in gedit and confirmed UTF-8 encoding.

I tried this on 2 systems, windows 10 and ubuntu 12.04. Same error.

scribusGenerator.log.txt

French characters - issue

Dear,

I'm using Scribus portable (1.4.5) in combination with your scribus generator scripts on Windows 10 machine. Contrary to the desktop version 1.4.6 that I use, the scribus generator works fine with scribus portable.
However it struggles with French characters (è, ë, etc) and things like " ... ".
the log returns:

2016-09-03 11:18:41 - root - DEBUG - init:57 - ScribusGenerator initialized
2016-09-03 11:18:41 - root - DEBUG - run:69 - parsing data source file location/frans test.csv
2016-09-03 11:18:41 - root - DEBUG - run:108 - parsing scribus source file location/template framework cards.sla
2016-09-03 11:18:41 - root - DEBUG - replaceVariablesWithCsvData:378 - cleaned 1 empty variable
2016-09-03 11:18:41 - root - DEBUG - run:133 - generating reference content from row #1

If I remove all trema, accent, 3 dots ,... it works fine.

thanks for your help
Stef

SyntaxError on Mac OS X 10.9.5

On going to Scribus > Scrips > Execute script... and opening scribusgenerator.py I get the following error:

Traceback (most recent call last):
  File "<string>", line 8, in <module>
  File "/Users/guillem/.scribus/scripts/ScribusGenerator-master/ScribusGenerator.py", line 153
     except IOError as e:   #except FileNotFoundError as e:
                     ^
 SyntaxError: invalid syntax

python --version says Python 2.7.11

better output numbering with leading zeros

The automatic numbering of output-files is messy and listing in a file-explorer can be fixed with leading zeros.

I have manually added zfill(3) but if a user want to mail merge 150.000 documents or whatever we need an idea to automatically add the appropriate number of digits (number of leading zeros). Please help and please put the zfill idea into the code, if you like it. Good job for having put Scribus Generator on github.

Greetings, Martin Zaske

def createOutputFileName(self, index, outputFileName, headerRow, row):
    # If the User has not set an Output File Name, an internal unique file name
    # will be generated which is the index of the loop.
    result = str(index)
    result = result.zfill(3)

give feedback on generation end

tell the user if the generation was successful (or not) in the GUI and CLI.
maybe close script GUI on successful generation.

Upper limit of rows in csv?

Hi!

I have just begun to fiddle around with the Scribus Generator and so far it works fantastic!

But I have a problem.The csv file that I use is with over 500 rows and when i try to use it in the script I get an error like the one on the attached image. I tested around i little and found that when the data used is a maximum of 35 rows everything works. Any number above that couses the same error.

Is this i limitation of the script, or is there anything a can do to solve this?
I am on win 10 with scribus 1.4.6 and is using the GUI.
felmeddelande

Mac OSX

Having trouble getting the script to work with OSX. Anybody else with similar issues? I've updated Tcl, not sure if I should up/downgrade my install of Python.

remove empty variables, empty lines & eol

request from @garydale

is it possible to have the script remove variables (and eol characters?) that match empty .csv fields? It's not a big issue but with the .csv file having to contain all possible fields, I have to do a lot of deleting to clean up the output file. Deleting variable names requires me to select the name then hit delete, while deleting an empty line just requires a delete. Having the script remove empty lines would be even better.

Add [[File > Import > Vector File]] to ScribusGenerator

Hi B.

Question: is it possible to add [File > Import > Vector File] to ScribusGenerator?

The issue with scribus is that if you use an Image frame for an vector file (like svg), the quality sucks (clearly). So, to get the best quality I like to import the right vector file at the right place.

Greetings
Erwinius

error with Output file Name

Something went wrong.

Read the log file for more (in your home directory).Traceback(most recent call last):
File”/home/rana/Desktop/new ubuntu/ScribusGenerator.py”, line 151, in buttonokHandler
generator.run()
File”/home/rana/Desktop/new ubuntu/ScribusGeneratorBackend.py”, line 165, in run outputFileName= self.createOutPutFileName(index,self._dataObject.getOutputFileName(), varNamesForFileName,row,fillCount)
File”/home/rana/Desktop/new ubuntu/ScribusGeneratorBackend.py”, line 353. in createOutputFileName
result =
self.replaceVariableWithCsvData(carNames, [row], [outputFileName])
file”/home/rana/Desktop/new ubuntu/ScribusGeneratorBackend.py”, line 398, in
replaceVariableWithCsvData line = line.replace(tmp, cell)
Type Error: expected a string or other character buffer object

Support for more complex data patterns/sources

Bonjour @berteh :

We were very happy to find this tool, since we want to use templates to print out work orders for cars in particular formats, and wanted to give our admins the ability to edit templates in a WSYIWIG manner.

I'd love to discuss this more with you, including a possible paid contract. Please drop me a line at [email protected].

Thanks,
Animesh

Logger config error leads to silent crash

Hi there, I have followed the instructions carefully, but I just can't get the script to work. Scribus 1.4.5. Very simple template file - just one text element, very simple csv file - just one column, three rows. I get the script GUI and press 'generate' and nothing happens. I'm sorry I can't give a more specific error, but it is just a silent fail.

Objects are incorrectly displaced vertically

First of all: Thanks for your very useful script!

Recently, I ran into some trouble, however. Starting from testcase.sla.txt, I used your script in "single file" mode (any csv with several lines will do - there are no variables to replace in the testcase). In the resulting testcase__single.sla.txt, the blue box is increasingly displaced vertically on each consecutive page.

I think I tracked this down. The testcase was created with a paper size of A4, which I later changed to A5 for the first (and only) page. The generator seems to use the document settings (ScribusGeneratorBackend.py@135) for calculating offsets (which are still for A4), not the settings of the actual page (which are A5). Interestingly, Scribus does not seem to follow the PAGEYPOS value when laying out the pages (there is no huge gap between them).

The background behind this is that I created a master-file with the same template adapted to different page sizes. I then took that, deleted all but one page, and saved that as template for ScribusGenerator. This is how I ended up with mismatching document/page settings.

I'm using Scribus 1.4.6 on Ubuntu.

(rare) error: NoneType object is not callable

Every once in a while when I run the script I get an error in Windows, like: "NoneType object is not callable", but closing and restarting Scribus solves it.

Don't know where this error comes from, googling leads to potential missing librairies not backported to some Python version... as it's not blocking me I won't investigate anytime soon. If this is a problem to you kindly let me know with as much details as possible (OS + python + tk version)

Berteh.

Scribus 1.5.1 - Generator does not work

There are two versions of Scribus on my hard drive: One is Scribus 1.4.6 and one is 1.5.1

I noticed that the original tool by Ekkehard Will works fine with 1.5.1, but I'd prefer your version in order to delete empty lines while creating customer adresses. Here's the issue-report from 1.5.1. Since my skills with programing languages are pretty much limited, I have no idea what the report is trying to say.

Note: C:\Program Files\Scribus 1.5.1\share\scripts\ScribusGenerator-master\ScribusGenerator.py is the generator's directory for the later version

C:\Program Files(x86)\Scribus 1.4.6\share\scripts\ScribusGenerator-master\ScribusGenerator.py is he one for the 1.4.6, where it seems to work - but like with the original Ekkehard-Will-Generator, Scribus crashes after fulfilling the operation.

I am using Windows 8.1. Any quick ways to fix the issue quickly?

Cheers
Ryk

Error-report below:

Traceback (most recent call last):
File "", line 10, in
File "C:\Program Files\Scribus 1.5.1\share\scripts\ScribusGenerator-master\ScribusGenerator.py", line 342, in
main_wrapper(sys.argv)
File "C:\Program Files\Scribus 1.5.1\share\scripts\ScribusGenerator-master\ScribusGenerator.py", line 330, in main_wrapper
main(argv)
File "C:\Program Files\Scribus 1.5.1\share\scripts\ScribusGenerator-master\ScribusGenerator.py", line 321, in main
root.mainloop()
File "C:\Program Files\Scribus 1.5.1\python\lib\lib-tk\Tkinter.py", line 1125, in mainloop
self.tk.mainloop(n)
File "C:\Program Files\Scribus 1.5.1\python\lib\lib-tk\Tkinter.py", line 1540, in call
self.widget._report_exception()
File "C:\Program Files\Scribus 1.5.1\python\lib\lib-tk\Tkinter.py", line 1293, in _report_exception
root.report_callback_exception(exc, val, tb)
File "C:\Program Files\Scribus 1.5.1\python\lib\lib-tk\Tkinter.py", line 1895, in report_callback_exception
traceback.print_exception(exc, val, tb)
File "C:\Program Files\Scribus 1.5.1\python\lib\traceback.py", line 125, in print_exception
print_tb(tb, limit, file)
File "C:\Program Files\Scribus 1.5.1\python\lib\traceback.py", line 67, in print_tb
' File "%s", line %d, in %s' % (filename, lineno, name))
File "C:\Program Files\Scribus 1.5.1\python\lib\traceback.py", line 13, in _print
file.write(str+terminator)
IOError: [Errno 9] Bad file descriptor

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.