Export Writer page as jpeg

Creating a macro - Writing a Script - Using the API

Export Writer page as jpeg

Postby eBookLuke » Thu Aug 01, 2013 5:01 pm

Hi all,

I need to export the first page of a Writer document as jpeg, via Basic macro, in the same way I can do it by using the menu File>Export and choosing "jpeg" as filetype.

I found this code, but doesn't works with Writer:

Code: Select all   Expand viewCollapse view
Sub ExportJPG
   Dim Props(1) as New com.sun.star.beans.PropertyValue
   oSM = GetProcessServiceManager
   ExportSrv = oSM.createInstance("com.sun.star.drawing.GraphicExportFilter")
   oDPages = oTextDoc.getDrawPage()
   oPage = oDPages.getByIndex(1)
   ExportSrv.setSourceDocument(oTextDoc)
   Props(0).Name = "MediaType"
   Props(0).Value = "image/jpeg"
   Props(1).Name = "URL"
   Props(1).Value = "file:///C:/Exported.jpg"
   ExportSrv.filter(Props)
End Sub


Someone can help me?

Thanks

Luke
eBookLuke
 
Posts: 16
Joined: Tue Jan 12, 2010 12:19 am

Re: Export Writer page as jpeg

Postby F3K Total » Sat Aug 03, 2013 3:18 pm

Hi,
eBookLuke wrote:Writer document as jpeg, via Basic macro, in the same way I can do it by using the menu File>Export and choosing "jpeg" as filetype

For sure?
I can't find "jpeg" as an export Option in Writer:
x.png
x.png (6.18 KiB) Viewed 2673 times
That's all
R
    MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
    my current system
  • Windows 7 OOo, AOO, LOLinux Mint OOo, AOO, LO
F3K Total
Volunteer
 
Posts: 939
Joined: Fri Dec 16, 2011 8:20 pm

Re: Export Writer page as jpeg

Postby eBookLuke » Sun Aug 04, 2013 8:49 pm

True, I confused Apache OpenOffice with LibreOffice that has this feature… :(

Anyway, suggestions about exporting Writer pages in jpg?
OpenOffice 3.1.1 & 4.0 on MacOS 10.9.4
http://writer2epub.it/en
eBookLuke
 
Posts: 16
Joined: Tue Jan 12, 2010 12:19 am

Re: Export Writer page as jpeg

Postby Ahham » Tue Nov 12, 2019 2:11 pm

Hello,

for me it works: :D in draws

Code: Select all   Expand viewCollapse view
Sub ExportJPG
Dim oDPages As Object
dim oDoc
Dim oSm
dim ExportSrv
dim oPage
Dim URL As String
   Dim Props(1) as New com.sun.star.beans.PropertyValue
   oDoc = ThisComponent
   oSM = GetProcessServiceManager
   ExportSrv = oSM.createInstance("com.sun.star.drawing.GraphicExportFilter")
   oPage = oDoc.DrawPages(0)
   ExportSrv.setSourceDocument(oPage)
   URL = "C:\Example\Exported2.jpg"
   Props(0).Name = "MediaType"
   Props(0).Value = "image/jpeg"
   Props(1).Name = "URL"
   Props(1).Value = ConvertToUrl(URL)
   ExportSrv.filter(Props)
End Sub
Attachments
Exported2.jpg
OpenOffice 4.1.5
Ahham
 
Posts: 1
Joined: Tue Nov 12, 2019 2:03 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests