• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

export an Illustrator file as pdf

New Here ,
Oct 25, 2022 Oct 25, 2022

Copy link to clipboard

Copied

Hi all,
I want to export an Illustrator file as pdf.
I dicovered the API, but I have an issue when I open more then one document in Illustrator.
Following the steps to reproduce the issue:
1) open two files in Illustrator (file A and file B)
2) select file A
3) make some changes in file A
4) WITHOUT SAVING the file A, close the file A.
5) A windows prompts asking if I want to save
6) Click yes on the windows because I want to save the changes.
7) Illustrator saves the document A, but it exports the document B!

My procedure to generate the pdf is described at hte end of this post.

 

It seems that when I close the document A, Illustrator changes the active document from the document A to the document B and then it generates the export pdf from the document B.
I'm wondering if there is an API for generating a PDF passing the correct AIDocumentHandle.

What I'm doing wrong?
Do you have a solution please?
Thanks a lot!

 

The following function is triggered when I reach the event generated by the notified event "kAIDocumentWriteOnDiskCompleteNotifier"
AIErr EmIllustratorHandler::generateOutputFormat()
{
AIErr error = kNoErr;
std::wstring path(L"C:\\debug\\Adobe\\out.pdf");
fs::remove(path.c_str());

// If I can set the AIDocumentHandle for the sAIActionManager I'll solved the issue, but I don't know how to do it!

AIActionParamValueRef fActionParamValueRef = NULL;
error = sAIActionManager->AINewActionParamValue(&fActionParamValueRef);
error = sAIActionManager->AIActionSetEnumerated(fActionParamValueRef, kAIPDFCompatibilityKey, "AIPDFCompatibility", pdfVer);
error = sAIActionManager->AIActionSetBoolean(fActionParamValueRef, kAIPDFRoundTripKey, 1);
error = sAIActionManager->AIActionSetBoolean(fActionParamValueRef, kAIPDFGenerateThumbnailsKey, 1);
ai::FilePath filePath;
EmAISDKDocument::FilePathFromString(filePath, path.c_str());

// -- EXPORT PDF --
error = sAIActionManager->AIActionSetStringUS(fActionParamValueRef, kAIExportDocumentFormatKey, ai::UnicodeString(kAIPDFFileFormat));
error = sAIActionManager->AIActionSetStringUS(fActionParamValueRef, kAIExportDocumentNameKey, filePath.GetFullPath());
error = sAIActionManager->AIActionSetStringUS(fActionParamValueRef, kAIExportDocumentExtensionKey, ai::UnicodeString(kAIPDFFileFormatExtension));
error = sAIActionManager->PlayActionEvent(kAIExportDocumentAction, dialogStatus, fActionParamValueRef);
error = sAIActionManager->AIDeleteActionParamValue(fActionParamValueRef);

return error;
}

TOPICS
How to , Import and export , SDK

Views

64

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation