Jump to content

マクロ/全般/006

From The Document Foundation Wiki
This page is a translated version of the page Macros/General/006 and the translation is 100% complete.


説明

ハイブリッドPDFは、他のPDFと同じように読むことができますが、PDF形式のソース・ドキュメントが含まれているため、LibreOfficeを使用して変更することができます。メニューコマンド ファイル ▸ 次の形式でエキスポート ▸ PDFとしてエキスポート を使用して作成できます。

次のマクロは、LibreOffice Basic でこれを行う方法を示しています。この例では、配列 propFich は、使用するフィルタ (calc_pdf_Export) と選択し、オプションを指定します。filterProps 配列は、エクスポートされるテキストを指定し、エクスポートが行われるかどうかを決定するスイッチ IsAddStream を含みます。

Code

LibreOffice Basic:

Option Explicit

Sub ExportPDFinHybridFormat
    '''Export current active Calc sheet to a hybrid PDF

現在アクティブな Calc シート をハイブリッドPDFへエクスポート'''

    Dim filterData(1) As New com.sun.star.beans.PropertyValue
    Dim filterProps(1) As New com.sun.star.beans.PropertyValue
    Dim fileAddress As String

    'filterData に prop-vals を作成し、filterProps に渡します。
    filterData(0).Name = "Selection"
    filterData(0).Value = ThisComponent.CurrentController.ActiveSheet
    filterData(1).Name = "IsAddStream"
    filterData(1).Value = True

    'エクスポート関数 storeToURL に渡される prop-vals を filterProps に作成します。
    filterProps(0).Name = "FilterName"
    filterProps(0).Value = "calc_pdf_Export"
    filterProps(1).Name = "FilterData"
    filterProps(1).Value = filterData()

    fileAddress = convertToURL("/home/<user>/Documents/test.pdf")
    ThisComponent.storeToURL(fileAddress, filterProps())

End Sub ' ExportPDFinHybridFormat

マクロのテスト用 ODT ファイル

メモ