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

柔情痞子 提交于 2020-01-01 03:52:10

问题


Anyone knows how to load a .AI file (Adobe Illustrator) and then rasterize/render the vectors into a Bitmap so I could generate eg. a JPG or PNG from it?

I would like to produce thumbnails + render the big version with transparent background in PNG if possible.

Ofcause its "possible" if you know the specs of the .AI, but has anyone any knowledge or code to share for a start? or perhaps just a link to some components?

C# .NET please :o)

Code is most interesting as I know nothing about reading vector points and drawing splines.


回答1:


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.




回答2:


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.




回答3:


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.




回答4:


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);


来源:https://stackoverflow.com/questions/5784030/c-sharp-import-of-adobe-illustrator-ai-files-render-to-bitmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!