Corel Draw API(Java/C#)
我想知道是否有Corel Draw for Java或类似的API。我的一个朋友需要一个编辑一些图片的小程序。它必须是Corel Draw,但编程语言没有限制(Java或C#prefered…)Corel Draw API(Java/C#),c#,java,api,coreldraw,C#,Java,Api,Coreldraw,我想知道是否有Corel Draw for Java或类似的API。我的一个朋友需要一个编辑一些图片的小程序。它必须是Corel Draw,但编程语言没有限制(Java或C#prefered…) 不幸的是,我在网上没有发现任何有用的东西。也许你们中的一些人知道得更多?我知道你用VB写了一些宏。您可以在以下位置找到pdf文档中的所有信息: C:\ProgramFiles(x86)\Corel\Corel Graphics 12\Programs pdf:dvba_pg.pdf PP VBA对象模型
不幸的是,我在网上没有发现任何有用的东西。也许你们中的一些人知道得更多?我知道你用VB写了一些宏。您可以在以下位置找到pdf文档中的所有信息: C:\ProgramFiles(x86)\Corel\Corel Graphics 12\Programs pdf:dvba_pg.pdf PP VBA对象模型.pdf:CorelDRAW VBA对象模型.pdf
我希望这将对您有所帮助。我发现最好的方法是使用VBScript 在您仍然感兴趣的cas中,请查看下面的代码。 这些脚本(从java开始)接受两个参数:源文件和目标文件,并在将源文件保存到目标文件之前对源文件进行一些操作 此脚本的局限性在于它依赖于“CorelDraw x6”。您可以编写更通用的代码,并查找各种CorelDraw OLE对象 这种机制的局限性在于,并不是所有的工作都可以用VB来完成(我从来没有实现过获得CorelDraw页面的大小!!!) 代码:
选项显式
昏暗的应用程序
“参数
暗源
if(Wscript.Arguments.count)(人们仍然使用Corel产品…?我怀疑是否有一个用于它的API,但也许有一种方法可以将一种矢量格式转换为“Corel Draw”格式或另一种中间矢量格式,并使用API创建/更改它。)
<package>
<job id="Main">
<reference object="CorelDraw.Application" version="16.0" />
<script language="VBScript">
Option Explicit
Dim app
' Parameters
Dim source, dest
if ( Wscript.Arguments.count<2) Then
Err.Raise 2, "MakeThumb", "Invalid paremeters count"
Wscript.echo "Invalid paremeters count"
Wscript.quit -999
end if
source= Wscript.Arguments.Item(0)
dest= Wscript.Arguments.Item(1)
'Wscript.echo source
'Wscript.echo dest
' Initialisation
set app= nothing
On Error resume next
' Retrieval of an existing instance
Set app = GetObject(, "CorelDraw.Application.16")
On Error GoTo 0
' No existing instance, creatoing a new one
If (app is nothing) Then
Err.Clear
On Error resume next
Set app = CreateObject("CorelDraw.Application.16")
On Error GoTo 0
End If
If (app Is Nothing) Then
Err.Raise 2, "MakeThumb", "Impossible to open Corel Draw"
'stop
Wscript.quit -998
end if
app.visible=true
Dim doc
set doc = app.OpenDocument(source)
' Trying to get source document's size
'Dim cs
'Set cs = CreateObject( "CorelDRAW.CorelScript" )
Dim pg
Set pg = doc.pages.Item(1)
doc.unit=5 'unit=pixels
Dim h0, w0
on error resume next
' if it fails, I assume the dimention are an A4
h0=pg.SizeHeight
w0=pg.SizeWidth
if (err<>0) then
w0=2480
h0=3508
end if
on error goto 0
Dim h, w, s, r
'Wscript.echo "h orig=" + CStr(h0) + ",w orig=" + CStr(w0) + " unit=" + CStr(doc.Unit)
h = doc.ToUnits(h0, cdrPixel)
w = doc.ToUnits(w0, cdrPixel)
s = h * w
r = Sqr(500990 / s)
'Wscript.echo "h=" + CStr(h) + ",w=" + CStr(w) + ",s=" + CStr(s) + ", r=" + CStr(r)
Dim h2, w2
h2 = h * r
w2 = w * r
'Wscript.echo "h2=" + CStr(h2) + ",w2=" + CStr(w2)
Dim exportFilter
Set exportFilter = doc.ExportBitmap( _
dest, cdrPNG, cdrCurrentPage, cdrRGBColorImage, w2, h2, 72, 72, _
cdrNormalAntiAliasing, False, False, True, False, cdrCompressionNone, Nothing, Nothing)
exportFilter.Finish
doc.close
app.quit
Set app = Nothing
Set doc = Nothing
Wscript.quit 0
</script>
</job>
</package>