Export Writer page as jpeg

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
eBookLuke
Posts: 16
Joined: Tue Jan 12, 2010 12:19 am

Export Writer page as jpeg

Post by eBookLuke »

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

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
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: Export Writer page as jpeg

Post by F3K Total »

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 4478 times
That's all
R
  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
eBookLuke
Posts: 16
Joined: Tue Jan 12, 2010 12:19 am

Re: Export Writer page as jpeg

Post by eBookLuke »

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
Ahham
Posts: 1
Joined: Tue Nov 12, 2019 2:03 pm

Re: Export Writer page as jpeg

Post by Ahham »

Hello,

for me it works: :D in draws

Code: Select all

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
Post Reply