IllustratorSaveOptions in C# .NET is not working anymore as expected
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;
All over the internet we see a lot of people using the same code above (applying the exact same idea) also in other programming languages.
Following test has been done with Illustrator versions CS, CS2, CS3, CS5, CS6, etc. on the latest Windows 10 operating system and VS2012: draw 2 intersecting rectangles: above yellow, the other red. A transparency Difference has been set on the yellow rectangle.
AI version 8.0 output results via scripted AI 8.0 output:
using the source code above, in versions up to and CS5, three rectangles are outputted (transparency is being flattened), but later versions (CS6 up to and the latest Creative Cloud Illustrator version) outputs only two rectangles (do not flatten but remove the transparency as if option aiPreservePaths instead of aiPreserveAppearance is active).
Everything is working well in case the save to AI format 8.0 is done manually from within the Illustrator programs.
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 which is still present up to and today? 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.
Jac Oppers commented
Title 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 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) _
'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"
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
Call appRef.Documents(1).SaveAs(TextBox1.Text, SaveOptions)
Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged