Looking for Advice on Using importPage

Previous topic - Next topic

Derek

I'm writing a script to allow me to append sections of a magazine to build a complete magazine (which then goes through final editing (of course).

As there does not appear to be a simple way to append complete sla files I am using importPage to import each page separately. I'm having some difficulties with this:

1) I haven't found an easy way to specify that I want to import all pages. I'm preprocessing each section to get the number of pages in that section, then using the stored number of pages to build the pageList parameter (eg {1, 2, 3, 4}) for importPage. Have I missed something?

2) Whenever importPage creates a page, it creates an empty text frame. This gets in the way for subsequent editing. This is also a problem with newPage - may be related. Can I stop this (possibly I've missed a setting somewhere)?

3) importPage loses the linkage between linked text frames. This needs to be manually recreated to restore the finished page. Any ideas for retaining the linkage?

AdmFubar

depending on the total pages in the magazine you may run into a performance issue with large .sla files. Appending the sections as a finished pdfs, into one will be much easier.
Using Scribus 1.6.1, openSUSE 15.6
Advanced hobbyist

a.l.e

#2
Hi Derek

A few short answers from my side...


1

According to https://impagina.org/scribus-scripter-api/page/#importpage it seems to be possible to pass a range of pages...

In order to know which pages you want to be imported, you might want to get the script to first open the sla, analyze it, close it, before importing the pages.

2

Did you enable auto frames when creating the document?

3

That might be a bug in the pages import, independent from the script API...

Derek

Quote from: AdmFubar on October 04, 2024, 03:11:20 PMdepending on the total pages in the magazine you may run into a performance issue with large .sla files. Appending the sections as a finished pdfs, into one will be much easier.

Unfortunately, not possible in my use case. The aggregate sla is an intermediate stage that requires further editing to complete the magazine. Mainly making final decisions about content, adding adverts, sorting out white space and the transitions between sections, sometimes finding filler content to pad out the magazine to a multiple of 4 pages (it's an A5 magazine printed on A4 stock) and building a TOC.

Performance, so far, hasn't been an issue. There's usually about 50 to 100 pages (with text and images) in the aggregate sla file, and I'm happy to go get a cup of coffee while I'm waiting for the script to complete. The current test data (which produces 54 pages) is the last edition's live data. The script completes in under 800 seconds. I haven't seen any memory issues (and the machine I run this on only has 8Gb). In its final form it was edited down to 44 pages - one of my larger editions.

Derek

Quote from: a.l.e on October 04, 2024, 05:28:55 PMHi Derek

A few short answers from my side...


1

According to https://impagina.org/scribus-scripter-api/page/#importpage it seems to be possible to pass a range of pages...

In order to know which pages you want to be imported, you might want to get the script to first open the sla, analyze it, close it, before importing the pages.

2

Did you enable auto frames when creating the document?

3

That might be a business pages import, independent from the script API...

Hi A.L.E.:

1) That's exactly what I'm doing. I preprocess each section to get the page count. That's stored in a mySQL table which is used to control the build process. Each page count (integer) is converted to a tuple {1, 2, 3, 4, ....} for the importPaqe process. I was hoping for a wildcard ('*' or similar) that I have missed or is not documented. That would enable me to drop that process completely - which would give me a worthwhile time saving. (The process is automated, but I haven't managed to get it into the background, yet - it's on my list, so the gui is tied up while it runs.

2) That's a strong possibility. I'm sure I saw that when I created the original documents - which was, perhaps, 5 or 6 years ago! If that is the issue, can that setting be changed in an existing document (I haven't found it - perhaps it's a straightforward edit to the XML that I haven't dived into yet), or must I start from scratch? Would 'enable auto frames' have to be unset for all the section files, or just the first one loaded?

3) I'm not sure what you mean by 'business pages import'. Perhaps something lost in translation?

a.l.e

Quote from: a.l.e on October 04, 2024, 05:28:55 PM3

That might be a business pages import, independent from the script API...

Bug. bug!

Damned autocorrect!

Derek

Quote from: a.l.e on October 04, 2024, 10:17:19 PMBug. bug!

Damned autocorrect!

Gets us all sooner or later!

For issue 2 (empty frames being created) I changed AUTOTEXT in the sla file to 0. On running the build process, empty frames are no longer being created. I'm not really able to say, yet, whether editing the sla file directly will cause problems further down the line, but perhaps changing that option should be available under Document Setup or Preferences. Perhaps even as a Scripter command (it might even be useful to be able to choose programmatically).

This also helps with issue 3 (losing linkage between imported frames). I have to edit the aggregated document anyway, so it's easy and quick enough to identify the correct frame to link to without the additional autotext frame causing confusion. This doesn't, of course, fix the bug - but does give me an easy workaround.

I think it's time to improve what I've got, so far, so that it's in shape to produce the next (December) edition.

Progress has definitely been made - thank-you.

BN_Dev

Interesting stuff @Derek hopefully you can give an update when you get it working as you want 8)
Developer in the print industry with Quark+macOS expertise. Linux+KDE fan. Code in Qt/C/C++/Java/PHP/JS/more. FOSS advocate.