Page 1 of 1

Convert pdf with visual basic OpenOffice Calc

Posted: Mon Dec 10, 2018 6:51 pm
by visomes
Good afternoon, how are you?
Has anyone used any commands below to convert an open office spreadsheet using visual basic.net? I'm trying to use it but with no success so far. If anyone can help, I'm grateful, thank you.

Code: Select all

 Sub exportaPDF()
        ' precisamos no mínimo da propriedade Filtro
        Dim oDoc As Object
        Dim sUrl As String
        Dim aProp(0) As New com.sun.star.beans.PropertyValue
        oDoc = thisComponent
        ' adapte para seu sistema
        sUrl = "c:\OOOexemplos\tst_PDF.pdf"
        sUrl = ConvertToURL(sUrl)
        ' define o filtro de exportação
        aProp(0).Name = "FilterName"
        aProp(0).Value = "writer_pdf_Export"
        ' para exportar use storeToURL
        oDoc.storeToURL(sUrl, aProp())
    End Sub

Re: convert pdf with visual basic openOffice Calc

Posted: Mon Dec 10, 2018 7:15 pm
by Zizi64
using visual basic.net?
The StarBasic - embedded in the AOO/LO - is not appropriate for you?

Re: convert pdf with visual basic openOffice Calc

Posted: Mon Dec 10, 2018 7:35 pm
by visomes
I could not find in the code something that meets what I need, which is to convert to pdf. Do you know how to do it?

Re: convert pdf with visual basic openOffice Calc

Posted: Mon Dec 10, 2018 7:50 pm
by Zizi64
What you want to convert?
- a whole .ods document?
- one sheet only?
- a selected cellrange only?

(You must use the same StoreTo() routine with spreadsheet-related parameters.)

Re: convert pdf with visual basic openOffice Calc

Posted: Mon Dec 10, 2018 7:52 pm
by RoryOF

Re: convert pdf with visual basic openOffice Calc

Posted: Mon Dec 10, 2018 8:39 pm
by Lupp
LibreOffice / OpenOffice don't support VBA.

Conversion is done by the appropriate filter when storing TO (Not As!) a file.
The document itself remains unchanged and associated with the file it was loaded from (or used with stroeAs previously).
See https://stackoverflow.com/questions/305 ... o-pdf-file for an example.
It's basically the same with both branches though LibreOffice seems to be more active in developing/enhancing filters.

===Editing===
I just explored Q&D the names of arguments that were set for the respective .uno:ExportTo command used with the "calc_pdf_Export" filter of current LibreOffice (6.1.3). There were 52:
"UseLosslessCompression", "Quality", "ReduceImageResolution", "MaxImageResolution", "UseTaggedPDF", "SelectPdfVersion", "ExportNotes", "ViewPDFAfterExport", "ExportBookmarks", "OpenBookmarkLevels", "UseTransitionEffects", "IsSkipEmptyPages", "ExportPlaceholders", "IsAddStream", "FormsType", "ExportFormFields", "AllowDuplicateFieldNames", "HideViewerToolbar", "HideViewerMenubar", "HideViewerWindowControls", "ResizeWindowToInitialPage", "CenterWindow", "OpenInFullScreenMode". "DisplayPDFDocumentTitle", "InitialView", "Magnification", "Zoom", "PageLayout", "FirstPageOnLeft", "InitialPage", "Printing", "Changes", "EnableCopyingOfContent", "EnableTextAccessForAccessibilityTools", "ExportLinksRelativeFsys", "PDFViewSelection", "ConvertOOoTargetToPDFTarget", "ExportBookmarksToPDFDestination", "SignPDF", "_OkButtonString", "Watermark", "EncryptFile", "PreparedPasswords", "RestrictPermissions", "PreparedPermissionPassword", "SignatureLocation", "SignatureReason", "SignatureContactInfo", "SignaturePassword", "SignatureCertificate", "SignatureTSA", "UseReferenceXObject"
Probably there exist additional ones.