Discussion:
[scribus] Using scribus to create PDFs from the commandline
Marc Balmer
2014-07-20 17:26:28 UTC
Permalink
Currently we use LaTeX to produce PDF from the commandline (or rather, from within our applications). We run a scrip that creates a LaTeX sourcefile, fires up latex, and returns the resulting PDF.

I am now trying to find out if that would be possible with Scribus somehow. E.g. we would fire up scribus with the name of a Python script and the name of document. The script would then populate the document with data and output it to PDF.

Is that possible? Can we run a Python script at startup, or, can we run python and start Scribus from within? Or, in other words, are there ways to automate Scribus without user interaction, i.e. from the commandline?
Kunda Loves Scribus
2014-07-20 19:43:17 UTC
Permalink
On Sun, Jul 20, 2014 at 12:26 PM, Marc Balmer <marc at msys.ch> wrote:

> Currently we use LaTeX to produce PDF from the commandline (or rather,
> from within our applications). We run a scrip that creates a LaTeX
> sourcefile, fires up latex, and returns the resulting PDF.
>
> I am now trying to find out if that would be possible with Scribus
> somehow. E.g. we would fire up scribus with the name of a Python script
> and the name of document. The script would then populate the document with
> data and output it to PDF.
>
> Is that possible? Can we run a Python script at startup, or, can we run
> python and start Scribus from within? Or, in other words, are there ways
> to automate Scribus without user interaction, i.e. from the commandline?
>

This would be a powerful feature. Auto-populating forms would be pretty
sweet, not without some work though. And Scribus is short on manpower.

There were some efforts that I've come across in the bug tracker:

http://bugs.scribus.net/view.php?id=238
http://bugs.scribus.net/view.php?id=967

These are 3 digit bugs so that means they've been around for a while :)
I also am no authority, so it would be nice to hear from others who know
better what possibilities there are in this context.

Cheers,
/Kunda
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140720/1882cbcb/attachment.html>
Gregory Pittman
2014-07-20 23:52:30 UTC
Permalink
On 07/20/2014 01:26 PM, Marc Balmer wrote:
> Currently we use LaTeX to produce PDF from the commandline (or rather, from within our applications). We run a scrip that creates a LaTeX sourcefile, fires up latex, and returns the resulting PDF.
>
> I am now trying to find out if that would be possible with Scribus somehow. E.g. we would fire up scribus with the name of a Python script and the name of document. The script would then populate the document with data and output it to PDF.
>
> Is that possible? Can we run a Python script at startup, or, can we run python and start Scribus from within? Or, in other words, are there ways to automate Scribus without user interaction, i.e. from the commandline?
>
>
>
Though perhaps not as automated as you are suggesting, you can certainly
create documents from scratch following some preset pattern.

One example is this one:

http://wiki.scribus.net/canvas/Automatic_import_of_images:_Versions_not_requiring_Tkinter

which is some years old, and others have made their own versions for
their own needs.

There is also this:

http://wiki.scribus.net/canvas/A_Standard_Form_with_Barcodes_and_Custom_Entries

a version of which I use almost every day.
Each of these makes a document from scratch, the first makes as many
pages as needed, the second only a single page.

As far as I know PDF export in Scripter has not been implemented. There
is a long-standing request to have Scribus run from the command line to
perhaps do some of what you are suggesting.

Greg
Marc Balmer
2014-07-21 06:08:51 UTC
Permalink
Am 21.07.2014 um 01:52 schrieb Gregory Pittman <gpittman at iglou.com>:

> On 07/20/2014 01:26 PM, Marc Balmer wrote:
>> Currently we use LaTeX to produce PDF from the commandline (or rather, from within our applications). We run a scrip that creates a LaTeX sourcefile, fires up latex, and returns the resulting PDF.
>>
>> I am now trying to find out if that would be possible with Scribus somehow. E.g. we would fire up scribus with the name of a Python script and the name of document. The script would then populate the document with data and output it to PDF.
>>
>> Is that possible? Can we run a Python script at startup, or, can we run python and start Scribus from within? Or, in other words, are there ways to automate Scribus without user interaction, i.e. from the commandline?
>>
>>
>>
> Though perhaps not as automated as you are suggesting, you can certainly create documents from scratch following some preset pattern.
>
> One example is this one:
>
> http://wiki.scribus.net/canvas/Automatic_import_of_images:_Versions_not_requiring_Tkinter
>
> which is some years old, and others have made their own versions for their own needs.
>
> There is also this:
>
> http://wiki.scribus.net/canvas/A_Standard_Form_with_Barcodes_and_Custom_Entries
>
> a version of which I use almost every day.
> Each of these makes a document from scratch, the first makes as many pages as needed, the second only a single page.
>
> As far as I know PDF export in Scripter has not been implemented. There is a long-standing request to have Scribus run from the command line to perhaps do some of what you are suggesting.


Thanks for the examples.

If I got that correctly, there is currently no way to do what I want, i.e. I have to call the scripts from the menu.

Not, I don't want to create documents from scratch, but merely fill templates with proper data (some sort of database publishing).

mb
a.l.e
2014-07-21 08:18:14 UTC
Permalink
hi marc

if you have a scribus running on your machine, it should not be that
hard to get it to communicate with an external script. you just need the
right python skills (and eventually a little patch to scribus)
(this has been done in the past as an art project: get two instance of
scribus synchronize through IRC...)

what is not yet possible, is to start scribus without a GUI.
there are some efforts going on in that direction, but no solution in
sight for the near future.
(on the other hand, help is welcome!)

ciao
a.l.e

> Am 21.07.2014 um 01:52 schrieb Gregory Pittman <gpittman at iglou.com>:
>
>> On 07/20/2014 01:26 PM, Marc Balmer wrote:
>>> Currently we use LaTeX to produce PDF from the commandline (or rather, from within our applications). We run a scrip that creates a LaTeX sourcefile, fires up latex, and returns the resulting PDF.
>>>
>>> I am now trying to find out if that would be possible with Scribus somehow. E.g. we would fire up scribus with the name of a Python script and the name of document. The script would then populate the document with data and output it to PDF.
>>>
>>> Is that possible? Can we run a Python script at startup, or, can we run python and start Scribus from within? Or, in other words, are there ways to automate Scribus without user interaction, i.e. from the commandline?
>>>
>>>
>>>
>> Though perhaps not as automated as you are suggesting, you can certainly create documents from scratch following some preset pattern.
>>
>> One example is this one:
>>
>> http://wiki.scribus.net/canvas/Automatic_import_of_images:_Versions_not_requiring_Tkinter
>>
>> which is some years old, and others have made their own versions for their own needs.
>>
>> There is also this:
>>
>> http://wiki.scribus.net/canvas/A_Standard_Form_with_Barcodes_and_Custom_Entries
>>
>> a version of which I use almost every day.
>> Each of these makes a document from scratch, the first makes as many pages as needed, the second only a single page.
>>
>> As far as I know PDF export in Scripter has not been implemented. There is a long-standing request to have Scribus run from the command line to perhaps do some of what you are suggesting.
>
> Thanks for the examples.
>
> If I got that correctly, there is currently no way to do what I want, i.e. I have to call the scripts from the menu.
>
> Not, I don't want to create documents from scratch, but merely fill templates with proper data (some sort of database publishing).
>
> mb
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
Boris Samorodov
2014-07-21 17:18:10 UTC
Permalink
21.07.2014 10:08, Marc Balmer ?????:

> I don't want to create documents from scratch, but merely fill
> templates with proper data (some sort of database publishing).

For database forms I use ReportLab. It's a nice python open-source
PDF toolkit.

--
WBR, Boris Samorodov (bsam)
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve
Marc Balmer
2014-07-21 17:38:20 UTC
Permalink
Am 21.07.2014 um 19:18 schrieb Boris Samorodov <bsam at passap.ru>:

> 21.07.2014 10:08, Marc Balmer ?????:
>
>> I don't want to create documents from scratch, but merely fill
>> templates with proper data (some sort of database publishing).
>
> For database forms I use ReportLab. It's a nice python open-source
> PDF toolkit.

Well, my idea was, if the templates were Scribus files, then end users could (more easily) adapt them to their needs than the LaTeX styles and tempates we use now.

>
> --
> WBR, Boris Samorodov (bsam)
> FreeBSD Committer, http://www.FreeBSD.org The Power To Serve

