3 Replies Latest reply on Oct 12, 2017 6:03 AM by jaco78669427

    IllustratorSaveOptions in C# .NET is not working anymore as expected

    jaco78669427 Level 1

      For more than a decade the following Illustrator script has been applied via C# .NET in combination with all existing Illustrator versions (sourcecode):


      typelib.IllustratorSaveOptions saveOptions = new typelib.IllustratorSaveOptions();

      saveOptions.Compatibility = typelib.AiCompatibility.aiIllustrator8;

      saveOptions.FlattenOutput = typelib.AiOutputFlattening.aiPreserveAppearance;

      DestDoc.SaveAs(sPath, saveOptions);


      All over the internet we see a lot of people using the same code above (ideas) also in other programming languages.


      Following test has been done with CS, CS2, CS3, CS5, CS6, etc. on the latest Windows 10 operating system and with VS2012:

      draw 2 intersecting rectangles: above yellow, the other red. A transparency Difference has been set on the yellow rectangle.


      AI version8.0 output results:

      applying the source code above, in versions up to and CS5, yields three rectangles (transparency is being flattened), but later versions (CS6 up to and the latest most recent creative cloud Illustrator version) do output only two rectangles (do not flatten, but remove the transparency as if option aiPreservePaths instead of aiPreserveAppearance is activated).


      Everything is working well in case the save to AI format 8.0 is done manually inside the Illustrator application itself.


      What has been changed that has broken this functionality?


      Do we have to add something to the code mentioned above, or, has a bug been introduced in Illustrator from version CS5 to CS6? We have no idea why this is not working anymore. Please look into it because this piece of functionality is quite important for our customers.


      Our goal is to save a worksheet via a C# .NET application in AI version format 8.0 with option Preserve Appearance and Overprint. Initially it worked for a lot of Illustrator versions, but now it does not work anymore.




        • 1. Re: IllustratorSaveOptions in C# .NET is not working anymore as expected
          Silly-V Adobe Community Professional

          Not sure what is happening to you, but I am surprised on my end to discover that my Transparency radio buttons are disabled when I do a manual Save As operation!

          • 2. Re: IllustratorSaveOptions in C# .NET is not working anymore as expected
            jaco78669427 Level 1

            Well, those Transparency radio buttons will be activated once you have selected Illustrator 8.0 above as Version.


            In case you select Preserve Appearance and Overprints, that option will work well, that is manually. from within the UI, but in case of Scripting, for example in Visual Basic (which I have been testing too in combination with the latest Creative Cloud application) that option Preserve Appearance and Overprints does not work for me, as if instead Preserve Paths is always being selected.


            My test in Visual Basic does follow exactly the Visual Basic Scripting specs (does follow the exact same lines of Visual Basic source code) as had been formulated with the not yet released newest version of Creative Cloud. It is supposed to work, but it does not work for me anymore since the release of CS6. Why?

            • 3. Re: IllustratorSaveOptions in C# .NET is not working anymore as expected
              jaco78669427 Level 1

              Jac OppersJac Oppers      commented     ·          October 11, 2017 12:07           ·            Flag as inappropriate              ·          Delete…              


              Title of the original post refers explicitly to C# .NET, but a similar test has also been done with Visual Basic .NET in Visual Studio 2012 which has been communicating with Adobe Illustrator 2017 CC.


              Visual Basic source code actually used by me and to be tried out by others can be found here below:


              Public Class Form1
                  'Visual Basic .NET Script for saving Adobe Illustrator 2017 CC content to AI version 8.0 file format. 
                  Private Sub Form1_Load(sender As Object, e As EventArgs) _
                      Handles MyBase.Load
                      'Request path which allows storage of AI output file
                      Dim LocalAppData As String = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)
                      ' Set name of file to be saved in textbox.  
                      TextBox1.Text = LocalAppData + "\\Temp\\Test.ai"
                  End Sub
                  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                      'Defined reference: Adobe Illustrator CC 2017 Type Library (selected SriptingSupport.aip)
                      'When build with setting Any CPU then this Visual Basic .NET utility will only work with 32-Bit
                      'Easiest approach is first to startup Illustrator CC 2017 manually,
                      'then create required content (something with transparency)
                      'and then run this VB .NET program to let the application save its content to AI 8.0 format
                      'after clicking the push button (transparency will be removed instead of being flattened!).
                      Dim appRef As New Illustrator.Application

                      Dim SaveOptions As New Illustrator.IllustratorSaveOptions
                      SaveOptions.Compatibility = 8 'aiIllustrator8
                      SaveOptions.FlattenOutput = 1 'aiPreserveAppearance

                      'File must first be deleted in case file already exists.
                      If System.IO.File.Exists(TextBox1.Text) = True Then
                      End If

                      'Save file
                      Call appRef.Documents(1).SaveAs(TextBox1.Text, SaveOptions)
                  End Sub
                  Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
                  End Sub
              End Class