[Solved] Can't set a custom paper size correctly

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Eatmeat
Posts: 7
Joined: Sat May 14, 2011 10:20 pm

[Solved] Can't set a custom paper size correctly

Post by Eatmeat »

I'm trying to set a custom paper size, width 21 cm and height 14.85 cm, but instead it is set as 37.05 cm and 26.2 cm. What's interesting if I set paper size of A4 (21000 and 29700) it gets recognized as A4 and set correctly. What do I miss?
OpenOffice 3.4.1

Code: Select all

Sub Main
	Dim Doc As Object
	Dim Sheet As Object
	Doc = ThisComponent
	Dim PaperSize as New com.sun.star.awt.Size
	Dim printerOptions(1) As New com.sun.star.beans.PropertyValue		
	printerOptions(0).Name = "PaperFormat" 
	printerOptions(0).Value = com.sun.star.view.PaperFormat.USER	
	PaperSize.Width = 21000
	PaperSize.Height = 14850
	printerOptions(1).Name = "PaperSize"
	printerOptions(1).Value = PaperSize
	Doc.Printer = printerOptions()
End Sub
Thank you.
Last edited by Eatmeat on Thu Nov 29, 2012 10:50 am, edited 2 times in total.
OpenOffice 3.4.1
Eatmeat
Posts: 7
Joined: Sat May 14, 2011 10:20 pm

Re: Can't set a custom paper size correctly

Post by Eatmeat »

It's like it's multiplied by a factor of 1.764. Although documentation says "20000 corresponds to 20 cm" and my windows settings are metric.
OpenOffice 3.4.1
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Can't set a custom paper size correctly

Post by RoryOF »

Without knowing anything about your code, I remark that the dimensions you give are for A5 in landscape orientation. Perhaps, as a workaround, you could set the specific paper size by name and orientation rather than by dimensions.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
MikeytheMagnificent
Posts: 137
Joined: Fri Apr 11, 2008 12:06 am
Location: W. Yorks UK

Re: Can't set a custom paper size correctly

Post by MikeytheMagnificent »

Would printing 2 pages on each sheet of A4 as RoryOF hinted printing a Brochure, as its called in OOo, which isn't the same as a Microsoft brochure, do the business without macros. But a word of warning when I tried to do this sort of thing (with 4, 6 or lots records per sheet) when trying to print some labels, it printed on alternate facets, leaving alternate ones blank
Many opportunities to add short Tutorials or faq's are missed

1. Must have obvious title to be found easily
2. Keep to objectives
3. Use very clear language
4. Difficult to get right
5. Rewards are few
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Can't set a custom paper size correctly

Post by RoryOF »

I wasn't thinking about printing two up, which, as Mikey suggests, is a possibility, simply recognising that A5 is a defined paper size within current AOO 3.4.1 (also A6, very useful for trial pagenumbering setups!).
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Eatmeat
Posts: 7
Joined: Sat May 14, 2011 10:20 pm

Re: Can't set a custom paper size correctly

Post by Eatmeat »

Sorry for not answering for so long.
I guess my wrong paper size problem is only solved by dividing by the magic number 1.764.
MikeytheMagnificent wrote:Would printing 2 pages on each sheet of A4 as RoryOF hinted printing a Brochure, as its called in OOo, which isn't the same as a Microsoft brochure, do the business without macros.
What I'm actually trying to do is always print on no more than a HALF of an A4 portrait, but no matter what paper size, orientation and scale mode I choose, it rotates the image (making it landscape) so as to fit it into a WHOLE A4 list.
OpenOffice 3.4.1
B Marcelly
Volunteer
Posts: 1160
Joined: Mon Oct 08, 2007 1:26 am
Location: France, Paris area

Re: Can't set a custom paper size correctly

Post by B Marcelly »

For your information, the paper size is measured in twips.
A twip is 1/20 th of a point; a point is 1/72 of an inch. That is, 1 twip = 1.76 x 1/100 mm

Back in 1994, I issued Bug 35660 to request the update of the documentation (which was easier than changing the code and compatible with existing user programs). But nothing was done.
Bernard

OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Post Reply