Copy link to clipboard
Copied
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
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.
Copy link to clipboard
Copied
Use an Export Provider, see SnpImportExportXML in CodeSnippet. The format name is "InDesignMarkup"
Copy link to clipboard
Copied
Hi,
I tried this code snippet, idml file is creating but its' creating with 0 kb, no data is there.
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
frm where can i get this "theExportProvider" how to instantiate this.
thnks for ur response
Copy link to clipboard
Copied
SnpImportExportXML in SnippetRunner project has the code you need.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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));
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
}
}
Copy link to clipboard
Copied
Thanks for your continuous help...
Now idml is exporting even without ISelectionManager...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Try,
deleted,
same as upper.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more