Marc Balmer
NetBSD Committer, http://www.NetBSD.org The Power in Your Toaster

:)
Jean-Paul Gendner
2014-07-22 13:37:54 UTC
Permalink
Sorry for the delay, I was out.

I do not used it since a long time, however, a solution is to write
a small program to do that. For example with Visual Basic 6, you may use the
ShellExecute command to start Scribus, and then use the SendKeys command
which allow you to send characters to Scribus as if you enter it on the
keyboard. Of course all what you may do must be possible with the keyboard,
without any mouse command.

Regards,
Jean-Paul

****************
Jean-Paul Gendner
Site : f5bu.fr
03.88.27.03.44


-----Message d'origine-----
De?: Marc Balmer [mailto:marc at msys.ch]
Envoy??: dimanche 20 juillet 2014 19:26
??: scribus at lists.scribus.net
Objet?: [scribus] Using scribus to create PDFs from the commandline

Currently we use LaTeX to produce PDF from the commandline (or rather, from
within our applications). We run a scrip that creates a LaTeX sourcefile,
fires up latex, and returns the resulting PDF.

I am now trying to find out if that would be possible with Scribus somehow.
E.g. we would fire up scribus with the name of a Python script and the name
of document. The script would then populate the document with data and
output it to PDF.

Is that possible? Can we run a Python script at startup, or, can we run
python and start Scribus from within? Or, in other words, are there ways to
automate Scribus without user interaction, i.e. from the commandline?



___
Scribus Mailing List: scribus at lists.scribus.net
Edit your options or unsubscribe:
http://lists.scribus.net/mailman/listinfo/scribus
See also:
http://wiki.scribus.net
http://forums.scribus.net
Rolf-Werner Eilert
2014-07-22 14:04:26 UTC
Permalink
Hello Marc,

are we talking about Linux or Windows here?

In Linux, I would create the form with Scribus as a PDF, then use Gambas
for loading the PDF and writing on it the data from the database. At
least I would give it a try...

Regards

Rolf


Am 20.07.2014 19:26, schrieb Marc Balmer:
> Currently we use LaTeX to produce PDF from the commandline (or rather, from within our applications). We run a scrip that creates a LaTeX sourcefile, fires up latex, and returns the resulting PDF.
>
> I am now trying to find out if that would be possible with Scribus somehow. E.g. we would fire up scribus with the name of a Python script and the name of document. The script would then populate the document with data and output it to PDF.
>
> Is that possible? Can we run a Python script at startup, or, can we run python and start Scribus from within? Or, in other words, are there ways to automate Scribus without user interaction, i.e. from the commandline?
>
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
Juraj Fedel
2014-07-27 17:32:02 UTC
Permalink
On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc Balmer wrote:
> Or, in other words, are there ways to automate Scribus without user
> interaction, i.e. from the commandline?

Let me try once more to present my solution to this problem! At the
bottom of the mail is small patch that enables exactly what Marc is
asking for.

You can create template scribus document 'mydoc.sla' with two text
frames and this small python script 'data.py' in the same directory:

import scribus
scribus.openDoc('mydoc.sla')
scribus.setText('Name', 'Text1') # get 'Name' and 'Address' from database
scribus.setText('Address', 'Text2')
pdf = scribus.PDFfile()
pdf.file = 'output1.pdf'
pdf.save()

Then run scribus as folow:
scribus --python-script data.py

and you have your output1.pdf file created!

WARNING!
- This is for linux only. And it is for stable version of Scribus-1.4.4
(because that is what I use).
- Use only python script without bugs (he, he :)
- You will anyway find some limitation because scribus really is not in
its core coded for use without GUI

PS:
I have been posting this or similar solution since 2006 (and Scribus
version 1.2 I was using at that time). I would be glad if at least one
person try to compile scribus with this patch and confirm that it works
on some other computer than mine! If you find it useful it would be
extra bonus.

Here is patch for running scribus from CLI against Srcibus-1.4.4 version

Modified scribus/main_nix.cpp
diff --git a/scribus/main_nix.cpp b/scribus/main_nix.cpp
index 03db7e8..039f703 100644
--- a/scribus/main_nix.cpp
+++ b/scribus/main_nix.cpp
@@ -37,6 +37,7 @@ for which a new license (GPL+exception) is in place.
#include "scribus.h"

#include "scconfig.h"
+#include "scraction.h" // JF: need to be able to trigger action for scripter to run without GUI

int mainApp(int argc, char **argv);
void initCrashHandler();
@@ -81,7 +82,16 @@ int mainApp(int argc, char **argv)
int appRetVal=app.init();
if (appRetVal==EXIT_FAILURE)
return(EXIT_FAILURE);
- return app.exec();
+ // JF: This is ugly
+ // it is this way because for now scribus use app.useGUI variable
+ // as synonym for 'run scribus with GUI or not at all'
+ if (!app.pythonScript.isNull())
+ {
+ if (ScCore->primaryMainWindow()->scrActions.contains("scripterRunPythonScript"))
+ ScCore->primaryMainWindow()->scrActions.value("scripterRunPythonScript")->trigger();
+ }
+ else
+ return app.exec();
}
return EXIT_SUCCESS;
}
Modified scribus/plugins/scriptplugin/scriptercore.cpp
diff --git a/scribus/plugins/scriptplugin/scriptercore.cpp b/scribus/plugins/scriptplugin/scriptercore.cpp
index 14979f1..ffc0c6e 100644
--- a/scribus/plugins/scriptplugin/scriptercore.cpp
+++ b/scribus/plugins/scriptplugin/scriptercore.cpp
@@ -32,6 +32,7 @@ for which a new license (GPL+exception) is in place.
#include "prefscontext.h"
#include "prefstable.h"
#include "prefsmanager.h"
+#include "scribusapp.h" // JF: need it to acces ScQApp->pythonScript

ScripterCore::ScripterCore(QWidget* parent)
{
@@ -57,6 +58,10 @@ ScripterCore::ScripterCore(QWidget* parent)
QObject::connect( scrScripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) );
QObject::connect( scrScripterActions["scripterAboutScript"], SIGNAL(triggered()) , this, SLOT(aboutScript()) );

+ // JF: Create an action that will run python file without GUI
+ ScCore->primaryMainWindow()->scrActions.insert("scripterRunPythonScript", new ScrAction(this));
+ QObject::connect( ScCore->primaryMainWindow()->scrActions.value("scripterRunPythonScript"), SIGNAL(triggered()) , this, SLOT(slotRunPythonScript()) );
+
SavedRecentScripts.clear();
ReadPlugPrefs();

@@ -404,6 +409,13 @@ void ScripterCore::slotRunScriptFile(QString fileName, bool inMainInterpreter)
enableMainWindowMenu();
}

