Scribusoid

Author Topic: Resize multiple text frames simultaneously  (Read 3124 times)

AliasHannibal

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
Resize multiple text frames simultaneously
« on: August 27, 2018, 05:08:29 pm »
As a regular user of Scribus (I've typeset several books, and designed book covers, etc), I sometimes realize that I need to resize several text frames after I've created the document.

To do this I have to go to each frame and copy and paste (or type, but that's slower) the exact measures for the text frames. When I need to do this for a whole book (more than let's say 30 pages, but I often work with books of more than 200 pages), it is a hopeless job that takes forever. And since it could be automated, I wonder if there's a better way to do this.

I can create new documents and let Scribus automatically create text frames for me, but if I've already worked on several other features in this document, this becomes less attractive as an option.

If I try and zoom out and select all the text frames, I have found that the text frames behave erratically. Sometimes they resize unevenly, or in proportion to each other. This is not what I want. I want to change all of them at the same time to the same measurements.

Is there any other way to change the size simultaneously? Thanks in advance.

Nermander

  • Hero Member
  • *****
  • Posts: 1458
  • Karma: 19
Re: Resize multiple text frames simultaneously
« Reply #1 on: August 27, 2018, 05:58:02 pm »
I'd say the best way is probably to write a script for it.

I don't think it would be very hard to write a script that does "Every frame with these measures shall be changed to this size". A loop and a couple of if statements.

AliasHannibal

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #2 on: August 27, 2018, 06:08:39 pm »
Thanks for the quick reply.

That would be great. I know nothing about how to do that. Do you?

Nermander

  • Hero Member
  • *****
  • Posts: 1458
  • Karma: 19
Re: Resize multiple text frames simultaneously
« Reply #3 on: August 27, 2018, 08:54:23 pm »
I have not yet bothered to learn the Scribus scripter, but I think there is already a sample script out there that iterates through all text frames in the document. I would think it is not very complicated to adjust it with a few if statements, at least if you know a little about programming.

AliasHannibal

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #4 on: August 27, 2018, 09:02:40 pm »
Sorry. I don't. I am hopeless with any sort of programming. But I really appreciate you guiding me in the right direction. Thanks.

Ewac

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #5 on: June 16, 2021, 07:30:49 am »
Has there been a solution to this issue in the past years? I'm in the same situation and would really appreciate a way to rezise multiple frames together....

RobSay

  • Newbie
  • *
  • Posts: 33
  • Karma: 0
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #6 on: June 16, 2021, 08:29:19 pm »
I'm not aware of any new solutions to this and I use scripter to achieve a similar sort of effect (standard width image frames over 250 pages)

For a straight forward resize of all frames within the whole document - you can run this in the scripter console:
Code: [Select]
# select all the items in the document - you can be much cleverer than this with page ranges etc
allItems = getAllObjects()
# loop through all the objects
for item in allItems :
  # look for text frames only - you can be cleverer here in lots of ways and filter by type, name, property .. whatever
  if (getObjectType(item) == 'TextFrame'):
    # set the frame dimensions (you can calculate the desired width and height etc)
    sizeObject(200,30, item)
    # you could also move the text frame to a specific point on the page (might need to check the current page)
    # moveObjectAbs(x,y,item)

Ewac

  • Newbie
  • *
  • Posts: 12
  • Karma: 0
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #7 on: August 10, 2021, 04:19:25 pm »
I have tried this unsuccesfully, but I never worked with scrips ever and I am not even sure how to fill out the template you gave exactly. I have 300+ pages and need to change all the frames now.
If it's not too much to ask, could you show me how I have to adjuct the template script to change
every text frame in the document
to the size w 122mm, h 190mm
in the position x 10mm, y 10mm

RobSay

  • Newbie
  • *
  • Posts: 33
  • Karma: 0
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #8 on: August 12, 2021, 01:36:56 am »
Scripter can be a little finicky - but it is very powerful.

Try this:
  • Create a new scribus document and add a Text frame anywhere on the first page
  • Page Menu > Copy > Just OK on the dialog ... creates a second page
  • Script Menu > Show Console > Copy the script below into the top field of the dialog
  • Dialog Script Menu > Run
The text frame you created in step 1 and the text frame on the 2nd page should be resized to your dimensions and position (assuming your default doc is defined in mm).

If it's doing what you want ... open your 300 page document and repeat steps 3 & 4.

Code: [Select]
pageNum = 1
totalPageCount = pageCount()
while (pageNum <= totalPageCount):
  gotoPage(pageNum)
  # select all text frame items on the current page
  allItems = getAllObjects(ITEMTYPE_TEXTFRAME)
  # loop through all the objects
  for item in allItems :
    sizeObject(122,190, item)
    moveObjectAbs(10,10,item)
  # next page
  pageNum +=1
# leave a blank line at the end for the scripter console - after this comment

The final blank line is critical - as is all of the indentation (spaces not tabs)
« Last Edit: August 12, 2021, 01:41:28 am by RobSay »

AdmFubar

  • Jr. Member
  • **
  • Posts: 76
  • Karma: 1
  • Scribus User
Re: Resize multiple text frames simultaneously
« Reply #9 on: August 12, 2021, 07:03:46 am »
While not an immediate solution, what seems to be a better option would be styles for images. This would allow changing the frame sizing, location, etc. . would be usfull for other objects as well.

 

palmate