The SetMarkedContent and DocSetMarkedContent methods create marked content operators, which identify (mark) a portion of a PDF document as elements that can be processed by an application or plug-in. For instance, a structure tree for the PDF document.
System.Boolean SetMarkedContent(System.Int32 PageNumber, System.Int32 xStart, System.Int32 yStart, System.Int32 xEnd, System.Int32 yEnd, System.String Tag, System.String Attributes)
int DocSetMarkedContent(EXTDOCHANDLE edhDocument, long PageNumber, long xStart, long yStart, long xEnd, long yEnd, LPCSTR Tag, LPCSTR Attributes)
PageNumber
Page number specifying the location of the Marked Content.
xStart
X-coordinate of the start point.
yStart
Y-coordinate of the start point.
xEnd
X-coordinate of the end point.
yEnd
Y-coordinate of the end point.
Tag
Marked Content tag.
Attributes
Marked Content attributes.
edhDocument
Handle Returned by DocOpen.
The return value is True if the SetMarkedContent method succeed. Otherwise, False If the SetMarkedContent method fails.
The return value is zero if the DocSetMarkedContent method succeed. If the DocSetMarkedContent method fails, a negative value will returned.
Member of CDIntfEx.Document.
Private Sub Sample()
' Constants for Activation codes
Const strLicenseTo As String = "Amyuni PDF Converter Evaluation"
Const strActivationCode As String = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
' Declare a new cdintfex document if it does not exist in the form.
Dim pdfDoc As New CDIntfEx.Document
' The SetLicenseKey method should be called after creating an object of type
' CDIntfEx.Document to activate the advanced methods that require the object
' activation code to work properly
pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode)
' Open the document
pdfDoc.Open("c:\temp\test.pdf")
' This code adds a structure type of CHAP and assign it a name
pdfDoc.SetMarkedContent(1, 0, 0, 0, 0, "/S /Chap1 /Alt (Hello)", "/Author (Amyuni)")
pdfDoc.SetMarkedContent(2, 0, 0, 0, 0, "/S /Chap2", "/Author (Amyuni)")
pdfDoc.SetMarkedContent(3, 0, 0, 0, 0, "/S /Chap3", "/Author (Amyuni)")
' Save the document
pdfDoc.Save("c:\temp\SetMarkedContent.pdf")
End Sub
public void AutoBookmarks()
{
// Constants for Activation codes
const string strLicenseTo = "Amyuni PDF Converter Evaluation";
const string strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
// Declare a new cdintfex document if it does not exist in the form.
CDIntfEx.Document pdfDoc = new CDIntfEx.Document();
// The SetLicenseKey method should be called after creating an object of type
// CDIntfEx.Document to activate the advanced methods that require the object
// activation code to work properly
pdfDoc.SetLicenseKey(strLicenseTo, strActivationCode);
// Open the document
pdfDoc.Open(@"c:\temp\test.pdf");
// This code adds a structure type of CHAP and assign it a name
pdfDoc.SetMarkedContent(1, 0, 0, 0, 0, "/S /Chap1 /Alt (Hello)", "/Author (Amyuni)");
pdfDoc.SetMarkedContent(2, 0, 0, 0, 0, "/S /Chap2", "/Author (Amyuni)");
pdfDoc.SetMarkedContent(3, 0, 0, 0, 0, "/S /Chap3", "/Author (Amyuni)");
// Save the document
pdfDoc.Save(@"c:\temp\SetMarkedContent.pdf");
}
// PDF Converter Cpp.cpp : Defines the entry point for the console application.
//
#include <Windows.h>
#include <string>
#include <iostream>
#include "CdIntf.h"
#pragma comment (lib, "CDIntf.lib")
using namespace std;
int main()
{
// Constants for Activation codes
#define strLicenseTo "Amyuni PDF Converter Evaluation"
#define strActivationCode "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
// Declare a new cdintfex document if it does not exist in the form.
EXTDOCHANDLE pdfDoc;
// The SetLicenseKey method should be called after creating an object of type
// CDIntfEx.Document to activate the advanced methods that require the object
// activation code to work properly
SetLicenseKeyA(strLicenseTo, strActivationCode);
// Open the document
LPBYTE passWord = nullptr;
DocOpenA(&pdfDoc, "C:\temp\\test.pdf", passWord);
// This code adds a structure type of CHAP and assign it a name
DocSetMarkedContentA(pdfDoc, 1, 0, 0, 0, 0, "/S /Chap1 /Alt (Hello)", "/Author (Amyuni)");
DocSetMarkedContentA(pdfDoc, 2, 0, 0, 0, 0, "/S /Chap2", "/Author (Amyuni)");
DocSetMarkedContentA(pdfDoc, 3, 0, 0, 0, 0, "/S /Chap3", "/Author (Amyuni)");
// Save the document
DocSaveA(pdfDoc, "C:\temp\\SetMarkedContent.pdf");
// Destroy pdfDoc object
DocClose(pdfDoc);
pdfDoc = nullptr;
return 0;
}
package Example;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class Sample {
public static void main(String[] args)
{
// Constants for Activation codes
String strLicenseTo = "Amyuni PDF Converter Evaluation";
String strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA";
// Declare a new cdintfex document if it does not exist in the form.
ActiveXComponent pdfDoc = new ActiveXComponent("CDIntfEx.Document.6.5");
// The SetLicenseKey method should be called after creating an object of type
// CDIntfEx.Document to activate the advanced methods that require the object
// activation code to work properly
Dispatch.call(pdfDoc, "SetLicenseKey", strLicenseTo, strActivationCode);
// Open the document
Dispatch.call(pdfDoc, "Open", "C:\temp\\test.pdf");
// This code adds a structure type of CHAP and assign it a name
Dispatch.call(pdfDoc, "SetMarkedContent", 1, 0, 0, 0, 0, "/S /Chap1 /Alt (Hello)", "/Author (Amyuni)");
Dispatch.call(pdfDoc, "SetMarkedContent", 2, 0, 0, 0, 0, "/S /Chap2", "/Author (Amyuni)");
Dispatch.call(pdfDoc, "SetMarkedContent", 3, 0, 0, 0, 0, "/S /Chap3", "/Author (Amyuni)");
// Save the document
Dispatch.call(pdfDoc, "Save", "C:\temp\\SetMarkedContent.pdf");
// Destroy pdfDoc object
pdfDoc = null;
}
}
# Constants for Activation codes
$strLicenseTo = "Amyuni PDF Converter Evaluation"
$strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
#Declare a new cdintfex document if it does not exist in the form.
$pdfDoc = New-Object -ComObject CDIntfEx.Document.6.5
#The SetLicenseKey method should be called after creating an object of type
#CDIntfEx.Document to activate the advanced methods that require the object
#activation code to work properly
[System.__ComObject].InvokeMember('SetLicenseKey', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc, @($strLicenseTo, $strActivationCode))
#Open the document
[System.__ComObject].InvokeMember('Open', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\test.pdf")
#Set AutoBookmarks
[System.__ComObject].InvokeMember('SetMarkedContent', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,@(1, 0, 0, 0, 0, "/S /Chap1 /Alt (Hello)", "/Author (Amyuni)"))
[System.__ComObject].InvokeMember('SetMarkedContent', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,@(2, 0, 0, 0, 0, "/S /Chap2", "/Author (Amyuni)"))
[System.__ComObject].InvokeMember('SetMarkedContent', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,@(3, 0, 0, 0, 0, "/S /Chap3", "/Author (Amyuni)"))
#Save the document
[System.__ComObject].InvokeMember('Save', [System.Reflection.BindingFlags]::InvokeMethod,$null,$pdfDoc,"c:\temp\SetMarkedContent.pdf")
#Destroy pdfDoc object
$pdfDoc = $null
' Constants for Activation codes
Const strLicenseTo = "Amyuni PDF Converter Evaluation"
Const strActivationCode = "07EFCDAB0100010025AFF1801CB9441306C5739F7D452154D8833B9CECBA2ADE79E3762A69FFC354528A5F4A5811BE3204A0A439F5BA"
' Declare a new cdintfex document if it does not exist in the form.
Dim pdfDoc
Set pdfDoc = CreateObject("CDIntfEx.Document.6.5")
' The SetLicenseKey method should be called after creating an object of type
' CDIntfEx.Document to activate the advanced methods that require the object
' activation code to work properly
pdfDoc.SetLicenseKey strLicenseTo, strActivationCode
' Open the document
pdfDoc.Open "c:\temp\test.pdf"
' This code adds a structure type of CHAP and assign it a name
pdfDoc.SetMarkedContent 1, 0, 0, 0, 0, "/S /Chap1 /Alt (Hello)", "/Author (Amyuni)"
pdfDoc.SetMarkedContent 2, 0, 0, 0, 0, "/S /Chap2", "/Author (Amyuni)"
pdfDoc.SetMarkedContent 3, 0, 0, 0, 0, "/S /Chap3", "/Author (Amyuni)"
' Save the document
pdfDoc.Save "c:\temp\SetMarkedContent.pdf"
' Destroy pdfDoc object
Set pdfDoc = Nothing