Exporting/extracting text from a single layer.

Previous topic - Next topic


Can anyone suggest a solution to the following scenario please?

I have a newsletter where the text for all of the articles is in text frames in the same layer (e.g. "articles"). Some text exists in other layers but, for this scenario, they're pretty much irrelevant (i.e. they're used for page decoration etc.).

How can I export (or otherwise extract) all of the text from that one layer ("articles") to a text file, at the same time, while ignoring all the text in the other layers?

The purpose of doing this is to make it easier, once the newsletter is at the point of being published, to extract the relevant text for use in an email (for people who don't want to receive the full PDF but still want the info, for example: they don't have a computer but can get emails through their phone).

I've looked at the File->Export... function but it seems to only be able to export text from the currently selected text frame. I also tried using "Select All" (within my "articles" layer) and then using the Export... function but it just exports the text from one frame as before. I've also had a look around the menus and couldn't find anything else that seems to be relevant.

(I found this page in the wiki: http://wiki.scribus.net/canvas/Extracting_All_Text_from_a_Document but it does the whole document, not just one layer, and I can't program in Python to change it - and there seems to be an issue about variable size too.)

The newsletter isn't very big so it's not a huge job to do this manually, I just wondered if anyone already had a working solution.


sadly not possible yet.

this is not only one of the most requested features for the scripter, but also a missing feature that embarrassed me a lot during the scribus scripting workshop i've given last week.

i will make sure that this will be possible with the new scripter engine which will be in scribus 1.6!


hi garry

Quote from: GarryP on July 15, 2012, 03:26:45 PM...I found this page in the wiki: http://wiki.scribus.net/canvas/Extracting_All_Text_from_a_Document but it does the whole document, not just one layer...

...as a workaround you could delete (in a copy of your document) all layers, you don't like to export – not an elegant solution, but a possible one...



Oops, sorry a.l.e, I didn't know I'd be bringing up bad memories.

And thanks utnik, your solution is certainly something for me to look at in the short term.

If this is not possible with the scripter at the moment I've had an idea which may or may not come to anything. I'll post something here if it works.

Thanks to you both.




I threw some Java code together last night that seems to do the job so I've attached it in a text file to this post.
It's just a quick hash-up (it took me about two hours) but it seems to do what I want on the basic tests I did.

(Real Java coders: Please don't laugh at my silly code, I know it's not great or anything, it's more of a proof of concept than anything else.)

Obviously it's very raw and could do with tidying up if it were to be used for real - and I just picked my way through the XML in a SLA file so I've probably missed quite a lot of possibly important stuff - but if it comes in useful to anyone else then that's a plus.

I've no real intention in following this up with anything better at the moment but I've no problem with someone using it as the basis for something more "proper".

Anyway, the instructions are in the code and I've left my "workings" in there in case anyone finds them useful.

[attachment deleted by admin]