Copy link to clipboard
Copied
how to set pdf compatibility to ai file or doc? I want to convert ai file to pdf file and I have used writeDocument() api. it converts ai file into pdf file but pdf file shows "create pdf compatible file option turned on".
here is my code -
ai::UnicodeString myString(filepath);
ai::FilePath aiFile1(myString);
ASErr result = kNoErr;
try
{
SDK_ASSERT(sAIDocument);
result = sAIDocument->WriteDocument(aiFile1, fileFormatName, false);
aisdk::check_ai_error(result);
}
catch (ai::Error& ex)
{
result = ex;
}
Please give answer if anyone knows.
Copy link to clipboard
Copied
Use WriteDocumentWithOptions instead of WriteDocument and pass parameter integer parameter 'pdf ' in additionalOptionsDict
Copy link to clipboard
Copied
@Xpertios​Can you elaborate on this? I have a hard time understanding how this looks like in code. I'm uncertain what the key and entry in the additionalOptionsDict would look like.
Here's what I have:
ai::FilePath path(ai::UnicodeString("/tmp/renderDocument.ai"), false);
AIDictionaryRef additionalOptionsDict;
sAIDictionary->CreateDictionary(&additionalOptionsDict);
AIDictKey key = sAIDictionary->Key(kAINativeFileFormat);
sAIDictionary->SetIntegerEntry(additionalOptionsDict, key, kAINativePDFCompatibilityKey);
ai::int32 fileFormatOptions = kFileFormatWrite
| kFileFormatWriteAs
| kFileFormatNoWarningOption
| kFileFormatSuppressUI;
error = sAIDocument->WriteDocumentWithOptions(path,
kAINativeFileFormat,
fileFormatOptions,
additionalOptionsDict,
false);
Copy link to clipboard
Copied
Try this
AIDictKey key = sAIDictionary->Key("IntegerValue");
result = sAIDictionary->SetIntegerEntry(additionalOptionsDict,fIntKey,'pdf ');
result = sAIDocument->WriteDocumentWithOptions(path, "Adobe Illustrator Any Format Writer", kFileFormatWrite , additionalOptionsDict , false);
Copy link to clipboard
Copied
This does not seem to work. There's the boolean value missing (how would I express to disable PDF compatibility)?
The main question is: How do I know what the keys and entries are in the additionalOptionsDict?
Copy link to clipboard
Copied
You can try write using PlayActionEvent, here is an example
// Initialize param
AIActionParamValueRef param;
error = sAIActionManager->AINewActionParamValue(¶m);
// Set parameter - where path is ai::UnicodeString, you can get it from ai::FilePath using GetFullPath()
error = sAIActionManager->AIActionSetStringUS(param, kAISaveDocumentAsNameKey, path);
// Set parameter - Native format writer and extension (true or false)
error = sAIActionManager->AIActionSetString(param, kAISaveDocumentAsFormatKey, kAINativeFileFormat);
error = sAIActionManager->AIActionSetStringUS(param, 'extn', ai::UnicodeString(kAINativeFileFormatExtension));
// Here set PDF compatibility
error = sAIActionManager->AIActionSetBoolean(param, kAINativePDFCompatibilityKey, true);
// Play Action
error = sAIActionManager->PlayActionEvent("adobe_saveACopyAs", kDialogOff, param); // here you can use other action such as SaveAS or Save