资源简介
发现在中国针对CorelDRAW二次开发的资源少之甚少,这是偶根据经验写了点与CorelDRAW交互的Lib,功能:(1)将*.CDR文件转换为JPG。(2)将JPG文件添加到*.CDR文件中。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using CorelDRAW;
using VGCore;
namespace ConvertCDRLib
{
public class CDRMachine
{
#region “单实例运行“
private static CDRMachine instance = null;
private static object asyncObj = new object();
///
/// 应用程序信息缓存的实例
///
public static CDRMachine Instance
{
get
{
lock (asyncObj)
{
if (instance == null)
{
lock (asyncObj)
{
instance = new CDRMachine();
}
}
return instance;
}
}
}
#endregion
#region “CDR to images“
public void ConvertCDR2Img(string CDRfile)
{
CorelDRAW.Application app = null;
CorelDRAW.Document doc = null;
try
{
app = new CorelDRAW.Application();
doc = app.OpenDocument(CDRfile);
app.Visible = false;
CorelDRAW.ExportFilter exportfilter;
exportfilter = (CorelDRAW.ExportFilter)doc.ExportBitmap(“d:\\Test.bmp“ CorelDRAW.cdrFilter.cdrBMP CorelDRAW.cdrExportRange.cdrAllPages
CorelDRAW.cdrImageType.cdrRGBColorImage 1024 768 300 300 CorelDRAW.cdrAntiAliasingType.cdrNormalAntiAliasing
false false true false CorelDRAW.cdrCompressionType.cdrCompressionNone);
exportfilter.Finish();
app.Quit();
}
catch(Exception e)
{
MessageBox.Show(e.Message);
}
}
#endregion
#region “image add to CDR“
public void ConvertImg2CDR(string CDRfilename string ImgFile)
{
CorelDRAW.Application app = null;
CorelDRAW.Document mydoc = null;
CorelDRAW.ImportFilter impflt = null;
CorelDRAW.StructImportOptions impopt = null;
CorelDRAW.StructSaveAsOptions SaveOptions = null;
try
{
app = new CorelDRAW.Application();
app.Visible = false;
mydoc = app.CreateDocument();
impopt = new CorelDRAW.StructImportOptions();
impopt.Mode = CorelDRAW.cdrImportMode.cdrImportFull;
SaveOptions = new CorelDRAW.StructSaveAsOptions();
SaveOptions.embedVBAProject = true;
SaveOptions.Filter = CorelDRAW.cdrFilter.cdrCDR;
SaveOptions.IncludeCMXData = false;
SaveOptions.Range = CorelDRAW.cdrExportRange.cdrAllPages;
SaveOptions.embedICCProfile = false;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 16384 2011-09-23 11:04 ConvertCDRLib\bin\Debug\ConvertCDRLib.dll
文件 13824 2011-09-23 11:04 ConvertCDRLib\bin\Debug\ConvertCDRLib.pdb
文件 16384 2011-09-23 11:04 ConvertCDRLib\bin\Release\ConvertCDRLib.dll
文件 11776 2011-09-23 11:04 ConvertCDRLib\bin\Release\ConvertCDRLib.pdb
文件 3604 2011-09-23 11:05 ConvertCDRLib\CDRMachine.cs
文件 3001 2011-09-23 11:04 ConvertCDRLib\ConvertCDRLib.csproj
文件 503 2011-09-23 11:04 ConvertCDRLib\obj\Debug\ConvertCDRLib.csproj.FileListAbsolute.txt
文件 853 2011-09-23 11:04 ConvertCDRLib\obj\Debug\ConvertCDRLib.csproj.ResolveComReference.cache
文件 16384 2011-09-23 11:04 ConvertCDRLib\obj\Debug\ConvertCDRLib.dll
文件 13824 2011-09-23 11:04 ConvertCDRLib\obj\Debug\ConvertCDRLib.pdb
文件 5622 2011-09-23 11:04 ConvertCDRLib\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 1060352 2011-09-23 11:04 ConvertCDRLib\obj\Debug\Interop.CorelDRAW.dll
文件 356352 2011-09-23 11:04 ConvertCDRLib\obj\Debug\Interop.VGCore.dll
文件 519 2011-09-23 11:04 ConvertCDRLib\obj\Release\ConvertCDRLib.csproj.FileListAbsolute.txt
文件 853 2011-09-23 11:04 ConvertCDRLib\obj\Release\ConvertCDRLib.csproj.ResolveComReference.cache
文件 16384 2011-09-23 11:04 ConvertCDRLib\obj\Release\ConvertCDRLib.dll
文件 11776 2011-09-23 11:04 ConvertCDRLib\obj\Release\ConvertCDRLib.pdb
文件 5630 2011-09-23 11:04 ConvertCDRLib\obj\Release\DesignTimeResolveAssemblyReferencesInput.cache
文件 1060352 2011-09-23 11:04 ConvertCDRLib\obj\Release\Interop.CorelDRAW.dll
文件 356352 2011-09-23 11:04 ConvertCDRLib\obj\Release\Interop.VGCore.dll
文件 1358 2011-09-23 10:34 ConvertCDRLib\Properties\AssemblyInfo.cs
目录 0 2011-09-23 10:34 ConvertCDRLib\obj\Debug\TempPE
目录 0 2011-09-23 11:04 ConvertCDRLib\obj\Release\TempPE
目录 0 2011-09-23 11:04 ConvertCDRLib\bin\Debug
目录 0 2011-09-23 11:04 ConvertCDRLib\bin\Release
目录 0 2011-09-23 11:04 ConvertCDRLib\obj\Debug
目录 0 2011-09-23 11:04 ConvertCDRLib\obj\Release
目录 0 2011-09-23 10:35 ConvertCDRLib\bin
目录 0 2011-09-23 11:04 ConvertCDRLib\obj
目录 0 2011-09-23 10:34 ConvertCDRLib\Properties
............此处省略4个文件信息
评论
共有 条评论