How to export first 100 pages of XLS/DOC/PPT to PDF Using LibreOffice

Hi,

I am using LibreOffice with one of my application developed in C#. The workflow is, LibreOffice loads XLS/DOC/PPT and export them to PDF.

PROBLEM: it takes hours to export XLS/DOC/PPT to PDF if number of pages are in thousands. It’s not the file size which is a problem (time taking), it is the number of pages.

SOLUTION: The solution I want to implement if to print only first 100 pages.

HELP NEEDED: I need help in understanding how I can limit the number of pages to export, programmatically in C# or any other programing language. Without using LibreOffice interface. Is there any API or command line arguments I can use?

Thank You,
Sorabh

Perhaps you can use the dispatcher? When I record the pdf export in Writer to a BASIC macro, I can see the .uno:ExportToPDF command and a property PageRange. I have done it with export of page 3-5 and export with page 4 and get the values Array("PageRange",0,"3-5",com.sun.star.beans.PropertyState.DIRECT_VALUE) and Array("PageRange",0,"4",com.sun.star.beans.PropertyState.DIRECT_VALUE), so I think, that is the correct place for your page numbers. From the recorded BASIC macro you can see, what other properties are needed in addition. I count 51 properties, to long to cite here.

Hi

You can use something like:

sub ExportPDFNbPages

dim Props(1) As New com.sun.star.beans.PropertyValue
dim filterProps(0) as new com.sun.star.beans.PropertyValue

dim sUrl  as string

filterProps(0).Name = "PageRange"
filterProps(0).Value = "1-100"

Props(0).Name = "FilterName"
Props(0).Value = "writer_pdf_Export"
Props(1).Name = "FilterData"
Props(1).Value = filterProps()

sUrl = convertToURL("c:\Tests\export.pdf")

thiscomponent.storeToURL(sUrl, Props())

end sub

See API documentation.

Regards