Convert pdf with visual basic OpenOffice Calc

Discuss the spreadsheet application
Post Reply
visomes
Posts: 11
Joined: Mon Aug 14, 2017 3:50 pm

Convert pdf with visual basic OpenOffice Calc

Post 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
Open office 4.3.1
User avatar
Zizi64
Volunteer
Posts: 11358
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: convert pdf with visual basic openOffice Calc

Post by Zizi64 »

using visual basic.net?
The StarBasic - embedded in the AOO/LO - is not appropriate for you?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
visomes
Posts: 11
Joined: Mon Aug 14, 2017 3:50 pm

Re: convert pdf with visual basic openOffice Calc

Post 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?
Open office 4.3.1
User avatar
Zizi64
Volunteer
Posts: 11358
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: convert pdf with visual basic openOffice Calc

Post 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.)
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
RoryOF
Moderator
Posts: 34611
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: convert pdf with visual basic openOffice Calc

Post by RoryOF »

Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Lupp
Volunteer
Posts: 3548
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: convert pdf with visual basic openOffice Calc

Post 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.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Post Reply