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

Assistance Needed: Troubleshooting Adobe InDesign Plug-in to export PDF on macOS

Community Beginner ,
Jan 20, 2025 Jan 20, 2025

Copy link to clipboard

Copied

Hello Team,
 
I am currently working on an Adobe InDesign plug-in designed to export PDFs to a specified location. Below are the details of my setup:
 
InDesign SDK Version: plugin_sdk_19.3.0.58.zip
macOS Version: Sonoma 14.7.2
InDesign Version: 19.5.1
 
The code functions as expected on Windows, successfully creating a PDF in the same directory as the InDesign file. However, on macOS, I encounter the error "Command processing failed," and no PDF is generated.
I have confirmed that folder permissions are not the issue, as I can save InDesign files to the same location without any problems.
Could you please provide guidance on how to troubleshoot this issue further? Any insights or suggestions would be greatly appreciated.
 

 

	ErrorCode status = kFailure;
	UIFlags uiFlags = kSuppressUI;

	InterfacePtr<ICommand> pdfExportCmd(CmdUtils::CreateCommand(kPDFExportCmdBoss));
    if (!pdfExportCmd) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to create PDF export command");
        return status;
    }

	// set export prefs on the command by copying from the workspace export prefs.
	InterfacePtr<IPDFExportPrefs> pdfExportPrefs(pdfExportCmd, UseDefaultIID());
	InterfacePtr<IPDFExportPrefs> appExportPrefs((IPDFExportPrefs*)::QuerySessionPreferences(IID_IPDFEXPORTPREFS));
    if (!pdfExportPrefs || !appExportPrefs) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to retrieve export preferences");
        return status;
    }
	pdfExportPrefs->CopyPrefs(appExportPrefs);
    
	// set ISysFileData to point to the output file.
	InterfacePtr<ISysFileData> trgSysFileData(pdfExportCmd, IID_ISYSFILEDATA);
    if (!trgSysFileData) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to set output file data");
        return status;
    }
	trgSysFileData->Set(fileToExport);

	// set security prefs on the command by copying from the workspace security prefs.
	InterfacePtr<IPDFSecurityPrefs> securityPrefs(pdfExportCmd, UseDefaultIID());
	InterfacePtr<IPDFSecurityPrefs> appSecurityPrefs((IPDFSecurityPrefs*)::QuerySessionPreferences(IID_IPDFSECURITYPREFS));
    if (!securityPrefs || !appSecurityPrefs) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to retrieve security preferences");
        return status;
    }
	securityPrefs->CopyPrefs(appSecurityPrefs);

	// set print content prefs, if needed. We are doing nothing here.
	InterfacePtr<IPrintContentPrefs> printContentPrefs(pdfExportCmd, IID_IPRINTCONTENTPREFS);

	// set to true if outputting a book file 
	InterfacePtr<IBoolData> bookExport(pdfExportCmd, IID_IBOOKEXPORT);
    if (!bookExport) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to set book export flag");
        return status;
    }
	bookExport->Set(kFalse);

	// set UI flags, kFullUI, kMinimalUI, or kSuppressUI
	InterfacePtr<IUIFlagData> uiFlagData(pdfExportCmd, IID_IUIFLAGDATA);
    if (!uiFlagData) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to set UI flags");
        return status;
    }
	uiFlagData->Set(uiFlags);

	// set up the scope of export (pages)
	UIDList pageItemList(pagesUIDList);
	pdfExportCmd->SetItemList(pageItemList);

	InterfacePtr<IOutputPages> outputPages(pdfExportCmd, UseDefaultIID());
    if (!outputPages) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to initialize output pages");
        return status;
    }
	outputPages->Clear();

	IDataBase* db = pageItemList.GetDataBase();
    if (!db) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to get database from page item list");
        return status;
    }
	outputPages->SetMasterDataBase(db);

	bool16 isExportingSpreads = (pdfExportPrefs->GetPDFExReaderSpreads() == IPDFExportPrefs::kExportReaderSpreadsON);

    // Initialize output pages with the given page list and spread setting
	outputPages->InitializeFrom(pageItemList, isExportingSpreads); // for spreads
    
	int32 nProgressItems = pageItemList.Length();
 
	// set PDF document name (get name from IDocument)
	InterfacePtr<IDocument> doc ((IDocument*)db->QueryInstance(db->GetRootUID(), IID_IDOCUMENT));
    if (!doc) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Failed to get document instance");
        return status;
    }
	PMString documentName;
	doc->GetName(documentName);
	outputPages->SetName(documentName);

	// setup progress bar, if not suppressing the UI.
	K2::scoped_ptr<RangeProgressBar> deleteProgressBar;
	bool16 bShowImmediate = kTrue;
	if(uiFlags != kSuppressUI)
	{
		RangeProgressBar *progress = new RangeProgressBar( "Generating PDF", 0, nProgressItems, bShowImmediate, kTrue, nil, kTrue); 
		pdfExportPrefs->SetProgress(progress);
		deleteProgressBar.reset(progress);
	}

	// finally process command
	status = CmdUtils::ProcessCommand(pdfExportCmd);
    if (status != kSuccess) {
        LOG_ERROR(LayerSetLogger::getLogger(), "Command processing failed");
    } else {
        LOG_ERROR(LayerSetLogger::getLogger(), "Command processed successfully");
    }

 

TOPICS
SDK

Views

106

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

correct answers 1 Correct answer

Guide , Jan 20, 2025 Jan 20, 2025

Search the SDK and this forum for the recent change of the macOS version from HFS to Posix paths.

 

Votes

Translate

Translate
Community Expert ,
Jan 20, 2025 Jan 20, 2025

Copy link to clipboard

Copied

Is there a specific reason why you need to do it as a plug-in - instead of a script? 

 

Votes

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
Guide ,
Jan 20, 2025 Jan 20, 2025

Copy link to clipboard

Copied

Search the SDK and this forum for the recent change of the macOS version from HFS to Posix paths.

 

Votes

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
Community Expert ,
Jan 20, 2025 Jan 20, 2025

Copy link to clipboard

Copied

Votes

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
Community Beginner ,
Jan 21, 2025 Jan 21, 2025

Copy link to clipboard

Copied

LATEST

The issue was indeed related to file paths using HFS instead of the POSIX path style. I confirmed this by temporarily removing the cookie file named 'ENABLE_POSIX_PATH'. I have since updated the plug-in code, and it is now functioning as expected. Thank you very much for pointing me in the right direction.

Votes

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