Skip to main content
Inspiring
September 19, 2017
Answered

IDocFileHandler SaveACopy as idml

  • September 19, 2017
  • 3 replies
  • 862 views

I'm working on a plugin for InDesign and I need to save a copy of the actual document as idml (I also need to use the SaveAs function as idml).

When I use the SaveACopy function I only add the '.idml' to the file extension. this doesn't work because I can't open the file in CS5.5 (I save it in CS6).

IDocFileHandler *fIDFileH;

fIDFileH->SaveACopy(doc, destFile, uiFlags, asStationery, fileTypeID);

fileTypeId is a FileTypeInfoID.

What value (or how to declare the FileTypeInfoID) shall FileTypeInfoID have  to save the file as idml?

[Moved from user forum to developer forum... Mod]

[Here is the list of all Adobe forums... https://forums.adobe.com/welcome]

This topic has been closed for replies.
Correct answer Manan Joshi

Try the following code it should work

    InterfacePtr<IK2ServiceRegistry> iK2ServiceRegistry(GetExecutionContextSession(), UseDefaultIID());

    if(!iK2ServiceRegistry)

        return;

   

    InterfacePtr<IK2ServiceProvider> iK2ServiceProvider (iK2ServiceRegistry->QueryServiceProviderByClassID(kExportMgrServiceID, kExportMgrBoss));

    if(!iK2ServiceProvider)

        return;

   

    InterfacePtr<IExportManager> iExportManager(iK2ServiceProvider, IID_IEXPORTMANAGER);

    if(!iExportManager)

        return;

   

    IDocument *iDocument = Utils<ILayoutUIUtils>()->GetFrontDocument();

    if(!iDocument)

        return;

   

    UIDRef ref = ::GetUIDRef(iDocument);

    IDFile dest(WideString("/Path to folder/test.IDML"));

    iExportManager->ExportIDMLDirect(ref, &dest, kFalse);

Let me know if you still face issues

-Manan

3 replies

LucySS_00Author
Inspiring
September 22, 2017

Thank you for the advice.  I'm trying to follow the example InCopyExport that came with the C6 SDK.

I added the next code in one of the case inside the DoAction function of my ActionComponent.cpp, but the pointer to the IExportProvider always gave null.

InterfacePtr<IExportProvider> exporter (this,IID_IEXPORTPROVIDER);

                ASSERT(exporter);

                    IDFile sysFile;

                    IDFile defaultFile;

                    PMString baseFileName;

                   

                    // Get the Doc name to use as a base

                    IDocument* frontDoc = Utils<ILayoutUIUtils>()->GetFrontDocument();

                    frontDoc->GetName(baseFileName);

                   

                    PMString icDocumentFormatName("InDesign Markup (IDML)");

                    //PMString icInterchangeFormatName("InDesignInterchange");

                    PMString icDocumentFileExtension (exporter->GetExtensionForFormatName(icDocumentFormatName));

                    //PMString icInterchangeFileExtension (exporter->GetExtensionForFormatName(icInterchangeFormatName));

                    icDocumentFormatName.Translate();

                    //icInterchangeFormatName.Translate();

                   

                    ISelectionManager* selMgr = Utils<ISelectionUtils>()->GetActiveSelection();

                   

                    // Let's start off with getting a filename from the user via a dialog

                    bool16 bUseSystemDefaultDir = kTrue;

                    FileUtils::PMStringToIDFile(baseFileName, defaultFile);

                   

                    // Create the export Dialog

                    InterfacePtr<ISaveFileDialog> exportDialog((ISaveFileDialog *)CreateObject(kExportDialogBoss, IID_ISAVEFILEDIALOG));

                    ASSERT_MSG(exportDialog != nil, "Cannot create export dialog!");

                   

                    // Add the File Type to it

                    exportDialog->AddFileTypeInfo(icDocumentFormatName, icDocumentFileExtension);

                    //exportDialog->AddFileTypeInfo(icInterchangeFormatName, 0, 0, icInterchangeFileExtension);

                    //exportDialog->AddFileTypeInfo(icInterchangeFormatName, icInterchangeFileExtension);

                   

                    // Activate the dialog

                    int32 formatIndex = 0;

                    if (exportDialog->DoDialog(&defaultFile, &sysFile, &formatIndex, bUseSystemDefaultDir)) // use system default folder

                    {

                        // sysFile should be our destination at this point.

                        const PMString formatName = formatIndex == 0 ? InCopy::kInCopyMarkupFormatName : InCopy:: kInCopyInterchangeFormatName;

                        exporter->ExportToFile(sysFile, frontDoc, selMgr, formatName, kFullUI);

                }

Do you have any Idea of what I'm missing?  (I'm new in this)  thank you.

Manan JoshiCommunity ExpertCorrect answer
Community Expert
September 24, 2017

Try the following code it should work

    InterfacePtr<IK2ServiceRegistry> iK2ServiceRegistry(GetExecutionContextSession(), UseDefaultIID());

    if(!iK2ServiceRegistry)

        return;

   

    InterfacePtr<IK2ServiceProvider> iK2ServiceProvider (iK2ServiceRegistry->QueryServiceProviderByClassID(kExportMgrServiceID, kExportMgrBoss));

    if(!iK2ServiceProvider)

        return;

   

    InterfacePtr<IExportManager> iExportManager(iK2ServiceProvider, IID_IEXPORTMANAGER);

    if(!iExportManager)

        return;

   

    IDocument *iDocument = Utils<ILayoutUIUtils>()->GetFrontDocument();

    if(!iDocument)

        return;

   

    UIDRef ref = ::GetUIDRef(iDocument);

    IDFile dest(WideString("/Path to folder/test.IDML"));

    iExportManager->ExportIDMLDirect(ref, &dest, kFalse);

Let me know if you still face issues

-Manan

-Manan
LucySS_00Author
Inspiring
September 25, 2017

Thank You Manan.

I just tried it and it worked perfectly. I marked the answer as the correct one.

Thanks everyone for the support.

Inspiring
September 20, 2017

I am using IExportProvider to export as idml.

Community Expert
September 20, 2017

I don't have a direct answer to your question but i have a few pointers that could help you solve this.

  • FileTypeInfoID are defined in ShuksanID.h file(looked into CC2017 sdk), the entry that might work for you could be kInDesignPackageMarkupFileTypeInfoID. Try it if it works
  • Alternatively you could use an export service that can handle export of IDML documents, on searching i found one such class kExportMgrBoss, see if it works for you

Hope this helps you to the solution

-Manan

-Manan