Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > Sample Code
  New Posts New Posts RSS Feed - Tips for working with OCGs and Config Dictionaries
  FAQ FAQ  Forum Search   Register Register  Login Login

Tips for working with OCGs and Config Dictionaries

 Post Reply Post Reply
Author
Message
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Topic: Tips for working with OCGs and Config Dictionaries
    Posted: 10 Mar 11 at 9:15AM
(Read this for a refresher on the difference between OCGs and Layers in Quick PDF's world).

Sometimes there is a difference between the number of Optional Content Groups returned by the OptionalContentGroupCount function and the number of Optional Content Groups which are displayed in the Layers panel in Adobe Reader.

The OptionalContentGroupCount function counts all of the OCGs that are listed in the OCG array in the PDF, but there is a different dictionary in the PDF which deals with the configuration of the OCGs and whether or not specific OCGs are actually used in the conforming PDF viewer.

Most of the time the total number of OCGs found in the OCG array and the number of OCGs that the configuration dictionary directs the conforming PDF viewer to display are the same, but sometimes they are not.

This means that it is prudent to check the GetOptionalContentConfigOrderCount function to see if a configuration dictionary exists, and if one does, then to use the GetOptionalContentConfigOrderItemID, GetOptionalContentConfigOrderItemLabel, GetOptionalContentConfigOrderItemLevel, and GetOptionalContentConfigOrderItemType functions to get all of the information required to determine which OCGs are actually displayed in the Layers panel in Adobe Reader.

Here is some C# code to show you an example of how to check the configuration dictionary to see what OCGs will be shown in Adobe Reader:

QP.LoadFromFile(OpenFilePath());

int ContentConfigCount = QP.GetOptionalContentConfigCount();

txtOutput.AppendText("Total Content Config Count: " + ContentConfigCount);
txtOutput.AppendText(Environment.NewLine);

int OrderCount = QP.GetOptionalContentConfigOrderCount(1);

for (int i = 1; i <= OrderCount; i++)
{
int OrderItemID = QP.GetOptionalContentConfigOrderItemID(1, i);
string OrderItemLabel = QP.GetOptionalContentConfigOrderItemLabel(1, i);
int OrderItemLevel = QP.GetOptionalContentConfigOrderItemLevel(1, i);
int OrderItemType = QP.GetOptionalContentConfigOrderItemType(1, i);

txtOutput.AppendText("Order Item ID: " + OrderItemID);
txtOutput.AppendText(Environment.NewLine);

txtOutput.AppendText("Order Item Label: " + OrderItemLabel);
txtOutput.AppendText(Environment.NewLine);

txtOutput.AppendText("Order Item Level: " + OrderItemLevel);
txtOutput.AppendText(Environment.NewLine);

txtOutput.AppendText("Order Item Type: " + OrderItemType);
txtOutput.AppendText(Environment.NewLine);
}


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store