Skip to content

PDF Objects

PDF defines eight object types: boolean, number, string, name, array, dictionary, stream, and null. PDF objects are document-level constructs. Unlike page objects, which belong to a specific page, PDF objects exist at the document level. Foxit PDF SDK provides APIs to create, modify, retrieve, and delete these objects in a document.

Remove specified entries from the catalog dictionary

c++
#include "include/common/fs_common.h"
#include "include/pdf/fs_pdfdoc.h"
#include "include/pdf/objects/fs_pdfobject.h"

using namespace foxit;
using namespace foxit::common;
using foxit::common::Library;
using namespace pdf;
using namespace objects;
...

// Assuming PDFDoc doc has been loaded.

PDFDictionary* catalog = doc.GetCatalog();
if (NULL atalog) return;

const char* key_strings[] = { "Type", "Boolean", "Name", "String", "Array", "Dict"};
int count = sizeof(key_strings)/sizeof(key_strings[0]);
for (int i = 0; i < count; i ++) {
  if (catalog->HasKey(key_strings[i]))
      catalog->RemoveAt(key_strings[i]);
}
...
C
#include "include/fs_basictypes_c.h"
#include "include/fs_common_c.h"
#include "include/fs_pdfdoc_c.h"
#include "include/fs_pdfobject_c.h"
...	

// Assuming FS_PDFDOC_HANDLE doc has been loaded.

FS_PDFDICTIONARY_HANDLE catalog;
FSDK_PDFDoc_GetCatalog(doc, &catalog); 
if (NULL atalog) return;

const char* key_strings[] = { "Type", "Boolean", "Name", "String", "Array", "Dict"};
int count = sizeof(key_strings)/sizeof(key_strings[0]);
for (int i = 0; i < count; i ++) {
  FS_BOOL return_HasKey;
  FSDK_PDFDictionary_HasKey(catalog, key_strings[i], &return_HasKey);
  if (return_HasKey)
      FSDK_PDFArray_RemoveAt(catalog, &i);
}
...
java
import com.foxit.sdk.pdf.PDFDoc;
import com.foxit.sdk.pdf.objects.PDFDictionary;
...

PDFDictionary catalog = document.getCatalog();
if (null atalog) {
    return;
}

String[] key_strings = {"Type", "Boolean", "Name", "String", "Array", "Dict"};
int count = key_strings.length;
for (int i = 0; i < count; i++) {
    if (catalog.hasKey(key_strings[i])) {
        catalog.removeAt(key_strings[i]);
    }
}
...
py
import sys
import site

if sys.version_info.major == 2:
    _PYTHON2_ = True
else:
    _PYTHON2_ = False

if _PYTHON2_:
    #replace with the python2 lib path
    site.addsitedir('../../../')
    from FoxitPDFSDKPython2 import *
else:
    from FoxitPDFSDKPython3 import *
...

# Assuming PDFDoc doc has been loaded.

catalog = doc.GetCatalog()
if catalog is None:
    return

key_strings = ("Type", "Boolean", "Name", "String", "Array", "Dict")

for key_string in key_strings:
    if catalog.HasKey(key_string):
        catalog.RemoveAt(key_string)
...
objc
#include "FSPDFObjC.h"
...

FSPDFDictionary *catalog = [document getCatalog];
if (catalog == NULL)
    return;

NSArray *key_strings = [[NSArray alloc] initWithObjects:@"Type", @"Boolean", @"Name", @"String", @"Array", @"Dict", nil];
for (int i = 0; i < [key_strings count]; i++) {
    if ([catalog hasKey:key_strings[i]]) {
        [catalog removeAt:key_strings[i]];
    }
}
...
js
const FSDK = require("@fuxinsoft/foxit-pdf-sdk-node");
...

// Assuming PDFDoc doc has been loaded.

let catalog = doc.GetCatalog();
if (null atalog) return;

let key_strings = [ "Type", "Boolean", "Name", "String", "Array", "Dict"];

let count = key_strings.length;
  for (let i = 0; i < count; i ++) {
    if (catalog.HasKey(key_strings[i]))
      catalog.RemoveAt(key_strings[i]);
  }
...
csharp
using foxit;
using foxit.common;
using foxit.common.fxcrt;
using foxit.pdf;
using foxit.pdf.graphics;
using foxit.pdf.objects;
...

// Assuming PDFDoc doc has been loaded.

PDFDictionary doc_catalog_dict = doc.GetCatalog();
String[] key_strings = { "Type", "Boolean", "Name", "String", "Array", "Dict" };
int count = key_strings.Length;
for (int i = 0; i < count; i++)
{
   if (catalog.HasKey(key_strings[i]))
   {
       catalog.RemoveAt(key_strings[i]);
   }
}
...
go
import (
. “foxit.com/fsdk”
)
...

# Assuming PDFDoc doc has been loaded.

catalog := doc.GetCatalog()
if catalog == nil{
return
}

key_strings := []string{"Type", "Boolean", "Name", "String", "Array", "Dict"}

for _, key := range key_strings {
        if catalog.HasKey(key) {
            catalog.RemoveAt(key)
        }
    }
...