Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Global prevName As String
- Sub ExportToPNG()' oDoc, cFilename )
- BasicLibraries.loadLibrary("Tools")
- oDoc = ThisComponent
- cExportUrl = oDoc.getURL()
- oDocCtrl = oDoc.getCurrentController()
- oDrawPage = oDocCtrl.getCurrentPage()
- If Len(prevName) = 0 Then
- prevName = oDrawPage.getName()
- End If
- inputtedName = InputBox("Export PNG to:", "File name", prevName)' oDrawPage.getName())
- prevName = inputtedName
- cExportUrl = Tools.Strings.DirectoryNameoutofPath(ThisComponent.getURL(),"/") + "/" + inputtedName
- 'cExportUrl = Left( cExportUrl, Len(cExportUrl)-4 ) + "_" + oDrawPage.getName()
- Dim sFileUrl As String
- sFileUrl = "file://"+inputtedName 'ConvertToURL( cExportUrl + ".png" )
- oDrawPage = oDoc.getDrawPages().getByIndex(0)
- 'creating filter data
- Dim aFilterData (7) as new com.sun.star.beans.PropertyValue
- 'properties valid for all filters
- aFilterData(0).Name = "PixelWidth" '
- aFilterData(0).Value = 2480'oDrawPage.Width*(72/2540) 'convert => mm => inches => pixels (72 points per inch)
- aFilterData(1).Name = "PixelHeight"
- aFilterData(1).Value = 3509 'oDrawPage.Height*(72/2540) 'convert => mm => inches => pixels (72 points per inch)
- 'filter data for the image/jpeg MediaType
- 'aFilterData(2).Name ="Quality"
- 'aFilterData(2).Value = 90
- 'aFilterData(3).Name ="ColorMode"
- 'aFilterData(3).Value = 0
- 'filter data for the image/png MediaType
- aFilterData(2).Name ="Compression"
- aFilterData(2).Value = 9
- aFilterData(3).Name ="Interlaced"
- aFilterData(3).Value = 0
- 'filter data for the image/gif MediaType
- 'aFilterData(2).Name ="Translucent"
- 'aFilterData(2).Value = true
- 'aFilterData(3).Name ="Interlaced"
- 'aFilterData(3).Value = 0
- 'filter data for the image/bmp MediaType
- 'aFilterData(2).Name ="Color"
- 'aFilterData(2).Value = 7
- 'aFilterData(3).Name ="ExportMode"
- 'aFilterData(3).Value = 0
- 'aFilterData(4).Name ="Resolution"
- 'aFilterData(4).Value = 300
- 'aFilterData(5).Name ="RLE_Coding"
- 'aFilterData(5).Value = true
- 'aFilterData(6).Name ="LogicalWidth"
- 'aFilterData(6).Value = 2000
- 'aFilterData(7).Name ="LogicalHeight"
- 'aFilterData(7).Value = 2000
- Dim aArgs (2) as new com.sun.star.beans.PropertyValue
- aArgs(0).Name = "MediaType"
- aArgs(0).Value = "image/png"
- aArgs(1).Name = "URL"
- aArgs(1).Value = sFileUrl
- aArgs(2).Name = "FilterData"
- aArgs(2).Value = aFilterData()
- xExporter = createUnoService( "com.sun.star.drawing.GraphicExportFilter" )
- xExporter.setSourceDocument( oDrawPage )
- xExporter.filter( aArgs() )
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement