You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openoffice.apache.org by Erik Wigforss <er...@gmail.com> on 2012/05/03 15:44:12 UTC
[Rendering] Trying to render text page to a bitmap
Hi,
I'm trying to render a page to a bitmap and I don't get it working. Drawing
primitives works but not render a document.
Do anyone know how to do this?
Here is my code:
public static BufferedImage makeThumb(File inFile) throws IOException,
BootstrapException, IllegalArgumentException, Exception,
java.io.IOException {
XComponentLoader xCompLoader =
OfficeConnection.getConnection().getXComponentLoader();
PropertyValue[] loadProps = new PropertyValue[2];
loadProps[0] = OfficeTools.makeProperty("ReadOnly", Boolean.TRUE);
loadProps[1] = OfficeTools.makeProperty("Hidden", Boolean.TRUE);
XComponent xDoc =
xCompLoader.loadComponentFromURL(OfficeTools.makeOpenOfficeUrl(inFile.getAbsolutePath()),
"_blank", 0, loadProps);
XRenderable xRender =
(XRenderable)UnoRuntime.queryInterface(XRenderable.class, xDoc);
if (xRender != null) {
System.out.println("Is Renderable");
XDevice xDevice =
OfficeConnection.getConnection().getXToolkit().createScreenCompatibleDevice(1024,
1024);
PropertyValue[] renderProps = new PropertyValue[2];
renderProps[0] = OfficeTools.makeProperty("RenderDevive", xDevice);
renderProps[1] = OfficeTools.makeProperty("PageRange", "1");
xRender.render(0, xDoc, renderProps);
XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024);
if (xBitmap != null)
return ImageIO.read(new ByteArrayInputStream(xBitmap.getDIB()));
else
System.out.println("No bitmap created!");
} else {
System.out.println("Not Renderable");
}
return null;
}
Thanks in advance,
Erik Wigforss
Re: [Rendering] Trying to render text page to a bitmap
Posted by Fernand Vanrie <so...@pmgroup.be>.
Ariel ,
Very instructive, copied to my learning stuff, thansk
i pointed Eric to a other technic, opening the doc in "preview" mode in
a frame based on a new created window in a filepicker dialog.
Principle parts of the code
Sub PreviewWindowLoadOOFile(sUrl as String)
oPreviewWindow = InstallNewPreviewWindow(oFPickerDialog.Window, 0)
oFrame = createUnoService("com.sun.star.frame.Frame")
oFrame.initialize(oPreviewWindow)
Dim aProps(0) As New com.sun.star.beans.PropertyValue
aProps(0).Name = "Preview"
aProps(0).Value = true
oPreviewDoc = oFrame.loadComponentFromURL(sUrl, "", 0, aProps())
end sub
function InstallNewPreviewWindow(oWin as Object, lWinAttrs as Long) as
Object
' Create a window descriptor and set up its properties
Dim aDescriptor As New com.sun.star.awt.WindowDescriptor
aDescriptor.Type = com.sun.star.awt.WindowClass.SIMPLE
aDescriptor.Parent = oWin
aDescriptor.Bounds = oWin.Windows(lLastWindowAtStart).PosSize
aDescriptor.WindowAttributes = com.sun.star.awt.WindowAttribute.SHOW
or lWinAttrs
oToolkit = createUnoService("com.sun.star.awt.Toolkit")
InstallNewPreviewWindow = oToolkit.createWindow(aDescriptor)
end function
Greetz
Fernand
> REM ***** BASIC *****
>
> Option Explicit
>
> Sub Main
> GlobalScope.BasicLibraries.loadLibrary("Tools")
> Dim oDoc as Object
> oDoc = ThisComponent
>
>
> If HasUnoInterfaces(oDoc, "com.sun.star.view.XRenderable") Then
> Dim sBaseURL as String
> sBaseURL = DirectoryNameOutOfPath(oDoc.getURL(), "/")
>
> Dim oSFA as Object
> oSFA = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
> Dim oGraphicProvider as Object
> oGraphicProvider = CreateUnoService("com.sun.star.graphic.GraphicProvider")
>
> Dim oController as Object
> Dim oUnitConverter as Object
> oController = oDoc.getCurrentController()
> oUnitConverter = oController.getFrame().getComponentWindow()
>
> Dim oSelection as Object
> ' it could be the whole document
> oSelection = oDoc
>
> ' or the selection
> 'Dim oTextCursor as Object
> 'oTextCursor = oDoc.getText().createTextCursorByRange(oDoc.getText().getStart())
> 'oTextCursor.goToRange(oDoc.getText().getEnd(), True)
> 'oController.select(oTextCursor)
> 'oSelection = oController.getSelection()
>
> Dim oDevice as Object
> Dim aRenderOptions(5) as New com.sun.star.beans.PropertyValue
> aRenderOptions(0).Name = "RenderDevice"
> aRenderOptions(0).Value = oDevice
> aRenderOptions(1).Name = "ExportNotesPages"
> aRenderOptions(1).Value = False
> aRenderOptions(2).Name = "IsFirstPage"
> aRenderOptions(2).Value = True
> aRenderOptions(3).Name = "IsLastPage"
> aRenderOptions(3).Value = False
> aRenderOptions(4).Name = "IsSkipEmptyPages"
> aRenderOptions(4).Value = True
> aRenderOptions(5).Name = "PageRange"
> aRenderOptions(5).Value = ""
>
>
> Dim nPageCount as Integer
> nPageCount = oDoc.getRendererCount( oSelection, aRenderOptions )
> If nPageCount> 0 Then
> Dim oToolkit as Object
> oToolkit = CreateUnoService("com.sun.star.awt.Toolkit")
>
> Dim oRenderer as Object
> Dim oPageSize as Object
> Dim i%
> Dim sURL$
>
> While nPageCount> 0
> nPageCount = nPageCount - 1
> oRenderer = oDoc.getRenderer(nPageCount, oSelection, aRenderOptions)
> For i = 0 To UBound(oRenderer)
> If oRenderer(i).Name = "PageSize" Then
> oPageSize = oRenderer(i).Value
> Exit For
> End If
> Next
>
> Dim oDeviceSize as Object
> oDeviceSize = oUnitConverter.convertSizeToPixel(oPageSize, com.sun.star.util.MeasureUnit.MM_100TH)
> oDevice = oToolkit.createScreenCompatibleDevice( oDeviceSize.Width, oDeviceSize.Height)
> aRenderOptions(0).Value = oDevice
> oDoc.render( nPageCount, oSelection, aRenderOptions)
>
> Dim oBitmap as Object
> oBitmap = oDevice.createBitmap( 0, 0, oDevice.Info.Width,oDevice.Info.Height)
>
> sURL = sBaseURL + "/" + CStr(nPageCount) + ".png"
> If oSFA.exists(sURL) Then oSFA.kill(sURL)
> StoreBitmapToURL(oGraphicProvider, oBitmap, sURL)
> Wend
> End If
> End If
> End Sub
>
> Sub StoreBitmapToURL(oGraphicProvider, oBitmap, sURL)
> Dim oMediaProperties(0) as New com.sun.star.beans.PropertyValue
> oMediaProperties(0).Name = "Bitmap"
> oMediaProperties(0).Value = oBitmap
>
> Dim oGraphic as Object
> oGraphic = oGraphicProvider.queryGraphic(oMediaProperties)
>
> If NOT IsNull(oGraphic) Then
> Dim oMediaPropertiesOut(2) as New com.sun.star.beans.PropertyValue
> oMediaPropertiesOut(0).Name = "URL"
> oMediaPropertiesOut(0).Value = sURL
> oMediaPropertiesOut(1).Name = "MimeType"
> oMediaPropertiesOut(1).Value = "image/png"
>
> oGraphicProvider.storeGraphic(oGraphic, oMediaPropertiesOut)
> End If
> End Sub
Re: [Rendering] Trying to render text page to a bitmap
Posted by Ariel Constenla-Haile <ar...@apache.org>.
Hi Erik,
On Wed, May 30, 2012 at 11:20:23AM +0200, Erik Wigforss wrote:
> Hi,
>
> Thanks for the code but it doesn't work.
>
> Heres my code to anser every question one will ever have about ooo.
>
> Sub TheAnswerForEveryting()
>
> If isDepressed() Then
> doNothing()
> ElseIf isHappy() Then
> doSomething()
> ElseIf isHatred() Then
> crashForNoReason()
> ElseIf isPolite() Then
> throwAnError()
> Else
> waitForOneSecondAndTryAgain()
> End If
> End Sub
That made me laugh :)
You can find a way how to use XRenderable here:
http://people.apache.org/~arielch/api/XRenderable/
The Basic code in the Writer document produces the two PNG images.
REM ***** BASIC *****
Option Explicit
Sub Main
GlobalScope.BasicLibraries.loadLibrary("Tools")
Dim oDoc as Object
oDoc = ThisComponent
If HasUnoInterfaces(oDoc, "com.sun.star.view.XRenderable") Then
Dim sBaseURL as String
sBaseURL = DirectoryNameOutOfPath(oDoc.getURL(), "/")
Dim oSFA as Object
oSFA = CreateUnoService("com.sun.star.ucb.SimpleFileAccess")
Dim oGraphicProvider as Object
oGraphicProvider = CreateUnoService("com.sun.star.graphic.GraphicProvider")
Dim oController as Object
Dim oUnitConverter as Object
oController = oDoc.getCurrentController()
oUnitConverter = oController.getFrame().getComponentWindow()
Dim oSelection as Object
' it could be the whole document
oSelection = oDoc
' or the selection
'Dim oTextCursor as Object
'oTextCursor = oDoc.getText().createTextCursorByRange(oDoc.getText().getStart())
'oTextCursor.goToRange(oDoc.getText().getEnd(), True)
'oController.select(oTextCursor)
'oSelection = oController.getSelection()
Dim oDevice as Object
Dim aRenderOptions(5) as New com.sun.star.beans.PropertyValue
aRenderOptions(0).Name = "RenderDevice"
aRenderOptions(0).Value = oDevice
aRenderOptions(1).Name = "ExportNotesPages"
aRenderOptions(1).Value = False
aRenderOptions(2).Name = "IsFirstPage"
aRenderOptions(2).Value = True
aRenderOptions(3).Name = "IsLastPage"
aRenderOptions(3).Value = False
aRenderOptions(4).Name = "IsSkipEmptyPages"
aRenderOptions(4).Value = True
aRenderOptions(5).Name = "PageRange"
aRenderOptions(5).Value = ""
Dim nPageCount as Integer
nPageCount = oDoc.getRendererCount( oSelection, aRenderOptions )
If nPageCount > 0 Then
Dim oToolkit as Object
oToolkit = CreateUnoService("com.sun.star.awt.Toolkit")
Dim oRenderer as Object
Dim oPageSize as Object
Dim i%
Dim sURL$
While nPageCount > 0
nPageCount = nPageCount - 1
oRenderer = oDoc.getRenderer(nPageCount, oSelection, aRenderOptions)
For i = 0 To UBound(oRenderer)
If oRenderer(i).Name = "PageSize" Then
oPageSize = oRenderer(i).Value
Exit For
End If
Next
Dim oDeviceSize as Object
oDeviceSize = oUnitConverter.convertSizeToPixel(oPageSize, com.sun.star.util.MeasureUnit.MM_100TH)
oDevice = oToolkit.createScreenCompatibleDevice( oDeviceSize.Width, oDeviceSize.Height)
aRenderOptions(0).Value = oDevice
oDoc.render( nPageCount, oSelection, aRenderOptions)
Dim oBitmap as Object
oBitmap = oDevice.createBitmap( 0, 0, oDevice.Info.Width,oDevice.Info.Height)
sURL = sBaseURL + "/" + CStr(nPageCount) + ".png"
If oSFA.exists(sURL) Then oSFA.kill(sURL)
StoreBitmapToURL(oGraphicProvider, oBitmap, sURL)
Wend
End If
End If
End Sub
Sub StoreBitmapToURL(oGraphicProvider, oBitmap, sURL)
Dim oMediaProperties(0) as New com.sun.star.beans.PropertyValue
oMediaProperties(0).Name = "Bitmap"
oMediaProperties(0).Value = oBitmap
Dim oGraphic as Object
oGraphic = oGraphicProvider.queryGraphic(oMediaProperties)
If NOT IsNull(oGraphic) Then
Dim oMediaPropertiesOut(2) as New com.sun.star.beans.PropertyValue
oMediaPropertiesOut(0).Name = "URL"
oMediaPropertiesOut(0).Value = sURL
oMediaPropertiesOut(1).Name = "MimeType"
oMediaPropertiesOut(1).Value = "image/png"
oGraphicProvider.storeGraphic(oGraphic, oMediaPropertiesOut)
End If
End Sub
Regards
--
Ariel Constenla-Haile
La Plata, Argentina
Re: [Rendering] Trying to render text page to a bitmap
Posted by Fernand Vanrie <so...@pmgroup.be>.
On 30/05/2012 15:58, Erik Wigforss wrote:
> I get all kinds of errors. Errors I shouldn't even get. I have tried in AOO
> and LO. Got it working in LO but very unstable crashing for no reason at
> all every time. In AOO it don't work at all even if it works in LO
> unstably. It's so wierd and totally random.
>
> Now this line in "Function getGraphFromUrl(sFileURL as String) As Object"
> don't work:
> ---
> Dim oProvider As Object
> oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
> Dim oPropsIN(0 to 0) As Object
> oPropsIN(0) = new com.sun.star.beans.PropertyValue
> oPropsIN(0).Name = "URL"
> oPropsIN(0).Value = sFileURL
> getGraphFromUrl = oProvider.queryGraphic(oPropsIN())
> '<------------------------ Don't working
you need the function :-)
function getGraphFromUrl(sFileURL as String) as Object
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim oPropsIN(0)as new com.sun.star.beans.PropertyValue
oPropsIN(0).Name = "URL"
oPropsIN(0).Value = sFileURL
getGraphFromUrl = oProvider.queryGraphic(oPropsIN())
end function
>
> ---
> I have changed some line like the props setup lines beacuse they didn't
> work at all before.
>
> 2012/5/30 Fernand Vanrie<so...@pmgroup.be>
>
>> Erik,
>>
>> wath part of the code is not working ?
>>
>>> No the code is not working for me and I seek help.
>>> I want to have help with thumbnails and previews thats quick and stable,
>>> And the preview that exists is just too slow and unstable.
>>>
>>> Did you know that MS Wordpad is creating the thumbnails for OOo but Ms
>>> Office have no thumbnails? And the opposite for preview.
>>>
>>> ---
>>> <http://openoffice.2283327.n4.****
>>> nabble.com/api-dev-Open-a-****file-with-standard-****
>>> application-from-dialog-*<http://nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*>
>>> *td3067760.html<
>>> http://openoffice.2283327.n4.**nabble.com/api-dev-Open-a-**
>>> file-with-standard-**application-from-dialog-**td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>>> --
>>>
>>> 2012/5/30 Fernand Vanrie<so...@pmgroup.be>
>>>
>>> On 30/05/2012 11:20, Erik Wigforss wrote:
>>>> Hi,
>>>>> Thanks for the code but it doesn't work.
>>>>>
>>>>> for you i suppose :-)
>>>> Heres my code to anser every question one will ever have about ooo.
>>>>> Sub TheAnswerForEveryting()
>>>>>
>>>>> If isDepressed() Then
>>>>> doNothing()
>>>>> ElseIf isHappy() Then
>>>>> doSomething()
>>>>> ElseIf isHatred() Then
>>>>> crashForNoReason()
>>>>> ElseIf isPolite() Then
>>>>> throwAnError()
>>>>> Else
>>>>> waitForOneSecondAndTryAgain()
>>>>> End If
>>>>> End Sub
>>>>>
>>>>> Erik
>>>>>
>>>>> 2012/5/3 Fernand Vanrie<so...@pmgroup.be>
>>>>>
>>>>> Erik ,
>>>>>
>>>>>> With BASIC it can been done
>>>>>> have a look at this thread<http://openoffice.****2283327.n4.<
>>>>>> http://openoffice.**2283327.n4<http://openoffice.2283327.n4>.>
>>>>>> **
>>>>>> nabble.com/api-dev-Open-a-******file-with-standard-****<http://nabble.com/api-dev-Open-a-****file-with-standard-****>
>>>>>> application-from-dialog-*<http**://nabble.com/api-dev-Open-a-***
>>>>>> *file-with-standard-****application-from-dialog-*<http://nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*>
>>>>>> *td3067760.html<http://****openoffice.2283327.n4.nabble.****
>>>>>> com/api-dev-Open-a-file-with-****standard-application-from-**
>>>>>> dialog-td3067760.html<http://**openoffice.2283327.n4.nabble.**
>>>>>> com/api-dev-Open-a-file-with-**standard-application-from-**
>>>>>> dialog-td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>>>>>> hope it helps
>>>>>>
>>>>>> Fernand
>>>>>>
>>>>>> Hi, I'm trying to render a page to a bitmap and I don't get it working.
>>>>>> Drawing primitives works but not render a document. Do anyone know how
>>>>>> to
>>>>>> do this? Here is my code: public static BufferedImage makeThumb(File
>>>>>> inFile) throws IOException, BootstrapException,
>>>>>> IllegalArgumentException,
>>>>>> Exception, java.io.IOException { XComponentLoader xCompLoader =
>>>>>> OfficeConnection.******getConnection().******getXComponentLoader();
>>>>>> PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] =
>>>>>> OfficeTools.makeProperty("******ReadOnly", Boolean.TRUE);
>>>>>> loadProps[1] =
>>>>>> OfficeTools.makeProperty("******Hidden", Boolean.TRUE); XComponent
>>>>>> xDoc =
>>>>>> xCompLoader.******loadComponentFromURL(******
>>>>>> OfficeTools.makeOpenOfficeUrl(***
>>>>>> ***inFile.getAbsolutePath()),
>>>>>> "_blank", 0, loadProps); XRenderable xRender =
>>>>>> (XRenderable)UnoRuntime.**
>>>>>> queryInterface(XRenderable.******class, xDoc); if (xRender != null) {
>>>>>> System.out.println("Is Renderable"); XDevice xDevice =
>>>>>> OfficeConnection.**
>>>>>> getConnection().getXToolkit().**********createScreenCompatibleDevice(*
>>>>>> ****
>>>>>> *1024,
>>>>>> 1024); PropertyValue[] renderProps = new PropertyValue[2];
>>>>>> renderProps[0] =
>>>>>> OfficeTools.makeProperty("******RenderDevive", xDevice);
>>>>>> renderProps[1] =
>>>>>> OfficeTools.makeProperty("******PageRange", "1"); xRender.render(0,
>>>>>> xDoc,
>>>>>> renderProps); XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024);
>>>>>> if
>>>>>> (xBitmap != null) return ImageIO.read(new
>>>>>> ByteArrayInputStream(xBitmap.*
>>>>>> ***getDIB()));
>>>>>> else System.out.println("No bitmap created!"); } else {
>>>>>> System.out.println("Not Renderable"); } return null; } Thanks in
>>>>>> advance,
>>>>>> Erik Wigforss
>>>>>>
>>>>>>
>>>>>>
>>>>>>
Re: [Rendering] Trying to render text page to a bitmap
Posted by Erik Wigforss <er...@gmail.com>.
I get all kinds of errors. Errors I shouldn't even get. I have tried in AOO
and LO. Got it working in LO but very unstable crashing for no reason at
all every time. In AOO it don't work at all even if it works in LO
unstably. It's so wierd and totally random.
Now this line in "Function getGraphFromUrl(sFileURL as String) As Object"
don't work:
---
Dim oProvider As Object
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim oPropsIN(0 to 0) As Object
oPropsIN(0) = new com.sun.star.beans.PropertyValue
oPropsIN(0).Name = "URL"
oPropsIN(0).Value = sFileURL
getGraphFromUrl = oProvider.queryGraphic(oPropsIN())
'<------------------------ Don't working
---
I have changed some line like the props setup lines beacuse they didn't
work at all before.
2012/5/30 Fernand Vanrie <so...@pmgroup.be>
> Erik,
>
> wath part of the code is not working ?
>
>> No the code is not working for me and I seek help.
>> I want to have help with thumbnails and previews thats quick and stable,
>> And the preview that exists is just too slow and unstable.
>>
>> Did you know that MS Wordpad is creating the thumbnails for OOo but Ms
>> Office have no thumbnails? And the opposite for preview.
>>
>> ---
>> <http://openoffice.2283327.n4.****
>> nabble.com/api-dev-Open-a-****file-with-standard-****
>> application-from-dialog-*<http://nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*>
>> *td3067760.html<
>> http://openoffice.2283327.n4.**nabble.com/api-dev-Open-a-**
>> file-with-standard-**application-from-dialog-**td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>> --
>>
>> 2012/5/30 Fernand Vanrie<so...@pmgroup.be>
>>
>> On 30/05/2012 11:20, Erik Wigforss wrote:
>>>
>>> Hi,
>>>>
>>>> Thanks for the code but it doesn't work.
>>>>
>>>> for you i suppose :-)
>>>
>>> Heres my code to anser every question one will ever have about ooo.
>>>>
>>>> Sub TheAnswerForEveryting()
>>>>
>>>> If isDepressed() Then
>>>> doNothing()
>>>> ElseIf isHappy() Then
>>>> doSomething()
>>>> ElseIf isHatred() Then
>>>> crashForNoReason()
>>>> ElseIf isPolite() Then
>>>> throwAnError()
>>>> Else
>>>> waitForOneSecondAndTryAgain()
>>>> End If
>>>> End Sub
>>>>
>>>> Erik
>>>>
>>>> 2012/5/3 Fernand Vanrie<so...@pmgroup.be>
>>>>
>>>> Erik ,
>>>>
>>>>> With BASIC it can been done
>>>>> have a look at this thread<http://openoffice.****2283327.n4.<
>>>>> http://openoffice.**2283327.n4 <http://openoffice.2283327.n4>.>
>>>>> **
>>>>> nabble.com/api-dev-Open-a-******file-with-standard-****<http://nabble.com/api-dev-Open-a-****file-with-standard-****>
>>>>> application-from-dialog-*<http**://nabble.com/api-dev-Open-a-***
>>>>> *file-with-standard-****application-from-dialog-*<http://nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*>
>>>>> >
>>>>> *td3067760.html<http://****openoffice.2283327.n4.nabble.****
>>>>> com/api-dev-Open-a-file-with-****standard-application-from-**
>>>>> dialog-td3067760.html<http://**openoffice.2283327.n4.nabble.**
>>>>> com/api-dev-Open-a-file-with-**standard-application-from-**
>>>>> dialog-td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>>>>> >
>>>>> hope it helps
>>>>>
>>>>> Fernand
>>>>>
>>>>> Hi, I'm trying to render a page to a bitmap and I don't get it working.
>>>>> Drawing primitives works but not render a document. Do anyone know how
>>>>> to
>>>>> do this? Here is my code: public static BufferedImage makeThumb(File
>>>>> inFile) throws IOException, BootstrapException,
>>>>> IllegalArgumentException,
>>>>> Exception, java.io.IOException { XComponentLoader xCompLoader =
>>>>> OfficeConnection.******getConnection().******getXComponentLoader();
>>>>> PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] =
>>>>> OfficeTools.makeProperty("******ReadOnly", Boolean.TRUE);
>>>>> loadProps[1] =
>>>>> OfficeTools.makeProperty("******Hidden", Boolean.TRUE); XComponent
>>>>> xDoc =
>>>>> xCompLoader.******loadComponentFromURL(******
>>>>> OfficeTools.makeOpenOfficeUrl(***
>>>>> ***inFile.getAbsolutePath()),
>>>>> "_blank", 0, loadProps); XRenderable xRender =
>>>>> (XRenderable)UnoRuntime.**
>>>>> queryInterface(XRenderable.******class, xDoc); if (xRender != null) {
>>>>> System.out.println("Is Renderable"); XDevice xDevice =
>>>>> OfficeConnection.**
>>>>> getConnection().getXToolkit().**********createScreenCompatibleDevice(*
>>>>> ****
>>>>> *1024,
>>>>> 1024); PropertyValue[] renderProps = new PropertyValue[2];
>>>>> renderProps[0] =
>>>>> OfficeTools.makeProperty("******RenderDevive", xDevice);
>>>>> renderProps[1] =
>>>>> OfficeTools.makeProperty("******PageRange", "1"); xRender.render(0,
>>>>> xDoc,
>>>>> renderProps); XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024);
>>>>> if
>>>>> (xBitmap != null) return ImageIO.read(new
>>>>> ByteArrayInputStream(xBitmap.*
>>>>> ***getDIB()));
>>>>> else System.out.println("No bitmap created!"); } else {
>>>>> System.out.println("Not Renderable"); } return null; } Thanks in
>>>>> advance,
>>>>> Erik Wigforss
>>>>>
>>>>>
>>>>>
>>>>>
>
Re: [Rendering] Trying to render text page to a bitmap
Posted by Fernand Vanrie <so...@pmgroup.be>.
Erik,
wath part of the code is not working ?
> No the code is not working for me and I seek help.
> I want to have help with thumbnails and previews thats quick and stable,
> And the preview that exists is just too slow and unstable.
>
> Did you know that MS Wordpad is creating the thumbnails for OOo but Ms
> Office have no thumbnails? And the opposite for preview.
>
> ---
> <http://openoffice.2283327.n4.**
> nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*
> *td3067760.html<
> http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html
> --
>
> 2012/5/30 Fernand Vanrie<so...@pmgroup.be>
>
>> On 30/05/2012 11:20, Erik Wigforss wrote:
>>
>>> Hi,
>>>
>>> Thanks for the code but it doesn't work.
>>>
>> for you i suppose :-)
>>
>>> Heres my code to anser every question one will ever have about ooo.
>>>
>>> Sub TheAnswerForEveryting()
>>>
>>> If isDepressed() Then
>>> doNothing()
>>> ElseIf isHappy() Then
>>> doSomething()
>>> ElseIf isHatred() Then
>>> crashForNoReason()
>>> ElseIf isPolite() Then
>>> throwAnError()
>>> Else
>>> waitForOneSecondAndTryAgain()
>>> End If
>>> End Sub
>>>
>>> Erik
>>>
>>> 2012/5/3 Fernand Vanrie<so...@pmgroup.be>
>>>
>>> Erik ,
>>>> With BASIC it can been done
>>>> have a look at this thread<http://openoffice.**2283327.n4.<http://openoffice.2283327.n4.>
>>>> **
>>>> nabble.com/api-dev-Open-a-****file-with-standard-****
>>>> application-from-dialog-*<http://nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*>
>>>> *td3067760.html<http://**openoffice.2283327.n4.nabble.**
>>>> com/api-dev-Open-a-file-with-**standard-application-from-**
>>>> dialog-td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>>>> hope it helps
>>>>
>>>> Fernand
>>>>
>>>> Hi, I'm trying to render a page to a bitmap and I don't get it working.
>>>> Drawing primitives works but not render a document. Do anyone know how to
>>>> do this? Here is my code: public static BufferedImage makeThumb(File
>>>> inFile) throws IOException, BootstrapException, IllegalArgumentException,
>>>> Exception, java.io.IOException { XComponentLoader xCompLoader =
>>>> OfficeConnection.****getConnection().****getXComponentLoader();
>>>> PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] =
>>>> OfficeTools.makeProperty("****ReadOnly", Boolean.TRUE); loadProps[1] =
>>>> OfficeTools.makeProperty("****Hidden", Boolean.TRUE); XComponent xDoc =
>>>> xCompLoader.****loadComponentFromURL(****OfficeTools.makeOpenOfficeUrl(*
>>>> ***inFile.getAbsolutePath()),
>>>> "_blank", 0, loadProps); XRenderable xRender = (XRenderable)UnoRuntime.**
>>>> queryInterface(XRenderable.****class, xDoc); if (xRender != null) {
>>>> System.out.println("Is Renderable"); XDevice xDevice =
>>>> OfficeConnection.**
>>>> getConnection().getXToolkit().******createScreenCompatibleDevice(***
>>>> *1024,
>>>> 1024); PropertyValue[] renderProps = new PropertyValue[2];
>>>> renderProps[0] =
>>>> OfficeTools.makeProperty("****RenderDevive", xDevice); renderProps[1] =
>>>> OfficeTools.makeProperty("****PageRange", "1"); xRender.render(0, xDoc,
>>>> renderProps); XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024);
>>>> if
>>>> (xBitmap != null) return ImageIO.read(new ByteArrayInputStream(xBitmap.*
>>>> ***getDIB()));
>>>> else System.out.println("No bitmap created!"); } else {
>>>> System.out.println("Not Renderable"); } return null; } Thanks in advance,
>>>> Erik Wigforss
>>>>
>>>>
>>>>
Re: [Rendering] Trying to render text page to a bitmap
Posted by Erik Wigforss <er...@gmail.com>.
No the code is not working for me and I seek help.
I want to have help with thumbnails and previews thats quick and stable,
And the preview that exists is just too slow and unstable.
Did you know that MS Wordpad is creating the thumbnails for OOo but Ms
Office have no thumbnails? And the opposite for preview.
---
<http://openoffice.2283327.n4.**
nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*
*td3067760.html<
http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html
>
--
2012/5/30 Fernand Vanrie <so...@pmgroup.be>
> On 30/05/2012 11:20, Erik Wigforss wrote:
>
>> Hi,
>>
>> Thanks for the code but it doesn't work.
>>
> for you i suppose :-)
>
>> Heres my code to anser every question one will ever have about ooo.
>>
>> Sub TheAnswerForEveryting()
>>
>> If isDepressed() Then
>> doNothing()
>> ElseIf isHappy() Then
>> doSomething()
>> ElseIf isHatred() Then
>> crashForNoReason()
>> ElseIf isPolite() Then
>> throwAnError()
>> Else
>> waitForOneSecondAndTryAgain()
>> End If
>> End Sub
>>
>> Erik
>>
>> 2012/5/3 Fernand Vanrie<so...@pmgroup.be>
>>
>> Erik ,
>>> With BASIC it can been done
>>> have a look at this thread<http://openoffice.**2283327.n4.<http://openoffice.2283327.n4.>
>>> **
>>> nabble.com/api-dev-Open-a-****file-with-standard-****
>>> application-from-dialog-*<http://nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*>
>>> *td3067760.html<http://**openoffice.2283327.n4.nabble.**
>>> com/api-dev-Open-a-file-with-**standard-application-from-**
>>> dialog-td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>>> >
>>> hope it helps
>>>
>>> Fernand
>>>
>>> Hi, I'm trying to render a page to a bitmap and I don't get it working.
>>> Drawing primitives works but not render a document. Do anyone know how to
>>> do this? Here is my code: public static BufferedImage makeThumb(File
>>> inFile) throws IOException, BootstrapException, IllegalArgumentException,
>>> Exception, java.io.IOException { XComponentLoader xCompLoader =
>>> OfficeConnection.****getConnection().****getXComponentLoader();
>>> PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] =
>>> OfficeTools.makeProperty("****ReadOnly", Boolean.TRUE); loadProps[1] =
>>> OfficeTools.makeProperty("****Hidden", Boolean.TRUE); XComponent xDoc =
>>> xCompLoader.****loadComponentFromURL(****OfficeTools.makeOpenOfficeUrl(*
>>> ***inFile.getAbsolutePath()),
>>> "_blank", 0, loadProps); XRenderable xRender = (XRenderable)UnoRuntime.**
>>> queryInterface(XRenderable.****class, xDoc); if (xRender != null) {
>>> System.out.println("Is Renderable"); XDevice xDevice =
>>> OfficeConnection.**
>>> getConnection().getXToolkit().******createScreenCompatibleDevice(***
>>> *1024,
>>> 1024); PropertyValue[] renderProps = new PropertyValue[2];
>>> renderProps[0] =
>>> OfficeTools.makeProperty("****RenderDevive", xDevice); renderProps[1] =
>>> OfficeTools.makeProperty("****PageRange", "1"); xRender.render(0, xDoc,
>>> renderProps); XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024);
>>> if
>>> (xBitmap != null) return ImageIO.read(new ByteArrayInputStream(xBitmap.*
>>> ***getDIB()));
>>> else System.out.println("No bitmap created!"); } else {
>>> System.out.println("Not Renderable"); } return null; } Thanks in advance,
>>> Erik Wigforss
>>>
>>>
>>>
>
Re: [Rendering] Trying to render text page to a bitmap
Posted by Fernand Vanrie <so...@pmgroup.be>.
On 30/05/2012 11:20, Erik Wigforss wrote:
> Hi,
>
> Thanks for the code but it doesn't work.
for you i suppose :-)
>
> Heres my code to anser every question one will ever have about ooo.
>
> Sub TheAnswerForEveryting()
>
> If isDepressed() Then
> doNothing()
> ElseIf isHappy() Then
> doSomething()
> ElseIf isHatred() Then
> crashForNoReason()
> ElseIf isPolite() Then
> throwAnError()
> Else
> waitForOneSecondAndTryAgain()
> End If
> End Sub
>
> Erik
>
> 2012/5/3 Fernand Vanrie<so...@pmgroup.be>
>
>> Erik ,
>> With BASIC it can been done
>> have a look at this thread<http://openoffice.2283327.n4.**
>> nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*
>> *td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
>> hope it helps
>>
>> Fernand
>>
>> Hi, I'm trying to render a page to a bitmap and I don't get it working.
>> Drawing primitives works but not render a document. Do anyone know how to
>> do this? Here is my code: public static BufferedImage makeThumb(File
>> inFile) throws IOException, BootstrapException, IllegalArgumentException,
>> Exception, java.io.IOException { XComponentLoader xCompLoader =
>> OfficeConnection.**getConnection().**getXComponentLoader();
>> PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] =
>> OfficeTools.makeProperty("**ReadOnly", Boolean.TRUE); loadProps[1] =
>> OfficeTools.makeProperty("**Hidden", Boolean.TRUE); XComponent xDoc =
>> xCompLoader.**loadComponentFromURL(**OfficeTools.makeOpenOfficeUrl(**inFile.getAbsolutePath()),
>> "_blank", 0, loadProps); XRenderable xRender = (XRenderable)UnoRuntime.**
>> queryInterface(XRenderable.**class, xDoc); if (xRender != null) {
>> System.out.println("Is Renderable"); XDevice xDevice = OfficeConnection.**
>> getConnection().getXToolkit().**createScreenCompatibleDevice(**1024,
>> 1024); PropertyValue[] renderProps = new PropertyValue[2]; renderProps[0] =
>> OfficeTools.makeProperty("**RenderDevive", xDevice); renderProps[1] =
>> OfficeTools.makeProperty("**PageRange", "1"); xRender.render(0, xDoc,
>> renderProps); XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024); if
>> (xBitmap != null) return ImageIO.read(new ByteArrayInputStream(xBitmap.**getDIB()));
>> else System.out.println("No bitmap created!"); } else {
>> System.out.println("Not Renderable"); } return null; } Thanks in advance,
>> Erik Wigforss
>>
>>
Re: [Rendering] Trying to render text page to a bitmap
Posted by Erik Wigforss <er...@gmail.com>.
Hi,
Thanks for the code but it doesn't work.
Heres my code to anser every question one will ever have about ooo.
Sub TheAnswerForEveryting()
If isDepressed() Then
doNothing()
ElseIf isHappy() Then
doSomething()
ElseIf isHatred() Then
crashForNoReason()
ElseIf isPolite() Then
throwAnError()
Else
waitForOneSecondAndTryAgain()
End If
End Sub
Erik
2012/5/3 Fernand Vanrie <so...@pmgroup.be>
> Erik ,
> With BASIC it can been done
> have a look at this thread <http://openoffice.2283327.n4.**
> nabble.com/api-dev-Open-a-**file-with-standard-**application-from-dialog-*
> *td3067760.html<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
> >
>
> hope it helps
>
> Fernand
>
> Hi, I'm trying to render a page to a bitmap and I don't get it working.
> Drawing primitives works but not render a document. Do anyone know how to
> do this? Here is my code: public static BufferedImage makeThumb(File
> inFile) throws IOException, BootstrapException, IllegalArgumentException,
> Exception, java.io.IOException { XComponentLoader xCompLoader =
> OfficeConnection.**getConnection().**getXComponentLoader();
> PropertyValue[] loadProps = new PropertyValue[2]; loadProps[0] =
> OfficeTools.makeProperty("**ReadOnly", Boolean.TRUE); loadProps[1] =
> OfficeTools.makeProperty("**Hidden", Boolean.TRUE); XComponent xDoc =
> xCompLoader.**loadComponentFromURL(**OfficeTools.makeOpenOfficeUrl(**inFile.getAbsolutePath()),
> "_blank", 0, loadProps); XRenderable xRender = (XRenderable)UnoRuntime.**
> queryInterface(XRenderable.**class, xDoc); if (xRender != null) {
> System.out.println("Is Renderable"); XDevice xDevice = OfficeConnection.**
> getConnection().getXToolkit().**createScreenCompatibleDevice(**1024,
> 1024); PropertyValue[] renderProps = new PropertyValue[2]; renderProps[0] =
> OfficeTools.makeProperty("**RenderDevive", xDevice); renderProps[1] =
> OfficeTools.makeProperty("**PageRange", "1"); xRender.render(0, xDoc,
> renderProps); XBitmap xBitmap = xDevice.createBitmap(0, 0, 1024, 1024); if
> (xBitmap != null) return ImageIO.read(new ByteArrayInputStream(xBitmap.**getDIB()));
> else System.out.println("No bitmap created!"); } else {
> System.out.println("Not Renderable"); } return null; } Thanks in advance,
> Erik Wigforss
>
>
Re: [Rendering] Trying to render text page to a bitmap
Posted by Fernand Vanrie <so...@pmgroup.be>.
Erik ,
With BASIC it can been done
have a look at this thread
<http://openoffice.2283327.n4.nabble.com/api-dev-Open-a-file-with-standard-application-from-dialog-td3067760.html>
hope it helps
Fernand
Hi, I'm trying to render a page to a bitmap and I don't get it working.
Drawing primitives works but not render a document. Do anyone know how
to do this? Here is my code: public static BufferedImage makeThumb(File
inFile) throws IOException, BootstrapException,
IllegalArgumentException, Exception, java.io.IOException {
XComponentLoader xCompLoader =
OfficeConnection.getConnection().getXComponentLoader(); PropertyValue[]
loadProps = new PropertyValue[2]; loadProps[0] =
OfficeTools.makeProperty("ReadOnly", Boolean.TRUE); loadProps[1] =
OfficeTools.makeProperty("Hidden", Boolean.TRUE); XComponent xDoc =
xCompLoader.loadComponentFromURL(OfficeTools.makeOpenOfficeUrl(inFile.getAbsolutePath()),
"_blank", 0, loadProps); XRenderable xRender =
(XRenderable)UnoRuntime.queryInterface(XRenderable.class, xDoc); if
(xRender != null) { System.out.println("Is Renderable"); XDevice xDevice
=
OfficeConnection.getConnection().getXToolkit().createScreenCompatibleDevice(1024,
1024); PropertyValue[] renderProps = new PropertyValue[2];
renderProps[0] = OfficeTools.makeProperty("RenderDevive", xDevice);
renderProps[1] = OfficeTools.makeProperty("PageRange", "1");
xRender.render(0, xDoc, renderProps); XBitmap xBitmap =
xDevice.createBitmap(0, 0, 1024, 1024); if (xBitmap != null) return
ImageIO.read(new ByteArrayInputStream(xBitmap.getDIB())); else
System.out.println("No bitmap created!"); } else {
System.out.println("Not Renderable"); } return null; } Thanks in
advance, Erik Wigforss