5 Replies Latest reply on Aug 9, 2014 2:28 PM by CarlosCanto

    How TO Convert AI to AI JPG GreyScale

    Wajih

      I have already Export to AI to JPG But not able to JPG Grey Scale using illlustrator.dll in csharp currently my code for conversion to ESP GreyScale if some one know how it would be done kindly give solution or correct my ode will be appreciated in advance.

       

       

      Illustrator.ApplicationClass illustratorApp = new Illustrator.ApplicationClass();

      #region AI To JPGGreyScale

                  {

                      var sourceAlpha = 10;

                      var desAlpha = 10;

                      Color color = Color.Gray;

                      object[] array1 = new object[4];

                      array1[0] = color.A;

                      array1[1] = color.R;

                      array1[2] = color.G;

                      array1[3] = color.B;    

                      Illustrator.Document illustratorCurrentDoc;

                      try

                      {

                          illustratorApp.UserInteractionLevel = AiUserInteractionLevel.aiDontDisplayAlerts;

                          Illustrator.OpenOptionsClass objOptions = new OpenOptionsClass();

                          Illustrator.ExportOptionsJPEG jpgOptions = new ExportOptionsJPEG();

       

                          jpgOptions.AntiAliasing = true;

                          jpgOptions.QualitySetting = 100;

                          jpgOptions.Optimization = false;

                          jpgOptions.ArtBoardClipping = true;

       

                       // creating error this line   jpgOptions.Application.ConvertSampleColor(AiImageColorSpace.aiImageCMYK, array1, AiImageColorSpace.aiImageGrayScale,                  AiColorConvertPurpose.aiForExportPurpose, true, true);

       

                           illustratorApp.Open(SourceLocation, AiDocumentColorSpace.aiDocumentRGBColor, objOptions);

                          illustratorCurrentDoc = illustratorApp.ActiveDocument;

                          try

                          {

                              illustratorCurrentDoc.Export(TargetLocation, AiExportType.aiJPEG, jpgOptions);  

                          }

                          catch (Exception ex)

                          {

                              ErrorLog.InsertErrorLog("GenerateFileFormat", "Adobe AI_JPGGreyScale document Exception", "");

                              ErrorLog.InsertErrorLog("GenerateFileFormat", ex.StackTrace, "");

                          }

                          finally

                          {

                              illustratorCurrentDoc.Close(PsSaveBehavior.psAlwaysSave);

                              illustratorApp.Quit();

                          }

                      }

                      catch (Exception ex)

                      {

                          illustratorApp.Quit();

                      }

                  }

                  #endregion