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

InDesign Server 'CreateRectangleSpline' creating extra page

Community Beginner ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

I have updated a plugin to 2021 from 2020, and when running and it gets to the CreateRectangleSpline call it will create an extra page on the spread. This then gives an error later when deleting the spread.

 

sample code

// Open Document
InterfacePtr<ICommand> openDocCmd(Utils<IDocumentCommands>()->CreateOpenCommand(file, kSuppressUI, IOpenFileCmdData::kOpenCopy, IOpenFileCmdData::kUseLockFile, kFalse));
if (CmdUtils::ProcessCommand(openDocCmd) != kSuccess) {
	ASSERT_FAIL("openDocCmd failed");
	break;
}

// Pass the UIDRef of the new document back to the caller.
const UIDList& openDocCmdUIDList = openDocCmd->GetItemListReference();
UIDRef docRef = openDocCmdUIDList.GetRef(0);
if (docRef == UIDRef::gNull) {
	ASSERT_FAIL("openDocCmd returned invalid document UIDRef!");
	break;
}

// Create new Spread
InterfacePtr<ICommand> iNewSpreadCmd(CmdUtils::CreateCommand(kNewSpreadCmdBoss));
if (iNewSpreadCmd == nil) {
	ASSERT(iNewSpreadCmd);
	break;
}
InterfacePtr<INewSpreadCmdData> iNewSpreadCmdData(iNewSpreadCmd, UseDefaultIID());
if (iNewSpreadCmdData == nil) {
	ASSERT(iNewSpreadCmdData);
	break;
}

K2Vector<PMRect> one_big_page;

one_big_page.push_back(PMRect(0, 0, 14173, 14173));
iNewSpreadCmdData->SetNewSpreadCmdData(docRef, 1, ISpreadList::kAtTheEnd, INewSpreadCmdData::kPagesMayShuffleThroughNewSpread, 1, &one_big_page, nil, nil);

InterfacePtr<ISpreadList> spreads(docRef, UseDefaultIID());
int final_n = spreads->GetSpreadCount();
UIDRef spread(docRef.GetDataBase(), spreads->GetNthSpreadUID(final_n - 1));
InterfacePtr<ILayerList> doc_layers(docRef, IID_ILAYERLIST);
UIDRef spreadLayerRef;

for (int i = 0, n = doc_layers->GetCount(); i < n; i++)
{
	IDocumentLayer* doc_layer = doc_layers->QueryLayer(i);
	if (doc_layer->IsLocked())
		continue;
	if (!doc_layer->IsVisible())
		continue;

	/* The "parent" is the corresponding ISpreadLayer */
	InterfacePtr<ISpread>		ispread(spread, UseDefaultIID());
	InterfacePtr<ISpreadLayer> slayer(ispread->QueryLayer(doc_layer));
	spreadLayerRef = ::GetUIDRef(slayer);
	break;
}
InterfacePtr<ISpread>		ispread(spread, UseDefaultIID());
int pages = ispread->GetNumPages();

// Create frame
PMPoint startPoint(0, 0);		// Upper Left in Page Coords
PMPoint endPoint(300, 300);		// Size of rectangle
PMRect bbox(startPoint, endPoint);

UIDRef new_box = Utils<IPathUtils>()->CreateRectangleSpline(
	spreadLayerRef,
	bbox,
	INewPageItemCmdData::kTextFrameAttributes,
	kTrue,			// bAllowDefaultStandOff
	Transform::PasteboardCoordinates());

if (!new_box) {
	ASSERT(new_box);
	break;
}
int newpages = ispread->GetNumPages();
ASSERT(pages == newpages);		

Has anyone see this or know if there are changes needed for 2021 to stop this.

 

Thanks

Views

97

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 ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

When you open the document with UI, and show rulers: is there anything special about the zero point, e.g. moved to the far right?

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 ,
Jul 21, 2021 Jul 21, 2021

Copy link to clipboard

Copied

LATEST

Thanks for the info Dirk.

 

I looked at the rules of the document and there are not at the top left. I have got it to go wrong with a new document with 0,0 at top left.

 

I missed the code to run the create new spread.

 

when running on InDesign server 16.0 and it's good. 

 

When running on InDesign server 16.2.1 it fails.

 

Thanks

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