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

How to export IDML Files

Guest
Aug 12, 2009 Aug 12, 2009

Hi,

I tried pdf and swf export... these files are exporting fine.

How to export idml file is there any default method or any sdk sample or code snippet is available.

If it is there  pls help me out.

Thnks

Arun

TOPICS
SDK
4.5K
Translate
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

Deleted User
Aug 18, 2009 Aug 18, 2009

Your welcome.

A small request to all: If a question is answered, would author of the question please mark this. This way it is very easy to see which questions have a solution, so that you can either study them to learn or ignore them, if you know the answers, when visiting the forum.

Translate
Guest
Aug 12, 2009 Aug 12, 2009

Use an Export Provider, see SnpImportExportXML in CodeSnippet. The format name is "InDesignMarkup"

Translate
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
Guest
Aug 16, 2009 Aug 16, 2009

Hi,

I tried this code snippet, idml file is creating but its' creating with 0 kb, no data is there.

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

Try the ExportToFile method:

               IActiveContext* theContext = gSession->GetActiveContext();

               ISelectionManager* iSelec = theContext->GetContextSelection();

               PMString formatName("InDesignMarkup");

if(theExportProvider->CanExportThisFormat(idoc, iSelec, formatName))

               {

                         theExportProvider->ExportToFile(file, idoc, iSelec, formatName, kSuppressUI);

}

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

frm where can i get this "theExportProvider" how to instantiate this.

thnks for ur response

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

SnpImportExportXML in SnippetRunner project has the code you need.

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

Hi ,

Here i mentioned the code whatever i tried pls tell  what mistake i done why it's generating empy idml file

Pls help

ErrorCode err = kFailure;
do {
  // +precondition
  InterfacePtr<IDocument> document(documentUIDRef, UseDefaultIID());
  ASSERT(document);
  if(!document) {
   CAlert::InformationAlert("document");
   break;
  }
  // -precondition
  InterfacePtr<IK2ServiceRegistry> serviceRegistry(GetExecutionContextSession(), UseDefaultIID());
  ASSERT(serviceRegistry);
  int32 exportProviderCount = serviceRegistry->GetServiceProviderCount(kExportProviderService);

  bool found = kFalse;
for (int32 exportProviderIndex = 0 ; exportProviderIndex < exportProviderCount ; exportProviderIndex++)
{
  //InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryNthServiceProvider(kExportProviderService, exportProviderIndex));
  InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryServiceProviderByClassID(kExportProviderService, kXMLExportProviderBoss));
  ASSERT(serviceProvider);
  if(!serviceProvider) {
   CAlert::InformationAlert("serviceProvider");
   break;
  }
  //InterfacePtr<IExportProvider> exportProvider(serviceProvider, IID_IEXPORTPROVIDER);
  InterfacePtr<IExportProvider> exportProvider(serviceProvider, UseDefaultIID());
  ASSERT(exportProvider);
  if(!exportProvider) {
   CAlert::InformationAlert("exportProvider");
   break;
  }
  PMString formatName("InDesignMarkup");
  CAlert::InformationAlert("before CanExportThisFormat");
  bool16 result = exportProvider->CanExportThisFormat(document, nil, formatName);
  CAlert::InformationAlert("result is false");
  if(result)
  {
   CAlert::InformationAlert("CanExportThisFormat");
   // We found the appropriate provider, now we can export
   InterfacePtr<IPMStream> stream(StreamUtil::CreateFileStreamWrite(targetFile, kOpenOut|kOpenTrunc, 'TEXT', 'CWIE'));
   ASSERT(stream);
   if(!stream) {
    CAlert::InformationAlert("stream");
    break;
   }
   stream->Open();
   if (stream->GetStreamState() != kStreamStateGood)
   {
    CAlert::InformationAlert("GetStreamState");
    stream->Close();
    break;
   }
   exportProvider->ExportToStream(stream, document, nil, formatName, kFullUI); 
   stream->Flush();
   stream->Close();
   // Assume that failure is signalled by export provider
   err = ErrorUtils::PMGetGlobalErrorCode();
  }
}
 
} while(kFalse);
return err;

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

You are only looking at the kXMLExportProviderBoss:

for (int32 exportProviderIndex = 0 ; exportProviderIndex < exportProviderCount ; exportProviderIndex++)

{

     //InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryNthServiceProvider(kExportProviderService , exportProviderIndex));

     InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryServiceProviderByClassID(kExportProviderS ervice, kXMLExportProviderBoss));

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

I had tried with "ExportViaServiceProvider" from SnpImportExportXML.

Attaching the code that I tried.

The problem is "CanExportThisFormat" turns false.

If tried without that, IDML file is created but it is of 0KB.

Could you please help us.

Translate
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
Guest
Aug 17, 2009 Aug 17, 2009

The code is basically correct. Your problem is line 15 / 16. You need to change "kXMLExportProviderBoss" to "exportProviderIndex" in the line:

InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryServiceProviderByClassID(kExportProviderService, kXMLExportProviderBoss));

You are only querying the XML Service Provider, and it can't export IDML. You also need to use line 35:

          //bool16 result = exportProvider->CanExportThisFormat(document, iSelec, formatName);

Translate
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
Guest
Aug 18, 2009 Aug 18, 2009

If we are using
InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryNthServiceProvider(kExportProviderService , exportProviderIndex));

then it creates 0KB idml file

If we are using
InterfacePtr<IK2ServiceProvider> serviceProvider(serviceRegistry->QueryServiceProviderByClassID(kExportProviderService , exportProviderIndex));

then it enters this condition
if(!serviceProvider) {}

so no file is created.

for both the cases we tried with

bool16 result = exportProvider->CanExportThisFormat(document, iSelec, formatName);

and

exportProvider->ExportToStream(stream, document, iSelec, formatName, kSuppressUI);

Could you please help with this.

Translate
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
Guest
Aug 18, 2009 Aug 18, 2009

From a CodeSnippet adjusted for IDML:

for(int32 iProvider = 0; iProvider < theRegistry->GetServiceProviderCount(kExportProviderService); iProvider++) {

          InterfacePtr<IK2ServiceProvider> theProvider(theRegistry->QueryNthServiceProvider(kExportProviderService, iProvider));

          InterfacePtr<IExportProvider> theExportProvider(theProvider, IID_IEXPORTPROVIDER);

#ifdef DEBUG    

          for (int i = 0; i < theExportProvider->CountFormats(); i++) {

                    printf("FORMAT NAME: %s\n", theExportProvider->GetNthFormatName(i).GrabCString());

          }

#endif

          PMString formatName("InDesignMarkup");

          if (theExportProvider->CanExportThisFormat(idoc, iSelec, formatName)) {

                    theExportProvider->ExportToFile(file, idoc, iSelec, formatName, kSuppressUI);

         

                    // Check Global errro here

          }

}

Translate
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
Guest
Aug 18, 2009 Aug 18, 2009

Thanks for your continuous help...

Now idml is exporting  even without ISelectionManager...

Translate
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
Guest
Aug 18, 2009 Aug 18, 2009

Your welcome.

A small request to all: If a question is answered, would author of the question please mark this. This way it is very easy to see which questions have a solution, so that you can either study them to learn or ignore them, if you know the answers, when visiting the forum.

Translate
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
Guest
Aug 19, 2009 Aug 19, 2009
LATEST

Hi,

I need one more help how to change static text color and panel color in indesign sdk through code.

can you give some code snippert or wrking example

Pls help

Translate
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
Advocate ,
Aug 18, 2009 Aug 18, 2009

Try,

deleted,

same as upper.

Translate
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