Print Page | Close Window

Delete optionalcontentgroup

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3253
Printed Date: 02 Feb 26 at 4:01PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Delete optionalcontentgroup
Posted By: nieguizhi
Subject: Delete optionalcontentgroup
Date Posted: 25 Jan 16 at 8:49AM
Hi, I use the following code to delete the optionalcontentgroup, however it does not remove the optionalcontentgroup. Could somebody give me some suggestion, thanks! look forward to your replay.

DPL.LoadFromFile(L"contentstream.pdf", L"");
int contentNum = DPL.ContentStreamCount();

int optionNum = DPL.OptionalContentGroupCount();

for (int i=0; i<=optionNum; ++i)
{
int optionID = DPL.GetOptionalContentGroupID(i);
CStringW optionalName = DPL.GetOptionalContentGroupName(optionID).c_str();
DPL.DeleteOptionalContentGroup(optionID);
}
DPL.SaveToFile(L"no_option.pdf");



Replies:
Posted By: tfrost
Date Posted: 25 Jan 16 at 12:21PM
You should first re-sequence the loop. You should always start with the highest value and descend from the top down when deleting, because deleting the value i makes the next item become i.  Also the content group ID index base is documented as 1, not 0.


Posted By: nieguizhi
Date Posted: 26 Jan 16 at 4:10AM
could you mean this:
for (int i=optionNum; i>=1; --i) 
{
 int optionID = DPL.GetOptionalContentGroupID(i);
DPL.DeleteOptionalContentGroup(optionID);
 }

thanks!



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk