0 Replies Latest reply on Aug 7, 2014 7:56 AM by Wajih

    How TO Convert AI to 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 Jpg 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

                  {

                      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;   

                 bool inGamut = false;

       

                      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 Below Line line  {"Error HRESULT E_FAIL has been returned from a call to a COM component."}

      jpgOptions.Application.ConvertSampleColor(AiImageColorSpace.aiImageRGB, array1, AiImageColorSpace.aiImageGrayScale, AiColorConvertPurpose.aiForExportPurpose, AiColor.aiColorGray, inGamut);

       

                           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