使用 .net 转换 cdr (Corel Draw)

发布于 2024-10-15 10:31:00 字数 172 浏览 1 评论 0原文

我很难使用 c#.net 将 cdr 文件转换为 jpg 以便预览。有人告诉我 cdr 文件嵌入了位图,有没有简单的方法来提取它?

现在我正在运行一个非常糟糕的解决方案,从我的应用程序调用 uniconvertor 转换为 svg,然后使用 imagemagick 将 svg 文件转换为 jpg。有更好的方法吗?

Im having a hard time converting cdr files to jpgs for previews using c#.net. someone told me that cdr files have embedded bitmap, is there an easy way to extract it?

right now im running a realy bad solution of, from my application, calling uniconvertor to convert to svg, then converting the svg file to jpg using imagemagick. is there a better way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

童话里做英雄 2024-10-22 10:31:00

您需要将类型库从 corelDRAW: C:\Program Files (x86)\Corel\CorelDRAW Graphics Suite 13\Programs\CorelDraw.tlb 复制到 /bin 中文件夹并创建对其的引用。完成此操作后,您应该能够将 .CDR 文件导出为多种不同的格式。下面的示例代码将 .cdr 转换为 .png。



    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using CorelDRAW;

    namespace WebApplication1
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Button1_Click(object sender, EventArgs e)
            {
                CorelDRAW.Application cdr =
                    new Application();

                cdr.OpenDocument(@"C:\Users\user\Desktop\500074.cdr", 1);
                cdr.ActiveDocument.ExportBitmap(
                    @"C:\Users\user\Desktop\newImage.png",
                    CorelDRAW.cdrFilter.cdrPNG,
                    CorelDRAW.cdrExportRange.cdrCurrentPage,
                    CorelDRAW.cdrImageType.cdrRGBColorImage,
                    0, 0, 72, 72,
                    CorelDRAW.cdrAntiAliasingType.cdrNoAntiAliasing,
                    false,
                    true,
                    true,
                    false,
                    CorelDRAW.cdrCompressionType.cdrCompressionNone,
                    null).Finish();
                cdr.ActiveDocument.Close();
                cdr.Quit();
            }

            protected void Page_Load(object sender, EventArgs e)
            {

            }
        }
    }


此代码会将 .cdr 转换为 .pdf:




protected void Button2_Click(object sender, EventArgs e)
    {
        CorelDRAW.Application cdr =
             new Application();

        cdr.OpenDocument(@"C:\Users\user\Desktop\500074.cdr", 1);
        cdr.ActiveDocument.PublishToPDF(@"C:\Users\user\Desktop\NewImage.pdf");
        cdr.ActiveDocument.Close();
        cdr.Quit();
    }


You will need to copy the type library from corelDRAW: C:\Program Files (x86)\Corel\CorelDRAW Graphics Suite 13\Programs\CorelDraw.tlb into your /bin folder and create a reference to it. Once you have done this you should be able to export .CDR files to many different formats. The sample code below converts .cdr to .png.



    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using CorelDRAW;

    namespace WebApplication1
    {
        public partial class _Default : System.Web.UI.Page
        {
            protected void Button1_Click(object sender, EventArgs e)
            {
                CorelDRAW.Application cdr =
                    new Application();

                cdr.OpenDocument(@"C:\Users\user\Desktop\500074.cdr", 1);
                cdr.ActiveDocument.ExportBitmap(
                    @"C:\Users\user\Desktop\newImage.png",
                    CorelDRAW.cdrFilter.cdrPNG,
                    CorelDRAW.cdrExportRange.cdrCurrentPage,
                    CorelDRAW.cdrImageType.cdrRGBColorImage,
                    0, 0, 72, 72,
                    CorelDRAW.cdrAntiAliasingType.cdrNoAntiAliasing,
                    false,
                    true,
                    true,
                    false,
                    CorelDRAW.cdrCompressionType.cdrCompressionNone,
                    null).Finish();
                cdr.ActiveDocument.Close();
                cdr.Quit();
            }

            protected void Page_Load(object sender, EventArgs e)
            {

            }
        }
    }


This code would convert the .cdr to .pdf:




protected void Button2_Click(object sender, EventArgs e)
    {
        CorelDRAW.Application cdr =
             new Application();

        cdr.OpenDocument(@"C:\Users\user\Desktop\500074.cdr", 1);
        cdr.ActiveDocument.PublishToPDF(@"C:\Users\user\Desktop\NewImage.pdf");
        cdr.ActiveDocument.Close();
        cdr.Quit();
    }


几味少女 2024-10-22 10:31:00

最后我只是使用 com interop 导出图像,必须安装 coreldraw 并引用 CorelDRAW 15.0 类型库,仍然不是最好的解决方案,但比我使用的解决方案更好

In the end i just used com interop to export the images, had to install coreldraw and reference the CorelDRAW 15.0 Type Library, still not the best solution but better then the one i was using

终遇你 2024-10-22 10:31:00

我知道 CDR 文件格式规范和 SDK 可通过 Corel Technology 程序 http: //www.corel.com/servlet/Satellite/us/en/Content/1152796559574

I know that CDR file format specification and SDK is avaliable through Corel Technology programm http://www.corel.com/servlet/Satellite/us/en/Content/1152796559574

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文