| View previous topic :: View next topic |
| Author |
Message |
Beginner Guest
|
Posted: Fri Oct 31, 2003 5:17 am Post subject: Draw - exporting and printing |
|
|
Hello
I don 't understand the sdk api, so I hope that anyone can help me to solve my problem.
I am a beginner and try to program a makro that exports my current draw-sheet to jpg.
if it succeeds the previous saved file has to be printed out.
Is this possible?
This is needed cause my old printer cannot print out foreign-letters.
Thanks in advance.
Aho |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Oct 31, 2003 12:03 pm Post subject: |
|
|
The biggest challenge is to learn the API. Explore the Macros and API forum here and you'll find a wealth of information.
In the meantime try putting this code directly into the macro of a drawing document. Change the pathnames or printer queue names as appropriate.
| Code: | Sub Main
cDestFolder = "/home/danny/Desktop" ' for danny's Linux at home.
' cDestFolder = "c:\documents and settings\dbrewer\Desktop" ' for danny's WinXP at office.
cFilename = "Drawing"
oDrawDoc = ThisComponent
' Save the current document as an SXD file.
cURL = ConvertToURL( cDestFolder + "/" + cFilename + ".sxd" )
oDrawDoc.storeAsURL( cURL, Array() )
' Save the current document as an EPS file.
cURL = ConvertToURL( cDestFolder + "/" + cFilename + ".eps" )
oDrawDoc.storeToURL( cURL,_
Array( MakePropertyValue( "FilterName", "draw_eps_Export" ) ) )
' Save the current document as an PDF file.
cURL = ConvertToURL( cDestFolder + "/" + cFilename + ".pdf" )
oDrawDoc.storeToURL( cURL,_
Array( MakePropertyValue( "FilterName", "draw_pdf_Export" ) ) )
' Save the current document as an JPG file.
cURL = ConvertToURL( cDestFolder + "/" + cFilename + ".jpg" )
oDrawDoc.storeToURL( cURL,_
Array( MakePropertyValue( "FilterName", "draw_jpg_Export" ) ) )
' Save the current document as an PNG file.
cURL = ConvertToURL( cDestFolder + "/" + cFilename + ".png" )
oDrawDoc.storeToURL( cURL,_
Array( MakePropertyValue( "FilterName", "draw_png_Export" ) ) )
' Save the current document as an SVG file.
cURL = ConvertToURL( cDestFolder + "/" + cFilename + ".svg" )
oDrawDoc.storeToURL( cURL,_
Array( MakePropertyValue( "FilterName", "draw_svg_Export" ) ) )
' Decide which print queue to use -- on Windows.
' Specify any combination of properties from the
' com.sun.star.view.PrinterDescriptor.
' This step is actually unnecessary.
' oDrawDoc.setPrinter( Array(_
' MakePropertyValue( "Name", "\\DC01\HP 5si" ) ) )
' Decide which print queue to use -- on Linux.
' Specify any combination of properties from the
' com.sun.star.view.PrinterDescriptor.
' This step is actually unnecessary.
oDrawDoc.setPrinter( Array(_
MakePropertyValue( "Name", "lp" ) ) )
' Print the document the easy way.
' oDrawDoc.print( Array() )
' Print the document the exciting way.
' Specify any combination of properties from the
' service com.sun.star.view.PrintOptions.
oDrawDoc.print( Array(_
MakePropertyValue( "CopyCount", 1 ),_
MakePropertyValue( "Collate", True ),_
MakePropertyValue( "Pages", "1-4;10" ) ) )
End Sub
' Create and return a new com.sun.star.beans.PropertyValue.
'
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
|
_________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Beginner Guest
|
Posted: Mon Nov 03, 2003 7:24 am Post subject: Export works well |
|
|
Hello
Thank you very much for your reply.
It brings me a step forward. The Export works well. But I have still a problem with the printing.
What I want is, to print the exported JPG-File, not the current Draw-Document.
Are their possiblities?
I tried:
| Code: |
sub TestExport
myDoc = thisComponent
Dim myProps(0) as New com.sun.star.beans.PropertyValue
Dim iNumber as integer
sURL = "file:///C:/temp/test.jpg"
myProps(0).name="FilterName"
myProps(0).value="draw_jpg_Export"
myDoc.storeToURL(sURL, myProps())
Dim oProp()
' open previous saved document
oNewDoc=StarDesktop.loadComponentFromURL(sURL, "_blank", 0, oProp())
' print Document
oNewDoc.print(oProp())
' close Document
oNewDoc.close(-1)
end sub
|
But I got an error with "oNewDoc.close(-1)". Why does ist happen?
Can I Load the JPG-File invisible?
Thank you very much again.
Regards
Simon |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|