I have a problem which I can't solve so far. I have an excel file which has to be exported to pdf. Before exporting it, I have to set page breaks programmatically (in Java), so the exported pdf file looks good (I have some rules, like some rows should come together on the same page, and I can have one row on 1st page and next one on the second). To set page breaks in excel file I need to know what is the size of certain row. Is it possible to calculate? is it "predictable"?
Example (created in MS Office Excel):
1) I set in excel file scale to 65% (to fit the width)
2) my table in excel file, on my PC is about 1038px wide
3) height of one row is about 53 pixels
after conversion from Java using OpenOffice I have (in pdf file):
1) width of the table is about 719px
2) height of the row is 32px (without borders; in excel I have 1px top and bottom borders, in result pdf file I see 2px above and below)
what is strange for me: why 719px, if 65% from 1038 is 674,7px; 65% from 53 is 34,45px, is the scaling so disproportional?
is the scaling applied to the height of the row? as I told, result height is 32px without borders, and I have borders 2 px, so if "half" of the border belongs to the row, then I get 32 + 2/2 + 2/2 = 34px and it looks like 65%. Am I right in my calculation? Is here any other formula to get the height?
_______________________________________________
UPDATE:
well, even if my suspicions are right, I have another problem. When I open excel file in MS Excel, set there "fit to width" to "1 page" I see almost in the next field calculated by Excel scaling (like it was in my case - 65%). Using OO Calc I don't see this feature. It seems that Excel calculates it and saves both values "fit q page width" and "scale to 65%" in xls file. OO Calc saves only "fit to 1 page width", does not calculate which scale is needed for it. The same I see when I generate xls document from Java using POI library. So I have additional question: If I know that document should fit 1 page, how to calculate the scale needed? In my example it means how to get 65%...
How to get the height of row(s) in exported pdf
-
aeternitas
- Posts: 4
- Joined: Mon Dec 05, 2011 4:42 pm
How to get the height of row(s) in exported pdf
OpenOffice 3.3 on Windows 7
-
aeternitas
- Posts: 4
- Joined: Mon Dec 05, 2011 4:42 pm
Re: How to get the height of row(s) in exported pdf
Is here any formula for it? Say I know height of Excel row in pixels (or whatever else), I know if there are top/bottom borders (if matter), display resolution etc; I've generated that Excel file, so I know everything needed, then how to calculate height of that row in PDF file?
I tried to look up OO sources, but I didn't manage to find that place, can anybody point me?
thank you for any information,
Max
I tried to look up OO sources, but I didn't manage to find that place, can anybody point me?
thank you for any information,
Max
OpenOffice 3.3 on Windows 7
Re: How to get the height of row(s) in exported pdf
In PDF files measure unit is pt (normally and created by OOo), consider in it.
You can get page height, page margins, header height and cell heights in 1/100 mm though the api. Calculate in real unit used in the your target format away from display unit.
Cell borders are drawn on the cell rectangle, so if you draw 4 pt width line as border line, you see the half of the line is over wrapped on the cell in exported pdf file.
You can get page height, page margins, header height and cell heights in 1/100 mm though the api. Calculate in real unit used in the your target format away from display unit.
Cell borders are drawn on the cell rectangle, so if you draw 4 pt width line as border line, you see the half of the line is over wrapped on the cell in exported pdf file.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
-
aeternitas
- Posts: 4
- Joined: Mon Dec 05, 2011 4:42 pm
Re: How to get the height of row(s) in exported pdf
>You can get ... cell heights in 1/100 mm though the api
do you mean cells in PDF? Is it possible to get? Can you give me any example? I read somewhere that after it is exported to PDF this format is loosing info about table and its cells, so PDF treats table in different way then Excel/Word/RTF...
that's good advice, that everything is in pt in PDF, I didn't think about it, anyway for now everything I have are just pixels (after I make a screen shot of pdf), so if I could measure table in pdf in other metrics (preferably in pt), it would be very helpful..
thank you!
do you mean cells in PDF? Is it possible to get? Can you give me any example? I read somewhere that after it is exported to PDF this format is loosing info about table and its cells, so PDF treats table in different way then Excel/Word/RTF...
that's good advice, that everything is in pt in PDF, I didn't think about it, anyway for now everything I have are just pixels (after I make a screen shot of pdf), so if I could measure table in pdf in other metrics (preferably in pt), it would be very helpful..
thank you!
OpenOffice 3.3 on Windows 7
Re: How to get the height of row(s) in exported pdf
No it's in the office but PDF filter tries to export in the same size with in the spreadsheet. You can calculate contents size.[/quote]do you mean cells in PDF?
Just an example:
Code: Select all
Sub CalculateSizeInPt
oRange = ThisComponent.getCurrentSelection()
aSize = oRange.Size
width = ToPt(aSize.Width)
height = ToPt(aSize.Height)
msgbox "Width: " & CStr(width) & " height: " & CStr(height)
End Sub
' 1/100 mm to pt
Function ToPt(n)
ToPt = n / 100.0 / 25.4 * 72.0
End FunctionIf you want to know your calculation is correct, export a file to pdf and unpack its page data to check the result. So, you might need knowledge about pdf, read pdf reference provided from Adobe if needed.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Apache OpenOffice 4-dev on Xubuntu 14.04
Re: How to get the height of row(s) in exported pdf
Hello I know this is an old thread but I am looking to do something similar.
1>We have xls files created by customers so I don't know the width and height.
2>How do take the width and height of each spread sheet and get it into pdf units.
3>How do I manual add page breaks using java to spread the sheet on multiple pages to make it look pretty.
4>Also there are times where the sheet is too wide how do we switch to landscape mode to get all the cells in one page?
1>We have xls files created by customers so I don't know the width and height.
2>How do take the width and height of each spread sheet and get it into pdf units.
3>How do I manual add page breaks using java to spread the sheet on multiple pages to make it look pretty.
4>Also there are times where the sheet is too wide how do we switch to landscape mode to get all the cells in one page?
Libre Office 5.2.5
Windows
Windows