Page 1 of 1

Optimize whitespace

Posted: Tue May 20, 2008 12:29 pm
by mattis
Hi,

I have a case where I need to optimize white space in a document.

Case:
http://www.flickr.com/photos/26747105@N04/2508448218/

As you can see the image is too big.

I want to grab the picture, resize it so that it fits into the first page, resulting in this:
http://www.flickr.com/photos/26747105@N04/2508448276/

The problem is determining how much white space I have left on the first page, so I'll know the amount of resizing needed.

Re: Optimize whitespace

Posted: Fri May 23, 2008 3:41 am
by pitonyak
This is a very difficult problem I think. I would probably do something similar to the following:

1. Please the cursor in the paragraph before the picture.

2. Calculate the location of the text cursor (see the section titled "Where is the Display Cursor?" in my free macro document).

3. Determine how much free space is between that and the end of the page

It will take some trial and error. Please share any solutions that you determine.

Re: Optimize whitespace

Posted: Fri May 23, 2008 12:49 pm
by Caracalla
All you basically want to know is the space, in pixles, between the bottom of your first paragraph and the end of the page, right? I don't think you should look for the solution in OOo. There's things called screen rulers available, like this one*, that would be of more help here. All you have to do is make sure that your document is zoomed to 100%. The ruler will tell you the umber of pixels and you can adapt your picture to that.
Hope this helps.

*NB: i've only just googled this one i've never used it. If you use Opera of FF there's also widgets/extensions available that can do this.

EDIT: I'm wondering though why you don't simply resize the picture in writer. Just anchor it to the first paragraph and resize it. The rest of the text should flow along.

EDIT2: whoops, hadn't seen that this was in the Macro section.
Sorry for the useless answer then :)

Re: Optimize whitespace

Posted: Fri May 23, 2008 3:56 pm
by mattis
pitonyak wrote:This is a very difficult problem I think. I would probably do something similar to the following:

1. Please the cursor in the paragraph before the picture.

2. Calculate the location of the text cursor (see the section titled "Where is the Display Cursor?" in my free macro document).

3. Determine how much free space is between that and the end of the page

It will take some trial and error. Please share any solutions that you determine.
This is probably the best solution so far; thanks for this insight.
Caracalla wrote:All you basically want to know is the space, in pixles, between the bottom of your first paragraph and the end of the page, right? I don't think you should look for the solution in OOo. There's things called screen rulers available, like this one*, that would be of more help here. All you have to do is make sure that your document is zoomed to 100%. The ruler will tell you the umber of pixels and you can adapt your picture to that.
Hope this helps.

*NB: i've only just googled this one i've never used it. If you use Opera of FF there's also widgets/extensions available that can do this.

EDIT: I'm wondering though why you don't simply resize the picture in writer. Just anchor it to the first paragraph and resize it. The rest of the text should flow along.
The reason is that I want to do this with OOo in headless mode and do it automatically through the UNO API. I need to programatically determine how much whitespace is left on the page.

Re: Optimize whitespace

Posted: Tue May 27, 2008 5:53 am
by pitonyak
You want to do this in headless mode? That could be a big problem. The only thing that understands how the document is displayed is the current controller / view cursor. The document itself is stored as a simple set of text commands and such. You will notice that although it knows about the fonts that it thinks that it desires to use, it does NOT contain font metrics or even know if the system supports a specific font.

I must have missed the fact that you desired to use headless mode. Silly me. I will be impressed if you are able to solve this in headless mode.