C# import of Adobe Illustrator (.AI) files render to Bitmap?

六月ゝ 毕业季﹏ 提交于 2019-12-03 09:44:55

Well, if Gregory is right that ai files are pdf-compatible, and you are okay with using GPL code, there is a project called GhostscriptSharp on github that is a .NET interface to the Ghostscript engine that can render PDF.

With the newer AI versions, you should be able to convert from PDF to image. There are plenty of libraries that do this that are cheap, so I would choose buy over build on this one. If you need to convert the older AI files, all bets are off. I am not sure what format they were in.

Johnson
private void btnGetAIThumb_Click(object sender, EventArgs e)
{
    Illustrator.Application app = new Illustrator.Application();
    Illustrator.Document doc = app.Open(@"F:/AI_Prog/2009Calendar.ai", Illustrator.AiDocumentColorSpace.aiDocumentRGBColor, null);
    doc.Export(@"F:/AI_Prog/2009Calendar.png",Illustrator.AiExportType.aiPNG24, null);  
    doc.Close(Illustrator.AiSaveOptions.aiDoNotSaveChanges); 
    doc = null; //
}

Illustrator.AiExportType.aiPNG24 can be set as JPEG,GIF,Flash,SVG and Photoshop format.

I Have Tested that with Pdf2Png and it worked fine with both .PDF and .ai files.
But I don't know how it will work with transparents.

string pdf_filename = @"C:\test.ai";
//string pdf_filename = @"C:\test.pdf";
string png_filename = "converted.png";
List<string> errors = cs_pdf_to_image.Pdf2Image.Convert(pdf_filename, png_filename);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!