private VGCore.Document newDocument(VGCore.Application application) { VGCore.Document document = application.CreateDocument(); document.Name = ++counter + "_" + Guid.NewGuid().ToString(); document.Activate(); document.Unit = VGCore.cdrUnit.cdrMillimeter; document.ActivePage.SetSize(210, 297); document.Rulers.VUnits = document.Rulers.HUnits = VGCore.cdrUnit.cdrMillimeter; createGuideLines(document); return(document); }
public ExportForm(VGCore.Application app) { this.appDraw = app; InitializeComponent(); }
private void generate(IProgress <object> progress) { VGCore.Application application; try { application = new VGCore.Application(); } catch (Exception ex) { throw new Exception("CorelDRAW is not started or its version is not compatible with the software, please start CorelDRAW if not started or install compatible version"); } VGCore.Document document = null; double positionX = 0; double positionY = 0; List <string> processedZipFiles = new List <string>(); string[] zipFiles = getZipFiles(ZipsFolderPathTxt.Text); int zipCount = 1; foreach (string zipFilePath in zipFiles) { if ((zipCount - 1) % 3 == 0) { if (document != null) { saveCloseDocument(document); moveZipFiles(processedZipFiles); } document = newDocument(application); positionX = MarginLeft; //positionY = PageHeight + MaxHeight; positionY = PageHeight - MarginTop + MaxHeight; } VGCore.Layer layer = document.ActiveLayer; List <string> imageFiles = getImagesFromZip(zipFilePath); bool isFirstImage = true; foreach (string imageFilePath in imageFiles) { VGCore.Shape image; try { image = loadResizedImage(layer, imageFilePath); } catch (Exception ex) { string message = "Failed to load file '" + Path.GetFileName(imageFilePath) + "' from zip file '" + Path.GetFileName(zipFilePath); progress.Report(message + "' for template file '" + document.Name + ".cdr'" + Environment.NewLine); //image = layer.CreateArtisticText(0, 0, message); //image.SizeWidth = MaxWidth; //image.SizeHeight = MaxHeight; //image.WrapText = VGCore.cdrWrapStyle.cdrWrapSquareAboveBelow; continue; } double x = 0; double y = 0; if (isFirstImage) { positionX = MarginLeft; //positionY -= MaxHeight + MarginTop; positionY -= MaxHeight; if (image != null) { x = positionX + ((MaxWidth - image.SizeWidth) / 2); y = positionY - (MaxHeight - image.SizeHeight) / 2; } isFirstImage = false; // insert order id from zip file name into the row layer.CreateArtisticText(-150, positionY - 15, Path.GetFileNameWithoutExtension(zipFilePath).Split('_')[0] , VGCore.cdrTextLanguage.cdrLanguageNone, VGCore.cdrTextCharSet.cdrCharSetMixed , "Arial", 30); } else { //positionX = PageWidth - MarginRight - image.SizeWidth; positionX += MaxWidth + MarginRight; if (image != null) { x = positionX + ((MaxWidth - image.SizeWidth) / 2); y = positionY - (MaxHeight - image.SizeHeight) / 2; } } if (image != null) { image.SetPosition(x, y); } // Insert text from xml file Dictionary <string, string> textData; bool hasValue = inputTexts.TryGetValue(Path.GetFileNameWithoutExtension(imageFilePath), out textData); if (hasValue && textData != null && textData["text"] != null && textData["text"].Length > 0) { VGCore.Shape text = layer.CreateArtisticText(positionX, positionY - 25, textData["text"] , VGCore.cdrTextLanguage.cdrLanguageNone, VGCore.cdrTextCharSet.cdrCharSetMixed , textData["family"], 25); String color = textData["color"]; if (color != null && color != "") { //.FromArgb(Convert.ToInt32(color.Replace("#", ""), 16)) VGCore.Color c = layer.Color; c.HexValue = color; text.Fill.ApplyUniformFill(c); } } } progress.Report(((100 - 10) / zipFiles.Length) * zipCount); zipCount++; processedZipFiles.Add(zipFilePath); } saveCloseDocument(document); moveZipFiles(processedZipFiles); application.Refresh(); //emptyTempDirectory(); progress.Report(100); }
public CorelDrawExporter(object obj) { this.appDraw = (VGCore.Application)obj; }