+// JF: needed for running script without GUI - this is activated by action from main_nix.cpp
+void ScripterCore::slotRunPythonScript()
+{
+ slotRunScriptFile(ScQApp->pythonScript);
+ FinishScriptRun();
+}
+
void ScripterCore::slotRunScript(const QString Script)
{
// Prevent two scripts to be run concurrently or face crash!
Modified scribus/plugins/scriptplugin/scriptercore.h
diff --git a/scribus/plugins/scriptplugin/scriptercore.h b/scribus/plugins/scriptplugin/scriptercore.h
index 47e96ac..2c84b75 100644
--- a/scribus/plugins/scriptplugin/scriptercore.h
+++ b/scribus/plugins/scriptplugin/scriptercore.h
@@ -39,6 +39,7 @@ public slots:
void StdScript(QString filebasename);
void RecentScript(QString fn);
void slotRunScriptFile(QString fileName, bool inMainInterpreter = false);
+ void slotRunPythonScript(); // JF: needed for running python script without GUI
void slotRunScript(const QString Script);
void slotInteractiveScript(bool);
void slotExecute();
Modified scribus/scribus.cpp
diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
index a999a29..60bd026 100644
--- a/scribus/scribus.cpp
+++ b/scribus/scribus.cpp
@@ -285,7 +285,8 @@ int ScribusMainWindow::initScMW(bool primaryMainWindow)
setAttribute(Qt::WA_KeyCompression, false);
setWindowIcon(loadIcon("AppIcon.png"));
scrActionGroups.clear();
- scrActions.clear();
+ // JF: DO NOT clear actions : scripter plugin has created one allready!
+// scrActions.clear();
scrRecentFileActions.clear();
scrRecentPasteActions.clear();
scrWindowsActions.clear();
Modified scribus/scribusapp.cpp
diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index 82582d1..8686e43 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -61,6 +61,7 @@ for which a new license (GPL+exception) is in place.
#define ARG_SWAPDIABUTTONS "--swap-buttons"
#define ARG_PREFS "--prefs"
#define ARG_UPGRADECHECK "--upgradecheck"
+#define ARG_PYTHONSCRIPT "--python-script"

#define ARG_VERSION_SHORT "-v"
#define ARG_HELP_SHORT "-h"
@@ -75,6 +76,7 @@ for which a new license (GPL+exception) is in place.
#define ARG_SWAPDIABUTTONS_SHORT "-sb"
#define ARG_PREFS_SHORT "-pr"
#define ARG_UPGRADECHECK_SHORT "-u"
+#define ARG_PYTHONSCRIPT_SHORT "-py"

// Qt wants -display not --display or -d
#define ARG_DISPLAY_QT "-display"
@@ -218,6 +220,21 @@ void ScribusQApp::parseCommandLine()
} else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
{
// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
+ } else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) {
+ pythonScript = QFile::decodeName(argv()[i + 1]);
+ if (!QFileInfo(pythonScript).exists()) {
+ showHeader();
+ if (pythonScript.left(1) == "-" || pythonScript.left(2) == "--") {
+ std::cout << tr("Invalid argument: ").toLocal8Bit().data() << pythonScript.toLocal8Bit().data() << std::endl;
+ } else {
+ std::cout << tr("File %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl;
+ }
+ showUsage();
+ useGUI=false;
+ return;
+ } else {
+ ++i;
+ }
} else {
fileName = QFile::decodeName(argv()[i]);
if (!QFileInfo(fileName).exists()) {
@@ -428,7 +445,7 @@ void ScribusQApp::showUsage()
printArgLine(ts, ARG_SWAPDIABUTTONS_SHORT, ARG_SWAPDIABUTTONS, tr("Use right to left dialog button ordering (eg. Cancel/No/Yes instead of Yes/No/Cancel)") );
printArgLine(ts, ARG_UPGRADECHECK_SHORT, ARG_UPGRADECHECK, tr("Download a file from the Scribus website and show the latest available version.") );
printArgLine(ts, ARG_VERSION_SHORT, ARG_VERSION, tr("Output version information and exit") );
-
+ printArgLine(ts, ARG_PYTHONSCRIPT_SHORT, QString(QString(ARG_PYTHONSCRIPT) + QString(" ") + tr("filename")).toLocal8Bit().constData(), tr("Run filename in Python scripter") );

#if defined(_WIN32) && !defined(_CONSOLE)
printArgLine(ts, ARG_CONSOLE_SHORT, ARG_CONSOLE, tr("Display a console window") );
Modified scribus/scribusapp.h
diff --git a/scribus/scribusapp.h b/scribus/scribusapp.h
index 9048328..cf9b555 100644
--- a/scribus/scribusapp.h
+++ b/scribus/scribusapp.h
@@ -67,6 +67,7 @@ class SCRIBUS_API ScribusQApp : public QApplication
bool neverSplashExists();
const QString& currGUILanguage() {return GUILang;};
ScDLManager* dlManager() { return m_scDLMgr; }
+ QString pythonScript; // JF: script to be run in pythoun without GUI

public slots:
Marc Balmer
2014-07-29 07:00:38 UTC
Permalink
Am 27.07.2014 um 19:32 schrieb Juraj Fedel <wtxnh-scribus at yahoo.com.au>:

> On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc Balmer wrote:
>> Or, in other words, are there ways to automate Scribus without user
>> interaction, i.e. from the commandline?
>
> Let me try once more to present my solution to this problem! At the
> bottom of the mail is small patch that enables exactly what Marc is
> asking for.

That is very nice. Is there a chance that this will make its way into the Scribus source tree?

>
> You can create template scribus document 'mydoc.sla' with two text
> frames and this small python script 'data.py' in the same directory:
>
> import scribus
> scribus.openDoc('mydoc.sla')
> scribus.setText('Name', 'Text1') # get 'Name' and 'Address' from database
> scribus.setText('Address', 'Text2')
> pdf = scribus.PDFfile()
> pdf.file = 'output1.pdf'
> pdf.save()
>
> Then run scribus as folow:
> scribus --python-script data.py
>
> and you have your output1.pdf file created!
>
> WARNING!
> - This is for linux only. And it is for stable version of Scribus-1.4.4
> (because that is what I use).
> - Use only python script without bugs (he, he :)
> - You will anyway find some limitation because scribus really is not in
> its core coded for use without GUI
>
> PS:
> I have been posting this or similar solution since 2006 (and Scribus
> version 1.2 I was using at that time). I would be glad if at least one
> person try to compile scribus with this patch and confirm that it works
> on some other computer than mine! If you find it useful it would be
> extra bonus.
>
> Here is patch for running scribus from CLI against Srcibus-1.4.4 version
>
> Modified scribus/main_nix.cpp
> diff --git a/scribus/main_nix.cpp b/scribus/main_nix.cpp
> index 03db7e8..039f703 100644
> --- a/scribus/main_nix.cpp
> +++ b/scribus/main_nix.cpp
> @@ -37,6 +37,7 @@ for which a new license (GPL+exception) is in place.
> #include "scribus.h"
>
> #include "scconfig.h"
> +#include "scraction.h" // JF: need to be able to trigger action for scripter to run without GUI
>
> int mainApp(int argc, char **argv);
> void initCrashHandler();
> @@ -81,7 +82,16 @@ int mainApp(int argc, char **argv)
> int appRetVal=app.init();
> if (appRetVal==EXIT_FAILURE)
> return(EXIT_FAILURE);
> - return app.exec();
> + // JF: This is ugly
> + // it is this way because for now scribus use app.useGUI variable
> + // as synonym for 'run scribus with GUI or not at all'
> + if (!app.pythonScript.isNull())
> + {
> + if (ScCore->primaryMainWindow()->scrActions.contains("scripterRunPythonScript"))
> + ScCore->primaryMainWindow()->scrActions.value("scripterRunPythonScript")->trigger();
> + }
> + else
> + return app.exec();
> }
> return EXIT_SUCCESS;
> }
> Modified scribus/plugins/scriptplugin/scriptercore.cpp
> diff --git a/scribus/plugins/scriptplugin/scriptercore.cpp b/scribus/plugins/scriptplugin/scriptercore.cpp
> index 14979f1..ffc0c6e 100644
> --- a/scribus/plugins/scriptplugin/scriptercore.cpp
> +++ b/scribus/plugins/scriptplugin/scriptercore.cpp
> @@ -32,6 +32,7 @@ for which a new license (GPL+exception) is in place.
> #include "prefscontext.h"
> #include "prefstable.h"
> #include "prefsmanager.h"
> +#include "scribusapp.h" // JF: need it to acces ScQApp->pythonScript
>
> ScripterCore::ScripterCore(QWidget* parent)
> {
> @@ -57,6 +58,10 @@ ScripterCore::ScripterCore(QWidget* parent)
> QObject::connect( scrScripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) );
> QObject::connect( scrScripterActions["scripterAboutScript"], SIGNAL(triggered()) , this, SLOT(aboutScript()) );
>
> + // JF: Create an action that will run python file without GUI
> + ScCore->primaryMainWindow()->scrActions.insert("scripterRunPythonScript", new ScrAction(this));
> + QObject::connect( ScCore->primaryMainWindow()->scrActions.value("scripterRunPythonScript"), SIGNAL(triggered()) , this, SLOT(slotRunPythonScript()) );
> +
> SavedRecentScripts.clear();
> ReadPlugPrefs();
>
> @@ -404,6 +409,13 @@ void ScripterCore::slotRunScriptFile(QString fileName, bool inMainInterpreter)
> enableMainWindowMenu();
> }
>
> +// JF: needed for running script without GUI - this is activated by action from main_nix.cpp
> +void ScripterCore::slotRunPythonScript()
> +{
> + slotRunScriptFile(ScQApp->pythonScript);
> + FinishScriptRun();
> +}
> +
> void ScripterCore::slotRunScript(const QString Script)
> {
> // Prevent two scripts to be run concurrently or face crash!
> Modified scribus/plugins/scriptplugin/scriptercore.h
> diff --git a/scribus/plugins/scriptplugin/scriptercore.h b/scribus/plugins/scriptplugin/scriptercore.h
> index 47e96ac..2c84b75 100644
> --- a/scribus/plugins/scriptplugin/scriptercore.h
> +++ b/scribus/plugins/scriptplugin/scriptercore.h
> @@ -39,6 +39,7 @@ public slots:
> void StdScript(QString filebasename);
> void RecentScript(QString fn);
> void slotRunScriptFile(QString fileName, bool inMainInterpreter = false);
> + void slotRunPythonScript(); // JF: needed for running python script without GUI
> void slotRunScript(const QString Script);
> void slotInteractiveScript(bool);
> void slotExecute();
> Modified scribus/scribus.cpp
> diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
> index a999a29..60bd026 100644
> --- a/scribus/scribus.cpp
> +++ b/scribus/scribus.cpp
> @@ -285,7 +285,8 @@ int ScribusMainWindow::initScMW(bool primaryMainWindow)
> setAttribute(Qt::WA_KeyCompression, false);
> setWindowIcon(loadIcon("AppIcon.png"));
> scrActionGroups.clear();
> - scrActions.clear();
> + // JF: DO NOT clear actions : scripter plugin has created one allready!
> +// scrActions.clear();
> scrRecentFileActions.clear();
> scrRecentPasteActions.clear();
> scrWindowsActions.clear();
> Modified scribus/scribusapp.cpp
> diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
> index 82582d1..8686e43 100644
> --- a/scribus/scribusapp.cpp
> +++ b/scribus/scribusapp.cpp
> @@ -61,6 +61,7 @@ for which a new license (GPL+exception) is in place.
> #define ARG_SWAPDIABUTTONS "--swap-buttons"
> #define ARG_PREFS "--prefs"
> #define ARG_UPGRADECHECK "--upgradecheck"
> +#define ARG_PYTHONSCRIPT "--python-script"
>
> #define ARG_VERSION_SHORT "-v"
> #define ARG_HELP_SHORT "-h"
> @@ -75,6 +76,7 @@ for which a new license (GPL+exception) is in place.
> #define ARG_SWAPDIABUTTONS_SHORT "-sb"
> #define ARG_PREFS_SHORT "-pr"
> #define ARG_UPGRADECHECK_SHORT "-u"
> +#define ARG_PYTHONSCRIPT_SHORT "-py"
>
> // Qt wants -display not --display or -d
> #define ARG_DISPLAY_QT "-display"
> @@ -218,6 +220,21 @@ void ScribusQApp::parseCommandLine()
> } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
> {
> // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
> + } else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) {
> + pythonScript = QFile::decodeName(argv()[i + 1]);
> + if (!QFileInfo(pythonScript).exists()) {
> + showHeader();
> + if (pythonScript.left(1) == "-" || pythonScript.left(2) == "--") {
> + std::cout << tr("Invalid argument: ").toLocal8Bit().data() << pythonScript.toLocal8Bit().data() << std::endl;
> + } else {
> + std::cout << tr("File %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl;
> + }
> + showUsage();
> + useGUI=false;
> + return;
> + } else {
> + ++i;
> + }
> } else {
> fileName = QFile::decodeName(argv()[i]);
> if (!QFileInfo(fileName).exists()) {
> @@ -428,7 +445,7 @@ void ScribusQApp::showUsage()
> printArgLine(ts, ARG_SWAPDIABUTTONS_SHORT, ARG_SWAPDIABUTTONS, tr("Use right to left dialog button ordering (eg. Cancel/No/Yes instead of Yes/No/Cancel)") );
> printArgLine(ts, ARG_UPGRADECHECK_SHORT, ARG_UPGRADECHECK, tr("Download a file from the Scribus website and show the latest available version.") );
> printArgLine(ts, ARG_VERSION_SHORT, ARG_VERSION, tr("Output version information and exit") );
> -
> + printArgLine(ts, ARG_PYTHONSCRIPT_SHORT, QString(QString(ARG_PYTHONSCRIPT) + QString(" ") + tr("filename")).toLocal8Bit().constData(), tr("Run filename in Python scripter") );
>
> #if defined(_WIN32) && !defined(_CONSOLE)
> printArgLine(ts, ARG_CONSOLE_SHORT, ARG_CONSOLE, tr("Display a console window") );
> Modified scribus/scribusapp.h
> diff --git a/scribus/scribusapp.h b/scribus/scribusapp.h
> index 9048328..cf9b555 100644
> --- a/scribus/scribusapp.h
> +++ b/scribus/scribusapp.h
> @@ -67,6 +67,7 @@ class SCRIBUS_API ScribusQApp : public QApplication
> bool neverSplashExists();
> const QString& currGUILanguage() {return GUILang;};
> ScDLManager* dlManager() { return m_scDLMgr; }
> + QString pythonScript; // JF: script to be run in pythoun without GUI
>
> public slots:
>
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net


Freundliche Gr?sse,
micro systems

Marc Balmer

--
micro systems, Landstrasse 66, CH-5073 Gipf-Oberfrick
fon +41 62 871 45 65, http://www.msys.ch/
a.l.e
2014-07-30 11:02:38 UTC
Permalink
hi juraj

thanks for sharing this!

it's possible that i've already tried your patch but failed to compile it...

i've tried a few of them, and none did compile at the time i've tried them.


i've browsed through your patch and i have a few comments:

- first a very simple one: don't mark your comments with a two letters
code... while this is fine for AV, CB or other team mebers, in a few
months nobody will know who JF is :-). (except if you plan to be a
regular contributor: then you're welcome in the club!)
as a general rule, i would suggest to sign with your first name if
it's unique for scribus and is listed in the about dialog.
otherwise, you should provide your firstname and name (and eventually
email address...) or a handle wich can be tracked to you (as an example,
kunda could use that nichkname even if it is not his real name!)

- staying with the "ugly hack": what should be changed in scribus to
avoid it? how much effort is it, to make a patch to get scribus to
currectly test if it should run (and not test for the GUI as a proxy for
it...).

- why is it linux only? the parts that are OS dependent should be marked
as such (allowing other people to work on it and further provide patches
for other OSes?)

- what are the known limitations? i guess that it won't run from a real
terminal (X11 needed)... and then?

- and of course such a patch should be against 1.5svn ... but iirc this
issue has been already (easily) solved by william!

once the limitations are clearly documented and the "ugly hack" has been
-- if possible -- unuglified i think that we should look for integrating
this in the trunk!

thanks for sharing your patch!
a.l.e

> On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc Balmer wrote:
>> Or, in other words, are there ways to automate Scribus without user
>> interaction, i.e. from the commandline?
> Let me try once more to present my solution to this problem! At the
> bottom of the mail is small patch that enables exactly what Marc is
> asking for.
>
> You can create template scribus document 'mydoc.sla' with two text
> frames and this small python script 'data.py' in the same directory:
>
> import scribus
> scribus.openDoc('mydoc.sla')
> scribus.setText('Name', 'Text1') # get 'Name' and 'Address' from database
> scribus.setText('Address', 'Text2')
> pdf = scribus.PDFfile()
> pdf.file = 'output1.pdf'
> pdf.save()
>
> Then run scribus as folow:
> scribus --python-script data.py
>
> and you have your output1.pdf file created!
>
> WARNING!
> - This is for linux only. And it is for stable version of Scribus-1.4.4
> (because that is what I use).
> - Use only python script without bugs (he, he :)
> - You will anyway find some limitation because scribus really is not in
> its core coded for use without GUI
>
> PS:
> I have been posting this or similar solution since 2006 (and Scribus
> version 1.2 I was using at that time). I would be glad if at least one
> person try to compile scribus with this patch and confirm that it works
> on some other computer than mine! If you find it useful it would be
> extra bonus.
>
> Here is patch for running scribus from CLI against Srcibus-1.4.4 version
>
> Modified scribus/main_nix.cpp
> diff --git a/scribus/main_nix.cpp b/scribus/main_nix.cpp
> index 03db7e8..039f703 100644
> --- a/scribus/main_nix.cpp
> +++ b/scribus/main_nix.cpp
> @@ -37,6 +37,7 @@ for which a new license (GPL+exception) is in place.
> #include "scribus.h"
>
> #include "scconfig.h"
> +#include "scraction.h" // JF: need to be able to trigger action for scripter to run without GUI
>
> int mainApp(int argc, char **argv);
> void initCrashHandler();
> @@ -81,7 +82,16 @@ int mainApp(int argc, char **argv)
> int appRetVal=app.init();
> if (appRetVal==EXIT_FAILURE)
> return(EXIT_FAILURE);
> - return app.exec();
> + // JF: This is ugly
> + // it is this way because for now scribus use app.useGUI variable
> + // as synonym for 'run scribus with GUI or not at all'
> + if (!app.pythonScript.isNull())
> + {
> + if (ScCore->primaryMainWindow()->scrActions.contains("scripterRunPythonScript"))
> + ScCore->primaryMainWindow()->scrActions.value("scripterRunPythonScript")->trigger();
> + }
> + else
> + return app.exec();
> }
> return EXIT_SUCCESS;
> }
> Modified scribus/plugins/scriptplugin/scriptercore.cpp
> diff --git a/scribus/plugins/scriptplugin/scriptercore.cpp b/scribus/plugins/scriptplugin/scriptercore.cpp
> index 14979f1..ffc0c6e 100644
> --- a/scribus/plugins/scriptplugin/scriptercore.cpp
> +++ b/scribus/plugins/scriptplugin/scriptercore.cpp
> @@ -32,6 +32,7 @@ for which a new license (GPL+exception) is in place.
> #include "prefscontext.h"
> #include "prefstable.h"
> #include "prefsmanager.h"
> +#include "scribusapp.h" // JF: need it to acces ScQApp->pythonScript
>
> ScripterCore::ScripterCore(QWidget* parent)
> {
> @@ -57,6 +58,10 @@ ScripterCore::ScripterCore(QWidget* parent)
> QObject::connect( scrScripterActions["scripterShowConsole"], SIGNAL(toggled(bool)) , this, SLOT(slotInteractiveScript(bool)) );
> QObject::connect( scrScripterActions["scripterAboutScript"], SIGNAL(triggered()) , this, SLOT(aboutScript()) );
>
> + // JF: Create an action that will run python file without GUI
> + ScCore->primaryMainWindow()->scrActions.insert("scripterRunPythonScript", new ScrAction(this));
> + QObject::connect( ScCore->primaryMainWindow()->scrActions.value("scripterRunPythonScript"), SIGNAL(triggered()) , this, SLOT(slotRunPythonScript()) );
> +
> SavedRecentScripts.clear();
> ReadPlugPrefs();
>
> @@ -404,6 +409,13 @@ void ScripterCore::slotRunScriptFile(QString fileName, bool inMainInterpreter)
> enableMainWindowMenu();
> }
>
> +// JF: needed for running script without GUI - this is activated by action from main_nix.cpp
> +void ScripterCore::slotRunPythonScript()
> +{
> + slotRunScriptFile(ScQApp->pythonScript);
> + FinishScriptRun();
> +}
> +
> void ScripterCore::slotRunScript(const QString Script)
> {
> // Prevent two scripts to be run concurrently or face crash!
> Modified scribus/plugins/scriptplugin/scriptercore.h
> diff --git a/scribus/plugins/scriptplugin/scriptercore.h b/scribus/plugins/scriptplugin/scriptercore.h
> index 47e96ac..2c84b75 100644
> --- a/scribus/plugins/scriptplugin/scriptercore.h
> +++ b/scribus/plugins/scriptplugin/scriptercore.h
> @@ -39,6 +39,7 @@ public slots:
> void StdScript(QString filebasename);
> void RecentScript(QString fn);
> void slotRunScriptFile(QString fileName, bool inMainInterpreter = false);
> + void slotRunPythonScript(); // JF: needed for running python script without GUI
> void slotRunScript(const QString Script);
> void slotInteractiveScript(bool);
> void slotExecute();
> Modified scribus/scribus.cpp
> diff --git a/scribus/scribus.cpp b/scribus/scribus.cpp
> index a999a29..60bd026 100644
> --- a/scribus/scribus.cpp
> +++ b/scribus/scribus.cpp
> @@ -285,7 +285,8 @@ int ScribusMainWindow::initScMW(bool primaryMainWindow)
> setAttribute(Qt::WA_KeyCompression, false);
> setWindowIcon(loadIcon("AppIcon.png"));
> scrActionGroups.clear();
> - scrActions.clear();
> + // JF: DO NOT clear actions : scripter plugin has created one allready!
> +// scrActions.clear();
> scrRecentFileActions.clear();
> scrRecentPasteActions.clear();
> scrWindowsActions.clear();
> Modified scribus/scribusapp.cpp
> diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
> index 82582d1..8686e43 100644
> --- a/scribus/scribusapp.cpp
> +++ b/scribus/scribusapp.cpp
> @@ -61,6 +61,7 @@ for which a new license (GPL+exception) is in place.
> #define ARG_SWAPDIABUTTONS "--swap-buttons"
> #define ARG_PREFS "--prefs"
> #define ARG_UPGRADECHECK "--upgradecheck"
> +#define ARG_PYTHONSCRIPT "--python-script"
>
> #define ARG_VERSION_SHORT "-v"
> #define ARG_HELP_SHORT "-h"
> @@ -75,6 +76,7 @@ for which a new license (GPL+exception) is in place.
> #define ARG_SWAPDIABUTTONS_SHORT "-sb"
> #define ARG_PREFS_SHORT "-pr"
> #define ARG_UPGRADECHECK_SHORT "-u"
> +#define ARG_PYTHONSCRIPT_SHORT "-py"
>
> // Qt wants -display not --display or -d
> #define ARG_DISPLAY_QT "-display"
> @@ -218,6 +220,21 @@ void ScribusQApp::parseCommandLine()
> } else if (strncmp(arg.toLocal8Bit().data(),"-psn_",4) == 0)
> {
> // Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
> + } else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) {
> + pythonScript = QFile::decodeName(argv()[i + 1]);
> + if (!QFileInfo(pythonScript).exists()) {
> + showHeader();
> + if (pythonScript.left(1) == "-" || pythonScript.left(2) == "--") {
> + std::cout << tr("Invalid argument: ").toLocal8Bit().data() << pythonScript.toLocal8Bit().data() << std::endl;
> + } else {
> + std::cout << tr("File %1 does not exist, aborting.").arg(pythonScript).toLocal8Bit().data() << std::endl;
> + }
> + showUsage();
> + useGUI=false;
> + return;
> + } else {
> + ++i;
> + }
> } else {
> fileName = QFile::decodeName(argv()[i]);
> if (!QFileInfo(fileName).exists()) {
> @@ -428,7 +445,7 @@ void ScribusQApp::showUsage()
> printArgLine(ts, ARG_SWAPDIABUTTONS_SHORT, ARG_SWAPDIABUTTONS, tr("Use right to left dialog button ordering (eg. Cancel/No/Yes instead of Yes/No/Cancel)") );
> printArgLine(ts, ARG_UPGRADECHECK_SHORT, ARG_UPGRADECHECK, tr("Download a file from the Scribus website and show the latest available version.") );
> printArgLine(ts, ARG_VERSION_SHORT, ARG_VERSION, tr("Output version information and exit") );
> -
> + printArgLine(ts, ARG_PYTHONSCRIPT_SHORT, QString(QString(ARG_PYTHONSCRIPT) + QString(" ") + tr("filename")).toLocal8Bit().constData(), tr("Run filename in Python scripter") );
>
> #if defined(_WIN32) && !defined(_CONSOLE)
> printArgLine(ts, ARG_CONSOLE_SHORT, ARG_CONSOLE, tr("Display a console window") );
> Modified scribus/scribusapp.h
> diff --git a/scribus/scribusapp.h b/scribus/scribusapp.h
> index 9048328..cf9b555 100644
> --- a/scribus/scribusapp.h
> +++ b/scribus/scribusapp.h
> @@ -67,6 +67,7 @@ class SCRIBUS_API ScribusQApp : public QApplication
> bool neverSplashExists();
> const QString& currGUILanguage() {return GUILang;};
> ScDLManager* dlManager() { return m_scDLMgr; }
> + QString pythonScript; // JF: script to be run in pythoun without GUI
>
> public slots:
>
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
William Bader
2014-07-30 16:28:39 UTC
Permalink
> Date: Wed, 30 Jul 2014 13:02:38 +0200
> From: ale.comp_06 at xox.ch
> To: scribus at lists.scribus.net
> Subject: Re: [scribus] Using scribus to create PDFs from the commandline
>
> hi juraj
>
> thanks for sharing this!
>
> it's possible that i've already tried your patch but failed to compile it...
>
> i've tried a few of them, and none did compile at the time i've tried them.
>
>
> i've browsed through your patch and i have a few comments:
>
> - first a very simple one: don't mark your comments with a two letters
> code... while this is fine for AV, CB or other team mebers, in a few
> months nobody will know who JF is :-). (except if you plan to be a
> regular contributor: then you're welcome in the club!)
> as a general rule, i would suggest to sign with your first name if
> it's unique for scribus and is listed in the about dialog.
> otherwise, you should provide your firstname and name (and eventually
> email address...) or a handle wich can be tracked to you (as an example,
> kunda could use that nichkname even if it is not his real name!)
>
> - staying with the "ugly hack": what should be changed in scribus to
> avoid it? how much effort is it, to make a patch to get scribus to
> currectly test if it should run (and not test for the GUI as a proxy for
> it...).
>
> - why is it linux only? the parts that are OS dependent should be marked
> as such (allowing other people to work on it and further provide patches
> for other OSes?)
>
> - what are the known limitations? i guess that it won't run from a real
> terminal (X11 needed)... and then?
>
> - and of course such a patch should be against 1.5svn ... but iirc this
> issue has been already (easily) solved by william!
>
> once the limitations are clearly documented and the "ugly hack" has been
> -- if possible -- unuglified i think that we should look for integrating
> this in the trunk!
>
> thanks for sharing your patch!
> a.l.e
I have posted a version of Juraj's patch that works against 1.5.0svn.
I only had to apply one part by hand, and I changed "pythonScript = QFile::decodeName(argv()[i + 1]);" to "pythonScript = QFile::decodeName(args[i + 1].toLocal8Bit());".
http://bugs.scribus.net/view.php?id=12572
My build environment is only Linux (Fedora 20), but the patch does not seem to contain anything operating system dependent, and I suspect that Juraj was being cautious when he said Linux-only because it was never tested under Windows rather than because there is any reason that it should not work.
At least on Linux, it still opens a window. The window does not need any user interaction and closes when the script finishes, so that is OK for my purposes. I imagine that on any x11 environment, you could create a virtual desktop with vncserver and connect Scribus to the virtual desktop instead of to a physical screen.
I think that the "ugly" comment relates to the Scribus useGUI variable. When running a python script, even though there is no GUI, the useGUI variable must be true, because if it is false, Scribus does not do anything.
The useGUI variable might be better as an enumeration of four values: no GUI because there were errors on the command line that prevent Scribus from starting, no GUI because the user specified the --no-gui command line option, non-interactive GUI because the user is running a script with --python-script, and normal interactive GUI. Or maybe as several boolean variables like fatal error, running a python script, gui needed.
If Juraj does not have time to make the changes, and if you can be clear about what it would take to make the patches acceptable, I would be willing to try.
Regards,William



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140730/36da9de2/attachment.html>
Juraj Fedel
2014-07-31 12:54:48 UTC
Permalink
On Wed, Jul 30, 2014 at 12:28:39PM -0400, William Bader wrote:
> I have posted a version of Juraj's patch that works against 1.5.0svn.
> I only had to apply one part by hand, and I changed "pythonScript = QFile::decodeName(argv()[i + 1]);" to "pythonScript = QFile::decodeName(args[i + 1].toLocal8Bit());".
> http://bugs.scribus.net/view.php?id=12572
> My build environment is only Linux (Fedora 20), but the patch does not seem to contain anything operating system dependent, and I suspect that Juraj was being cautious when he said Linux-only because it was never tested under Windows rather than because there is any reason that it should not work.
> At least on Linux, it still opens a window. The window does not need any user interaction and closes when the script finishes, so that is OK for my purposes. I imagine that on any x11 environment, you could create a virtual desktop with vncserver and connect Scribus to the virtual desktop instead of to a physical screen.
> I think that the "ugly" comment relates to the Scribus useGUI variable. When running a python script, even though there is no GUI, the useGUI variable must be true, because if it is false, Scribus does not do anything.
> The useGUI variable might be better as an enumeration of four values: no GUI because there were errors on the command line that prevent Scribus from starting, no GUI because the user specified the --no-gui command line option, non-interactive GUI because the user is running a script with --python-script, and normal interactive GUI. Or maybe as several boolean variables like fatal error, running a python script, gui needed.
> If Juraj does not have time to make the changes, and if you can be clear about what it would take to make the patches acceptable, I would be willing to try.
> Regards,William

Thank You William,
it is almost as if You read my mind.

I am very grateful that You fixed the patch for 1.5 source and posted it
at bug tracker. And I would be honored if you make required changes for
patch to be accepted (my 33K dialup connection is main reason I can not
be very responsive).

Bye
Juraj
Juraj Fedel
2014-07-31 11:56:14 UTC
Permalink
On Wed, Jul 30, 2014 at 01:02:38PM +0200, a.l.e wrote:
> i've browsed through your patch and i have a few comments:
>
> - first a very simple one: don't mark your comments with a two
> letters code... while this is fine for AV, CB or other team mebers,
> in a few months nobody will know who JF is :-). (except if you plan
> to be a regular contributor: then you're welcome in the club!)
> as a general rule, i would suggest to sign with your first name if
> it's unique for scribus and is listed in the about dialog.
> otherwise, you should provide your firstname and name (and
> eventually email address...) or a handle wich can be tracked to you
> (as an example, kunda could use that nichkname even if it is not his
> real name!)

Understood. I could go without puting my initials there at all (I guess
it was mainly for my ego boosting anyway :)

> - staying with the "ugly hack": what should be changed in scribus to
> avoid it? how much effort is it, to make a patch to get scribus to
> currectly test if it should run (and not test for the GUI as a proxy
> for it...).

The reason I said it is _ugly_ hack becuse it need to be placed in condition
if (app.useGUI)
{
...
}

(see main_nix.cpp). I don not understand what for useGUI is used at all.
If GUI can not be created (for some error/or whatever) the reason should
be printed to console and scribus should exit at once (without need for
testing app.useGUI in main_*.cpp files). As a matter of the fact 1.4.4
source have undocumented option --no-gui that set useGUI to false. If
you use this option all that scribus is doing is parsing the command
line and then exit. I fail to grasp meaning of this.

The reason I said it is hack is the way that scripter plugin export it
ability to run python script from CLI. It require addning a CLI option
that is related to plugin '--python-script' (no other plugin require
this AFAIK). This should be guarded by some #ifdef to be compiled only
if scripter is compiled (but scripter is compiled always I think - does
anybody use scribus without python support even when it is optional?).

As for needed changes is scribus to correctly handle app.useGUI I am in
no position to say anything. If I correctly recall you started a project
at the beginning of 2013 to extract PDF producing code out of scribus
and make it usable to convert .sla file to PDF from console. How is that
project going?

> - why is it linux only? the parts that are OS dependent should be
> marked as such (allowing other people to work on it and further
> provide patches for other OSes?)

Because I compile only on linux. Actually it can be made crossplatform
very easy by making same changes to file main_win32.cpp as are done to
main_nix.cpp.

> - what are the known limitations? i guess that it won't run from a
> real terminal (X11 needed)... and then?

Yes, X11 is indeed needed. Other than that:
- gui dialog will appear if our script contains any error (bug)
- it will work only if python script is in working directory
- as an enchancment it would be nice to be able to pass arguments to
script

> - and of course such a patch should be against 1.5svn ... but iirc
> this issue has been already (easily) solved by william!

For now I only use 1.4.4 version.
I have only limited access to computer with broadband internet and can
not use svn client there to download current source. If it is possible
to download 1.5svn source with wget I would be glad to use that. I was
searching for this but failed to find. I would be very greatful if
somebody show me the link how to download current source without svn
client (I can use wget or web browser to download files).

> once the limitations are clearly documented and the "ugly hack" has
> been -- if possible -- unuglified i think that we should look for
> integrating this in the trunk!

This would be great

> thanks for sharing your patch!
> a.l.e
a.l.e
2014-07-31 13:49:27 UTC
Permalink
hi juraj,

i'll get back to you concerning the other points...

first something with an easy answer...

> searching for this but failed to find. I would be very greatful if
> somebody show me the link how to download current source without svn
> client (I can use wget or web browser to download files).

you can use the download button provided by github for our newly created
repository! :-)

https://github.com/scribusproject/scribus/archive/svn.zip

ciao
a.l.e
Juraj Fedel
2014-07-31 20:57:31 UTC
Permalink
On Thu, Jul 31, 2014 at 03:49:27PM +0200, a.l.e wrote:
> you can use the download button provided by github for our newly
> created repository! :-)
>
> https://github.com/scribusproject/scribus/archive/svn.zip

