From The Document Foundation Wiki
Jump to: navigation, search

Exporting to hybrid PDF format

A hybrid PDF is a file which can be read like any other PDF, but which contains a source document in PDF format, allowing you to modify it using LibreOffice. It can be created with the menu command File ▸ Export as PDF. (See Frequently asked questions - Writer).

The following macro shows how to do this in Basic. The array propFich in this example specifies the filter to use (calc_pdf_Export) and the selected options. The filterProps array specifies the text to be exported and contains a switch IsAddStream to determine whether the export is to take place.

Example of exporting in hybrid PDF format:

sub ExportPdfAHybride

dim propFich(1) as new
dim filterProps(1) as new

dim adresseDoc  as string

filterProps(0).Name = "Selection"
'filterProps(0).Value = thisComponent.currentSelection
filterProps(0).Value = thisComponent.currentController.ActiveSheet
filterProps(1).Name = "IsAddStream"
filterProps(1).Value = true
'filterProps(1).Value = false

propFich(0).Name = "FilterName"
propFich(0).Value = "calc_pdf_Export"
propFich(1).Name = "FilterData"
propFich(1).Value = filterProps()

adresseDoc = convertToURL("c:\Tests\test.pdf")
thiscomponent.storeToURL(adresseDoc, propFich())

end sub