1 Reply Latest reply on Oct 27, 2014 1:45 PM by LeoTaro

    How to bypass file format parameter dialog during save

    Joydeep Ray Level 1

      Hi,

      In a file format plugin, I am saving an SVG document to EPS format (and also the opposite). The save operation is working properly, but always the format options dialog box for "EPS Options" is popping up (see attached). I am using a statement like the following:

      result = sAIDocument->WriteDocumentWithOptions(ai::FilePath(ai::UnicodeString("MyFile.svg")), "Adobe Illustrator EPSF", kFileFormatWrite | kFileFormatWriteAs | kFileFormatNoWarningOption, false);

       

      I also tried to use the WriteDocument() function as

      result = sAIDocument->WriteDocument(ai::FilePath(ai::UnicodeString("MyFile.svg")), "Adobe Illustrator EPSF", false); Outcome was the same.

       

      Finally, I also tried to specifically set the kFileFormatNoWarningOption in the EPS file format like the following, but there was no change.

       

      ai::int32 fileFormatCount;

      sAIFileFormat->CountFileFormats(&fileFormatCount);

       

      for (int i = 0; i < fileFormatCount; i++)

      {

           AIFileFormatHandle fileFormat = NULL;

           sAIFileFormat->GetNthFileFormat(i, &fileFormat);

           char *fileFormatName;

           sAIFileFormat->GetFileFormatName(fileFormat, &fileFormatName);

          

           if ( strncmp(fileFormatName, "Adobe Illustrator EPSF", strlen(fileFormatName)) == 0 )  // EPS file format

           {

                 result = sAIFileFormat->SetFileFormatExtendedOptions(fileFormat, kFileFormatNoWarningOption); // Don't show any warning dialog

       

                 result = sAIDocument->WriteDocumentWithOptions(ai::FilePath(ai::UnicodeString("MyFile.svg")), "Adobe Illustrator EPSF", kFileFormatWrite | kFileFormatWriteAs, false); // Save the document in EPS format  

           }

      }

       

      As there are numerous SVG files that need to be converted through the program, user intervention will not be acceptable.

       

      I think there may be something special about these EPS format options, because when I am saving an EPS file to SVG format (the opposite), no dialog box is coming. There I used the WriteDocument() function with the last parameter as false.

       

      One other associated question. If I want to specify some of these EPS specific options, how do I do that programmatically? Say, if I want to set Embed Fonts as "checked", how to do that? I have noted that if this is set/changed once manually, the value is retained, but how can I get access to this data in my program?

       

      Any help will be most appreciated.

       

      Best regards,

      Joydeep Ray

       

      EPS Options.png

        • 1. Re: How to bypass file format parameter dialog during save
          LeoTaro Level 4

          Hello again

           

          You will probably need to use the action manager suite for this.

           

          Start Illustrator and create/open a file. Open the Actions panel from the Window | Actions menu. Click on the "Create New Set" button at the bottom of the panel. Enter name for set and click OK. Click on the "Create New Action" button. Enter a name for the action and click Record. Now do File | Save As and save as EPS, setting the options you want to save from your code. Once the file has been saved, click the "Stop Playing/Recording" button on the action panel. You should see "Save As" included in your action. Select the set you created and from the menu button in the top right of the Action panel, select "Save Actions...". Choose a file name and save the action set. Open the saved file in a text editor and you should see something like this:

           

           

          /version 3

          /name [ 5

            5365742031

          ]

          /isOpen 1

          /actionCount 1

          /action-1 {

            /name [ 8

            6465662073617665

            ]

            /keyIndex 0

            /colorIndex 0

            /isOpen 1

            /eventCount 1

            /event-1 {

            /useRulersIn1stQuadrant 0

            /internalName (adobe_saveDocumentAs)

            /localizedName [ 7

            53617665204173

            ]

            /isOpen 0

            /isOn 1

            /hasDialog 1

            /showDialog 0

            /parameterCount 18

            /parameter-1 {

            /key 2003201396

            /showInPalette 4294967295

            /type (integer)

            /value 5

            }

            /parameter-2 {

            /key 1668445298

            /showInPalette 4294967295

            /type (integer)

            /value 17

            }

            /parameter-3 {

            /key 1702392878

            /showInPalette 4294967295

            /type (integer)

            /value 1

            }

            /parameter-4 {

            /key 1768975459

            /showInPalette 4294967295

            /type (boolean)

            /value 0

            }

            /parameter-5 {

            /key 1769236589

            /showInPalette 4294967295

            /type (boolean)

            /value 1

            }

            /parameter-6 {

            /key 1667723380

            /showInPalette 4294967295

            /type (boolean)

            /value 0

            }

            /parameter-7 {

            /key 1768320372

            /showInPalette 4294967295

            /type (integer)

            /value 0

            }

            /parameter-8 {

            /key 1768122987

            /showInPalette 4294967295

            /type (boolean)

            /value 1

            }

            /parameter-9 {

            /key 1886612598

            /showInPalette 4294967295

            /type (integer)

            /value 2

            }

            /parameter-10 {

            /key 1668118891

            /showInPalette 4294967295

            /type (boolean)

            /value 1

            }

            /parameter-11 {

            /key 1684435811

            /showInPalette 4294967295

            /type (boolean)

            /value 1

            }

            /parameter-12 {

            /key 1701802100

            /showInPalette 4294967295

            /type (integer)

            /value 1

            }

            /parameter-13 {

            /key 1851878757

            /showInPalette 4294967295

            /type (ustring)

            /value [ 47

            2f55736572732f7061747269636b63726169672f44726f70626f7820284c6f63

            75734c616273292f6465662e657073

            ]

            }

            /parameter-14 {

            /key 1718775156

            /showInPalette 4294967295

            /type (ustring)

            /value [ 22

            41646f626520496c6c7573747261746f722045505346

            ]

            }

            /parameter-15 {

            /key 1702392942

            /showInPalette 4294967295

            /type (ustring)

            /value [ 11

            6570732c657073662c7073

            ]

            }

            /parameter-16 {

            /key 1936548194

            /showInPalette 4294967295

            /type (boolean)

            /value 0

            }

            /parameter-17 {

            /key 1935764588

            /showInPalette 4294967295

            /type (boolean)

            /value 1

            }

            /parameter-18 {

            /key 1936875886

            /showInPalette 4294967295

            /type (ustring)

            /value [ 0

           

            ]

            }

            }

          }

           

          You now need to convert this into code. The code will be something like this, where you translate the parameters above into AIActionSet... calls. You can either just put the key value in directly or covert to hex and then a four character string. ustring parameters are unicode strings so use AIActionSetStringUS. The ustring values are the length and then the string as hex characters:

           

              AIActionParamValueRef vpb = NULL;

              sAIActionManager->AINewActionParamValue(&vpb);

              sAIActionManager->AIActionSetInteger(vpb, 'crtr', 17);

          ...

              sAIActionManager->PlayActionEvent(kAISaveDocumentAsAction, kDialogOff, vpb);

              sAIActionManager->AIDeleteActionParamValue(vpb);

          1 person found this helpful