Thanks a.l.e.
I was so excited and run immediately to download the source.
No I had it unziped and started compiling when this error showed:
CMake Error at CMakeLists.txt:6 (CMAKE_MINIMUM_REQUIRED):
CMake 2.8.9 or higher is required. You are running version 2.8.2

As it turns out my toolchain is too old for 1.5svn source. Unfortunately
I will not be able to help in porting patch :( Which is really sad
because I have an idea how to pass an arguments to python script and
how to lift a restriction that python script must be in working
directory.

Bye
Juraj
JLuc
2014-08-01 08:02:22 UTC
Permalink
Le 31/07/2014 22:57, Juraj Fedel a ?crit :
> CMake 2.8.9 or higher is required. You are running version 2.8.2
>
> As it turns out my toolchain is too old for 1.5svn source. Unfortunately
> I will not be able to

Cant you simply upgrade your cmake ?

JL

help in porting patch :( Which is really sad
> because I have an idea how to pass an arguments to python script and
> how to lift a restriction that python script must be in working
> directory.
>
> Bye
> Juraj
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
Juraj Fedel
2014-08-01 16:50:48 UTC
Permalink
On Fri, Aug 01, 2014 at 10:02:22AM +0200, JLuc wrote:
> Cant you simply upgrade your cmake ?

Not really - or to be more precise - I am afraid to :)

Warning: what follows is greatly OFF TOPIC!
To give you a picture why am I afraid let me give you some info: I am
using computer than I bought in 2004 (if I remember correctly) as an
second hand item (it is Pentium II). Immediately I replaced its 6GB HD
with 30GB and later I added additional 128MB RAM to its original 64MB
(adding RAM was noticeable improvement in computer performance -
especially when compiling big programs - nevertheless compiling scribus
source take almost 5 hour - 'time make' report this:
real 298m41.617s
user 259m1.255s
sys 13m50.480s
). And since than I was happily upgrading my Debian OS from Sarge to
Etch to Lenny to Squeeze when I noticed that in Squeeze I could no
longer use any graphics because X server was not running anymore on the
chip I have (MGA G100). So I had to use Lenny. Than I installed Squeeze
on the second partition and with much effort I managed to configure
system to boot into Lenny and use most of the program from Squeeze. This
setup is so quirky that I am afraid that it will collapse on me if I
change it much! I am not willing to experience once more this
configuration nightmare by installing newer distribution instead of
Squeeze. So as it seems I am stuck with this setup until I am able to
acquire more modern computer.

All that said I guess I can try to install newer cmake in /usr/local
(and also to install QT5) and hope for the best. Only thing that bothers
me is very likely possibility that after installing cmake I will find
out that I need to upgrade lot of other libraries that scribus depend
on :(

One possible solution is to install some modern distribution under qemu
virtual machine. Although I would need to physically acquire
installation DVDs to be totally independent from internet connection.
Even if that succeed I am wondering how responsive this setup would be
and I am afraid to estimate the time needed for compiling scribus :)

Bye
Juraj
JLuc
2014-08-02 09:12:11 UTC
Permalink
Le 01/08/2014 18:50, Juraj Fedel a ?crit :
> On Fri, Aug 01, 2014 at 10:02:22AM +0200, JLuc wrote:
>> Cant you simply upgrade your cmake ?
>
> Not really - or to be more precise - I am afraid to :)
>
> Warning: what follows is greatly OFF TOPIC!
> To give you a picture why am I afraid let me give you some info: I am
> using computer than I bought in 2004 (if I remember correctly) as an
> second hand item (it is Pentium II). Immediately I replaced its 6GB HD
> with 30GB and later I added additional 128MB RAM to its original 64MB

