Am Freitag, den 20.04.2007, 17:28 -0700 schrieb Ryan Grimm:
> > If this last step doesn't work, the easiest way to get around would be
> > to predefine a new page style having the size set as needed. In your
> > program you would only apply this page style temporarily and reset after
> > it is done - no need to fiddle with actual sizes directly.
> > 
> > If you have only one or a small amount of special size settings you only
> > need to care about distributing the page style to every client ...
> 
> Hi Marc,
> 
> Unfortunately the page size is going to vary from spreadsheet to 
> spreadsheet so I don't think I'll be able to predefine a page style.  My 
> end goal is to set the page width to be the same as the width of the 
> spreadsheet itself.

I see.

> It seems like this is something I should be able to do, am I correct in 
> my thinking?

I think so, too. But I'm only partly an expert in "printing matters",
knowing some facts from the users and macro programmers view. The
behaviour you describe look like an error to me. It rings a bell
somewhere too, but I don't know what it wants to tell me ... maybe an
old issue not fixed yet.

Last time dealing with calc and printing I went another way in my code:

(- store all defined print areas to not disturb users)
- define a print area containing the used range of cells
- print the sheet
- delete the self defined print area
(- restore all user print areas)

In BASIC the core part boils down to (working code I've made for a
template):

sub PrintSheetToPDF(aDoc as object, aSheet as object, aFileName)

        ' neuen Druckbereich einstellen, benutzter Bereich auf einer Seite
        dim oPrintAreas(0) as new com.sun.star.table.CellRangeAddress
        with oPrintAreas(0)
                .Sheet = IndexOfSheet(aDoc, aSheet)
                .StartRow = 0
                .StartColumn = 0
                .EndRow = maxRowI(aSheet)
                .EndColumn = maxColumnI(aSheet)
        end with
        aSheet.setPrintAreas(oPrintAreas())
        
        ' neuen Drucker setzen
        dim oPrinterDescriptor(0) as new com.sun.star.beans.PropertyValue
        oPrinterDescriptor(0).Name = "Name"
        oPrinterDescriptor(0).Value = "PDF-Konverter"
        aDoc.setPrinter(oPrinterDescriptor())
        
        ' Sheet drucken
        dim oPrintOpts(0) as new com.sun.star.beans.PropertyValue
        oPrintOpts(0).Name = "FileName"
        oPrintOpts(0).Value = ConvertToUrl(aFileName)
        aDoc.print(oPrintOpts())
        
end sub

For a translation to Java you'll have to insert the "queryInterface"
calls and get the var typing right ...

HTH,
Marc


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to