Just to understand better, why is it you dont upgrade your computer ?

JLuc
Juraj Fedel
2014-08-03 08:48:35 UTC
Permalink
On Sat, Aug 02, 2014 at 11:12:11AM +0200, JLuc wrote:
> Just to understand better, why is it you dont upgrade your computer ?

Money :(
For same reason I do not have broadband internet connection.

Juraj
john Culleton
2014-08-04 18:01:54 UTC
Permalink
On Sun, 3 Aug 2014 10:48:35 +0200
Juraj Fedel <wtxnh-scribus at yahoo.com.au> wrote:

> On Sat, Aug 02, 2014 at 11:12:11AM +0200, JLuc
> wrote:
> > Just to understand better, why is it you dont
> > upgrade your computer ?
>
> Money :(
> For same reason I do not have broadband
> internet connection.
>
> Juraj
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
>
> _______________________________________________________
> Unlimited Disk, Data Transfer, PHP/MySQL Domain
> Hosting http://www.doteasy.com

It is possible that a version of Slackware will
run on your old computer. Then you can compile
Scribus using the programming tools that come
free with Slackware. You may have to download and
compile some required libraries etc.

--
John Culleton
Wexford Press
Free list of books for self-publishers:
http://wexfordpress.net/shortlist.html
PDF e-book: "Create Book Covers with Scribus"
available at
http://www.booklocker.com/books/4055.html
Craig Bradney
2014-07-31 18:17:20 UTC
Permalink
>> - staying with the "ugly hack": what should be changed in scribus to
>> avoid it? how much effort is it, to make a patch to get scribus to
>> currectly test if it should run (and not test for the GUI as a proxy
>> for it...).
>
> The reason I said it is _ugly_ hack becuse it need to be placed in condition
> if (app.useGUI)
> {
> ...
> }
>
> (see main_nix.cpp). I don not understand what for useGUI is used at all.
> If GUI can not be created (for some error/or whatever) the reason should
> be printed to console and scribus should exit at once (without need for
> testing app.useGUI in main_*.cpp files). As a matter of the fact 1.4.4
> source have undocumented option --no-gui that set useGUI to false. If
> you use this option all that scribus is doing is parsing the command
> line and then exit. I fail to grasp meaning of this.

Because a long long time ago in a galaxy far far away, we started to do some more splitting of code
to have some of Scribus run with or without a GUI. We'd need to eliminate almost all of scribus.cpp
and many other parts of other files into other functions to make it possible to run headless.

> As for needed changes is scribus to correctly handle app.useGUI I am in
> no position to say anything. If I correctly recall you started a project
> at the beginning of 2013 to extract PDF producing code out of scribus
> and make it usable to convert .sla file to PDF from console. How is that
> project going?

scribus.cpp, scribusview.cpp, and probably 100 or more other files would need rewriting to run
scribus in headless mode. To add definition to that, I mean, to have some interface like pipes or
sockets to be able to send commands to a Scribus that has no windows. Eg "new doc, create text frame
at 10,10pt with size 100,100pt" sent as a message to a headless Scribus, then "save doc" and you
have an sla file. Much of the scribusdoc code is written to deal with this already, but there's a
ton of functionality in other major files like scribus.cpp that needs a lot of moving about.

Craig

Craig
William Bader
2014-07-28 23:54:19 UTC
Permalink
On Sun Jul 27 17:32:02 UTC 2014, Juraj Fedel wtxnh-scribus at yahoo.com.au wrote: > On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc Balmer wrote:> > Or, in other words, are there ways to automate Scribus without user> > interaction, i.e. from the commandline?>> Let me try once more to present my solution to this problem! At the> bottom of the mail is small patch that enables exactly what Marc is> asking for.>> You can create template scribus document 'mydoc.sla' with two text> frames and this small python script 'data.py' in the same directory:>> import scribus> scribus.openDoc('mydoc.sla')> scribus.setText('Name', 'Text1') # get 'Name' and 'Address' from database> scribus.setText('Address', 'Text2')> pdf = scribus.PDFfile()> pdf.file = 'output1.pdf'> pdf.save()>> Then run scribus as folow:> scribus --python-script data.py>> and you have your output1.pdf file created!...> PS:> I have been posting this or similar solution since 2006 (and Scribus> version 1.2 I was using at that time). I would be glad if at least one> person try to compile scribus with this patch and confirm that it works> on some other computer than mine! If you find it useful it would be> extra bonus.
Thank you for posting the patch! I had also been looking for a way to run Scribus without user interaction.
The patch needed only a small change to work with the current 1.5.0svn under Fedora 20. The example worked except for some font issues in the generated PDF which I think are unrelated to the patch.
I have attached an updated version of the patch.
Regards,William


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140728/f4262110/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: scribus-cmd-wb-28jul14.pat
Type: application/octet-stream
Size: 6294 bytes
Desc: not available
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140728/f4262110/attachment.obj>
JLuc
2014-07-29 07:52:49 UTC
Permalink
Le 29/07/2014 01:54, William Bader a ?crit :
> On Sun Jul 27 17:32:02 UTC 2014, Juraj Fedel wtxnh-scribus at yahoo.com.au wrote: > On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc Balmer wrote:> > Or, in other words, are there ways to automate Scribus without user> > interaction, i.e. from the commandline?>> Let me try once more to present my solution to this problem! At the> bottom of the mail is small patch that enables exactly what Marc is> asking for.>> You can create template scribus document 'mydoc.sla' with two text> frames and this small python script 'data.py' in the same directory:>> import scribus> scribus.openDoc('mydoc.sla')> scribus.setText('Name', 'Text1') # get 'Name' and 'Address' from database> scribus.setText('Address', 'Text2')> pdf = scribus.PDFfile()> pdf.file = 'output1.pdf'> pdf.save()>> Then run scribus as folo
> w:> scribus --python-script data.py>> and you have your output1.pdf file created!...> PS:> I have been posting this or similar solution since 2006 (and Scribus> version 1.2 I was using at that time). I would be glad if at least one> person try to compile scribus with this patch and confirm that it works> on some other computer than mine! If you find it useful it would be> extra bonus.
> Thank you for posting the patch! I had also been looking for a way to run Scribus without user interaction.
> The patch needed only a small change to work with the current 1.5.0svn under Fedora 20. The example worked except for some font issues in the generated PDF which I think are unrelated to the patch.
> I have attached an updated version of the patch.

Could you please post this patch in the bug tracker so it got more chances of getting reviewed ?
http://bugs.scribus.net

Thanks
JLuc

> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140728/f4262110/attachment.html>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: scribus-cmd-wb-28jul14.pat
> Type: application/octet-stream
> Size: 6294 bytes
> Desc: not available
> URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140728/f4262110/attachment.obj>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
Kunda Loves Scribus
2014-07-29 13:34:29 UTC
Permalink
On Tue, Jul 29, 2014 at 2:52 AM, JLuc <jluc at no-log.org> wrote:

> Le 29/07/2014 01:54, William Bader a ?crit :
>
> On Sun Jul 27 17:32:02 UTC 2014, Juraj Fedel wtxnh-scribus at
>> yahoo.com.au wrote: > On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc
>> Balmer wrote:> > Or, in other words, are there ways to automate Scribus
>> without user> > interaction, i.e. from the commandline?>> Let me try once
>> more to present my solution to this problem! At the> bottom of the mail is
>> small patch that enables exactly what Marc is> asking for.>> You can create
>> template scribus document 'mydoc.sla' with two text> frames and this small
>> python script 'data.py' in the same directory:>> import scribus>
>> scribus.openDoc('mydoc.sla')> scribus.setText('Name', 'Text1') # get 'Name'
>> and 'Address' from database> scribus.setText('Address', 'Text2')> pdf =
>> scribus.PDFfile()> pdf.file = 'output1.pdf'> pdf.save()>> Then run scribus
>> as folo
>> w:> scribus --python-script data.py>> and you have your output1.pdf
>> file created!...> PS:> I have been posting this or similar solution since
>> 2006 (and Scribus> version 1.2 I was using at that time). I would be glad
>> if at least one> person try to compile scribus with this patch and confirm
>> that it works> on some other computer than mine! If you find it useful it
>> would be> extra bonus.
>> Thank you for posting the patch! I had also been looking for a way to
>> run Scribus without user interaction.
>> The patch needed only a small change to work with the current 1.5.0svn
>> under Fedora 20. The example worked except for some font issues in the
>> generated PDF which I think are unrelated to the patch.
>> I have attached an updated version of the patch.
>>
>
> Could you please post this patch in the bug tracker so it got more chances
> of getting reviewed ?
> http://bugs.scribus.net
>
> Thanks
> JLuc


Perhaps posting in one of these
http://bugs.scribus.net/view.php?id=238
http://bugs.scribus.net/view.php?id=967

Cheers,
/Kunda


On Tue, Jul 29, 2014 at 2:52 AM, JLuc <jluc at no-log.org> wrote:

> Le 29/07/2014 01:54, William Bader a ?crit :
>
> On Sun Jul 27 17:32:02 UTC 2014, Juraj Fedel wtxnh-scribus at
>> yahoo.com.au wrote: > On Sun, Jul 20, 2014 at 07:26:28PM +0200, Marc
>> Balmer wrote:> > Or, in other words, are there ways to automate Scribus
>> without user> > interaction, i.e. from the commandline?>> Let me try once
>> more to present my solution to this problem! At the> bottom of the mail is
>> small patch that enables exactly what Marc is> asking for.>> You can create
>> template scribus document 'mydoc.sla' with two text> frames and this small
>> python script 'data.py' in the same directory:>> import scribus>
>> scribus.openDoc('mydoc.sla')> scribus.setText('Name', 'Text1') # get 'Name'
>> and 'Address' from database> scribus.setText('Address', 'Text2')> pdf =
>> scribus.PDFfile()> pdf.file = 'output1.pdf'> pdf.save()>> Then run scribus
>> as folo
>> w:> scribus --python-script data.py>> and you have your output1.pdf
>> file created!...> PS:> I have been posting this or similar solution since
>> 2006 (and Scribus> version 1.2 I was using at that time). I would be glad
>> if at least one> person try to compile scribus with this patch and confirm
>> that it works> on some other computer than mine! If you find it useful it
>> would be> extra bonus.
>> Thank you for posting the patch! I had also been looking for a way to
>> run Scribus without user interaction.
>> The patch needed only a small change to work with the current 1.5.0svn
>> under Fedora 20. The example worked except for some font issues in the
>> generated PDF which I think are unrelated to the patch.
>> I have attached an updated version of the patch.
>>
>
> Could you please post this patch in the bug tracker so it got more chances
> of getting reviewed ?
> http://bugs.scribus.net
>
> Thanks
> JLuc
>
>
> -------------- next part --------------
>> An HTML attachment was scrubbed...
>> URL: <http://lists.scribus.net/pipermail/scribus/attachments/
>> 20140728/f4262110/attachment.html>
>> -------------- next part --------------
>> A non-text attachment was scrubbed...
>> Name: scribus-cmd-wb-28jul14.pat
>> Type: application/octet-stream
>> Size: 6294 bytes
>> Desc: not available
>> URL: <http://lists.scribus.net/pipermail/scribus/attachments/
>> 20140728/f4262110/attachment.obj>
>> ___
>> Scribus Mailing List: scribus at lists.scribus.net
>> Edit your options or unsubscribe:
>> http://lists.scribus.net/mailman/listinfo/scribus
>> See also:
>> http://wiki.scribus.net
>> http://forums.scribus.net
>>
>>
>
>
> ___
> Scribus Mailing List: scribus at lists.scribus.net
> Edit your options or unsubscribe:
> http://lists.scribus.net/mailman/listinfo/scribus
> See also:
> http://wiki.scribus.net
> http://forums.scribus.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140729/3a1e7dc6/attachment.html>
William Bader
2014-07-29 19:58:55 UTC
Permalink
> From: scribus.user at gmail.com
> Date: Tue, 29 Jul 2014 08:34:29 -0500> To: scribus at lists.scribus.net> Subject: Re: [scribus] Using scribus to create PDFs from the commandline
>
> > Could you please post this patch in the bug tracker so it got more chances
> > of getting reviewed ?
> > http://bugs.scribus.net
> >
> > Thanks
> > JLuc
>
> Perhaps posting in one of these
> http://bugs.scribus.net/view.php?id=238
> http://bugs.scribus.net/view.php?id=967
>
> Cheers,
> /Kunda

I posted it under http://bugs.scribus.net/view.php?id=12572
Juraj's patch is more general than a PDF option because it allows you to run any python code. His example looks like the basis of a mail merge or a form letter generator.
Regards,William


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scribus.net/pipermail/scribus/attachments/20140729/ac48cf62/attachment.html>
Loading...