Sample C# code for using Apryse SDK to work with PDF page labels. PDF page labels can be used to describe a page, which is used to allow for non-sequential page numbering or the addition of arbitrary labels for a page (such as the inclusion of Roman numerals at the beginning of a book). Learn more about our Server SDK and PDF Editing & Manipulation Library.
1//
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3//
4
5using System;
6using pdftron;
7using pdftron.SDF;
8using pdftron.PDF;
9
10//-----------------------------------------------------------------------------------
11// The sample illustrates how to work with PDF page labels.
12//
13// PDF page labels can be used to describe a page. This is used to
14// allow for non-sequential page numbering or the addition of arbitrary
15// labels for a page (such as the inclusion of Roman numerals at the
16// beginning of a book). PDFNet PageLabel object can be used to specify
17// the numbering style to use (for example, upper- or lower-case Roman,
18// decimal, and so forth), the starting number for the first page,
19// and an arbitrary prefix to be pre-appended to each number (for
20// example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
21//-----------------------------------------------------------------------------------
22namespace PageLabelsTestCS
23{
24 class Class1
25 {
26 private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
27 static Class1() {}
28
29 // Relative path to the folder containing test files.
30 const string input_path = "../../../../TestFiles/";
31 const string output_path = "../../../../TestFiles/Output/";
32
33 /// <summary>
34 /// The main entry point for the application.
35 /// </summary>
36 [STAThread]
37 static void Main(string[] args)
38 {
39 PDFNet.Initialize(PDFTronLicense.Key);
40 try
41 {
42 //-----------------------------------------------------------
43 // Example 1: Add page labels to an existing or newly created PDF
44 // document.
45 //-----------------------------------------------------------
46 {
47 using (PDFDoc doc = new PDFDoc(input_path + "newsletter.pdf"))
48 {
49 doc.InitSecurityHandler();
50
51 // Create a page labeling scheme that starts with the first page in
52 // the document (page 1) and is using uppercase roman numbering
53 // style.
54 doc.SetPageLabel(1, PageLabel.Create(doc, PageLabel.Style.e_roman_uppercase, "My Prefix ", 1));
55
56 // Create a page labeling scheme that starts with the fourth page in
57 // the document and is using decimal arabic numbering style.
58 // Also the numeric portion of the first label should start with number
59 // 4 (otherwise the first label would be "My Prefix 1").
60 PageLabel L2 = PageLabel.Create(doc, PageLabel.Style.e_decimal, "My Prefix ", 4);
61 doc.SetPageLabel(4, L2);
62
63 // Create a page labeling scheme that starts with the seventh page in
64 // the document and is using alphabetic numbering style. The numeric
65 // portion of the first label should start with number 1.
66 PageLabel L3 = PageLabel.Create(doc, PageLabel.Style.e_alphabetic_uppercase, "My Prefix ", 1);
67 doc.SetPageLabel(7, L3);
68
69 doc.Save(output_path + "newsletter_with_pagelabels.pdf", SDFDoc.SaveOptions.e_linearized);
70 Console.WriteLine("Done. Result saved in newsletter_with_pagelabels.pdf...");
71 }
72 }
73
74 //-----------------------------------------------------------
75 // Example 2: Read page labels from an existing PDF document.
76 //-----------------------------------------------------------
77 {
78 using (PDFDoc doc = new PDFDoc(output_path + "newsletter_with_pagelabels.pdf"))
79 {
80 doc.InitSecurityHandler();
81
82 PageLabel label;
83 int page_num = doc.GetPageCount();
84 for (int i=1; i<=page_num; ++i)
85 {
86 Console.Write("Page number: {0}", i);
87 label = doc.GetPageLabel(i);
88 if (label.IsValid()) {
89 Console.WriteLine(" Label: {0}", label.GetLabelTitle(i));
90 }
91 else {
92 Console.WriteLine(" No Label.");
93 }
94 }
95 }
96 }
97
98 //-----------------------------------------------------------
99 // Example 3: Modify page labels from an existing PDF document.
100 //-----------------------------------------------------------
101 {
102 using (PDFDoc doc = new PDFDoc(output_path + "newsletter_with_pagelabels.pdf"))
103 {
104 doc.InitSecurityHandler();
105
106 // Remove the alphabetic labels from example 1.
107 doc.RemovePageLabel(7);
108
109 // Replace the Prefix in the decimal lables (from example 1).
110 PageLabel label = doc.GetPageLabel(4);
111 if (label.IsValid()) {
112 label.SetPrefix("A");
113 label.SetStart(1);
114 }
115
116 // Add a new label
117 PageLabel new_label = PageLabel.Create(doc, PageLabel.Style.e_decimal, "B", 1);
118 doc.SetPageLabel(10, new_label); // starting from page 10.
119
120 doc.Save(output_path + "newsletter_with_pagelabels_modified.pdf", SDFDoc.SaveOptions.e_linearized);
121 Console.WriteLine("Done. Result saved in newsletter_with_pagelabels_modified.pdf...");
122
123 int page_num = doc.GetPageCount();
124 for (int i=1; i<=page_num; ++i)
125 {
126 Console.Write("Page number: {0}", i);
127 label = doc.GetPageLabel(i);
128 if (label.IsValid()) {
129 Console.WriteLine(" Label: {0}", label.GetLabelTitle(i));
130 }
131 else {
132 Console.WriteLine(" No Label.");
133 }
134 }
135 }
136 }
137
138 //-----------------------------------------------------------
139 // Example 4: Delete all page labels in an existing PDF document.
140 //-----------------------------------------------------------
141 {
142 using (PDFDoc doc = new PDFDoc(output_path + "newsletter_with_pagelabels.pdf"))
143 {
144 doc.GetRoot().Erase("PageLabels");
145 // ...
146 }
147 }
148 }
149 catch (pdftron.Common.PDFNetException e)
150 {
151 Console.WriteLine(e.Message);
152 }
153 PDFNet.Terminate();
154 }
155 }
156}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6#include <PDF/PDFNet.h>
7#include <PDF/PDFDoc.h>
8#include <PDF/PageLabel.h>
9
10#include <iostream>
11#include "../../LicenseKey/CPP/LicenseKey.h"
12
13using namespace std;
14using namespace pdftron;
15using namespace PDF;
16
17//-----------------------------------------------------------------------------------
18// The sample illustrates how to work with PDF page labels.
19//
20// PDF page labels can be used to describe a page. This is used to
21// allow for non-sequential page numbering or the addition of arbitrary
22// labels for a page (such as the inclusion of Roman numerals at the
23// beginning of a book). PDFNet PageLabel object can be used to specify
24// the numbering style to use (for example, upper- or lower-case Roman,
25// decimal, and so forth), the starting number for the first page,
26// and an arbitrary prefix to be pre-appended to each number (for
27// example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
28//-----------------------------------------------------------------------------------
29int main(int argc, char *argv[])
30{
31 int ret = 0;
32 PDFNet::Initialize(LicenseKey);
33
34 // Relative path to the folder containing test files.
35 string input_path = "../../TestFiles/";
36 string output_path = "../../TestFiles/Output/";
37
38 try
39 {
40 //-----------------------------------------------------------
41 // Example 1: Add page labels to an existing or newly created PDF
42 // document.
43 //-----------------------------------------------------------
44 {
45 PDFDoc doc((input_path + "newsletter.pdf").c_str());
46 doc.InitSecurityHandler();
47
48 // Create a page labeling scheme that starts with the first page in
49 // the document (page 1) and is using uppercase roman numbering
50 // style.
51 PageLabel L1 = PageLabel::Create(doc, PageLabel::e_roman_uppercase, "My Prefix ", 1);
52 doc.SetPageLabel(1, L1);
53
54 // Create a page labeling scheme that starts with the fourth page in
55 // the document and is using decimal Arabic numbering style.
56 // Also the numeric portion of the first label should start with number
57 // 4 (otherwise the first label would be "My Prefix 1").
58 PageLabel L2 = PageLabel::Create(doc, PageLabel::e_decimal, "My Prefix ", 4);
59 doc.SetPageLabel(4, L2);
60
61 // Create a page labeling scheme that starts with the seventh page in
62 // the document and is using alphabetic numbering style. The numeric
63 // portion of the first label should start with number 1.
64 PageLabel L3 = PageLabel::Create(doc, PageLabel::e_alphabetic_uppercase, "My Prefix ", 1);
65 doc.SetPageLabel(7, L3);
66
67 doc.Save((output_path + "newsletter_with_pagelabels.pdf").c_str(), SDF::SDFDoc::e_linearized, 0);
68 cout << "Done. Result saved in newsletter_with_pagelabels.pdf..." << endl;
69 }
70
71 //-----------------------------------------------------------
72 // Example 2: Read page labels from an existing PDF document.
73 //-----------------------------------------------------------
74 {
75 PDFDoc doc((output_path + "newsletter_with_pagelabels.pdf").c_str());
76 doc.InitSecurityHandler();
77
78 PageLabel label;
79 int page_num = doc.GetPageCount();
80 for (int i=1; i<=page_num; ++i)
81 {
82 cout << "Page number: " << i;
83 label = doc.GetPageLabel(i);
84 if (label.IsValid()) {
85 cout << " Label: " << label.GetLabelTitle(i) << endl;
86 }
87 else {
88 cout << " No Label." << endl;
89 }
90 }
91 }
92
93 //-----------------------------------------------------------
94 // Example 3: Modify page labels from an existing PDF document.
95 //-----------------------------------------------------------
96 {
97 PDFDoc doc((output_path + "newsletter_with_pagelabels.pdf").c_str());
98 doc.InitSecurityHandler();
99
100 // Remove the alphabetic labels from example 1.
101 doc.RemovePageLabel(7);
102
103 // Replace the Prefix in the decimal labels (from example 1).
104 PageLabel label = doc.GetPageLabel(4);
105 if (label.IsValid()) {
106 label.SetPrefix("A");
107 label.SetStart(1);
108 }
109
110 // Add a new label
111 PageLabel new_label = PageLabel::Create(doc, PageLabel::e_decimal, "B", 1);
112 doc.SetPageLabel(10, new_label); // starting from page 10.
113
114 doc.Save((output_path + "newsletter_with_pagelabels_modified.pdf").c_str(), SDF::SDFDoc::e_linearized, 0);
115 cout << "Done. Result saved in newsletter_with_pagelabels_modified.pdf..." << endl;
116
117 int page_num = doc.GetPageCount();
118 for (int i=1; i<=page_num; ++i)
119 {
120 cout << "Page number: " << i;
121 label = doc.GetPageLabel(i);
122 if (label.IsValid()) {
123 cout << " Label: " << label.GetLabelTitle(i) << endl;
124 }
125 else {
126 cout << " No Label." << endl;
127 }
128 }
129 }
130
131 //-----------------------------------------------------------
132 // Example 4: Delete all page labels in an existing PDF document.
133 //-----------------------------------------------------------
134 {
135 PDFDoc doc((output_path + "newsletter_with_pagelabels.pdf").c_str());
136 doc.GetRoot().Erase("PageLabels");
137 // ...
138 }
139 }
140 catch(Common::Exception& e)
141 {
142 cout << e << endl;
143 ret = 1;
144 }
145 catch(...)
146 {
147 cout << "Unknown Exception" << endl;
148 ret = 1;
149 }
150
151 PDFNet::Terminate();
152 return ret;
153}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
3// Consult LICENSE.txt regarding license information.
4//---------------------------------------------------------------------------------------
5
6package main
7import (
8 "fmt"
9 "strconv"
10 . "pdftron"
11)
12
13import "pdftron/Samples/LicenseKey/GO"
14
15//-----------------------------------------------------------------------------------
16// The sample illustrates how to work with PDF page labels.
17//
18// PDF page labels can be used to describe a page. This is used to
19// allow for non-sequential page numbering or the addition of arbitrary
20// labels for a page (such as the inclusion of Roman numerals at the
21// beginning of a book). PDFNet PageLabel object can be used to specify
22// the numbering style to use (for example, upper- or lower-case Roman,
23// decimal, and so forth), the starting number for the first page,
24// and an arbitrary prefix to be pre-appended to each number (for
25// example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
26//-----------------------------------------------------------------------------------
27
28// Relative path to the folder containing the test files.
29var inputPath = "../../TestFiles/"
30var outputPath = "../../TestFiles/Output/"
31
32func main(){
33 // Initialize PDFNet
34 PDFNetInitialize(PDFTronLicense.Key)
35
36 //-----------------------------------------------------------
37 // Example 1: Add page labels to an existing or newly created PDF
38 // document.
39 //-----------------------------------------------------------
40
41 doc := NewPDFDoc(inputPath + "newsletter.pdf")
42 doc.InitSecurityHandler()
43
44 // Create a page labeling scheme that starts with the first page in
45 // the document (page 1) and is using uppercase roman numbering
46 // style.
47 L1 := PageLabelCreate(doc.GetSDFDoc(), PageLabelE_roman_uppercase, "My Prefix ", 1)
48 doc.SetPageLabel(1, L1)
49
50 // Create a page labeling scheme that starts with the fourth page in
51 // the document and is using decimal arabic numbering style.
52 // Also the numeric portion of the first label should start with number
53 // 4 (otherwise the first label would be "My Prefix 1").
54 L2 := PageLabelCreate(doc.GetSDFDoc(), PageLabelE_decimal, "My Prefix ", 4)
55 doc.SetPageLabel(4, L2)
56
57 // Create a page labeling scheme that starts with the seventh page in
58 // the document and is using alphabetic numbering style. The numeric
59 // portion of the first label should start with number 1.
60 L3 := PageLabelCreate(doc.GetSDFDoc(), PageLabelE_alphabetic_uppercase, "My Prefix ", 1)
61 doc.SetPageLabel(7, L3)
62
63 doc.Save(outputPath + "newsletter_with_pagelabels.pdf", uint(SDFDocE_linearized))
64 doc.Close()
65 fmt.Println("Done. Result saved in newsletter_with_pagelabels.pdf...")
66
67 //-----------------------------------------------------------
68 // Example 2: Read page labels from an existing PDF document.
69 //-----------------------------------------------------------
70
71 doc = NewPDFDoc(outputPath + "newsletter_with_pagelabels.pdf")
72 doc.InitSecurityHandler()
73
74 label := NewPageLabel()
75 pageNum := doc.GetPageCount()
76
77 i := 1
78 for i <= pageNum{
79 fmt.Println("Page number: " + strconv.Itoa(i))
80 label = doc.GetPageLabel(i)
81
82 if label.IsValid(){
83 fmt.Println("Label: " + label.GetLabelTitle(i))
84 }else{
85 fmt.Println("No Label.")
86 }
87 i = i + 1
88 }
89
90 doc.Close()
91
92 //-----------------------------------------------------------
93 // Example 3: Modify page labels from an existing PDF document.
94 //-----------------------------------------------------------
95
96 doc = NewPDFDoc(outputPath + "newsletter_with_pagelabels.pdf")
97 doc.InitSecurityHandler()
98
99 // Remove the alphabetic labels from example i.
100 doc.RemovePageLabel(7)
101
102 // Replace the Prefix in the decimal labels (from example 1).
103 label = doc.GetPageLabel(4)
104 if label.IsValid(){
105 label.SetPrefix("A")
106 label.SetStart(1)
107 }
108 // Add a new label
109 newLabel := PageLabelCreate(doc.GetSDFDoc(), PageLabelE_decimal, "B", 1)
110 doc.SetPageLabel(10, newLabel) // starting from page 10
111
112 doc.Save(outputPath + "newsletter_with_pagelabels_modified.pdf", uint(SDFDocE_linearized))
113 fmt.Println("Done. Result saved in newsletter_with_pagelabels_modified.pdf...")
114
115 pageNum = doc.GetPageCount()
116 i = 1
117 for i <= pageNum{
118 fmt.Println("Page number: " + strconv.Itoa(i))
119 label = doc.GetPageLabel(i)
120 if label.IsValid(){
121 fmt.Println("Label: " + label.GetLabelTitle(i))
122 }else{
123 fmt.Println("No Label.")
124 }
125 i = i + 1
126 }
127
128 doc.Close()
129
130 //-----------------------------------------------------------
131 // Example 4: Delete all page labels in an existing PDF document.
132 //-----------------------------------------------------------
133
134 doc = NewPDFDoc(outputPath + "newsletter_with_pagelabels.pdf")
135 doc.GetRoot().Erase("PageLabels")
136 doc.Save(outputPath + "newsletter_with_pagelabels_removed.pdf", uint(SDFDocE_linearized))
137
138 doc.Close()
139 PDFNetTerminate()
140}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6import com.pdftron.pdf.*;
7import com.pdftron.sdf.SDFDoc;
8
9//-----------------------------------------------------------------------------------
10// The sample illustrates how to work with PDF page labels.
11//
12// PDF page labels can be used to describe a page. This is used to
13// allow for non-sequential page numbering or the addition of arbitrary
14// labels for a page (such as the inclusion of Roman numerals at the
15// beginning of a book). PDFNet PageLabel object can be used to specify
16// the numbering style to use (for example, upper- or lower-case Roman,
17// decimal, and so forth), the starting number for the first page,
18// and an arbitrary prefix to be pre-appended to each number (for
19// example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
20//-----------------------------------------------------------------------------------
21public class PageLabelsTest {
22 public static void main(String[] args) {
23 PDFNet.initialize(PDFTronLicense.Key());
24
25 // Relative path to the folder containing test files.
26 String input_path = "../../TestFiles/";
27 String output_path = "../../TestFiles/Output/";
28
29 try {
30 //-----------------------------------------------------------
31 // Example 1: Add page labels to an existing or newly created PDF
32 // document.
33 //-----------------------------------------------------------
34 try (PDFDoc doc = new PDFDoc((input_path + "newsletter.pdf"))) {
35 doc.initSecurityHandler();
36
37 // Create a page labeling scheme that starts with the first page in
38 // the document (page 1) and is using uppercase roman numbering
39 // style.
40 doc.setPageLabel(1, PageLabel.create(doc, PageLabel.e_roman_uppercase, "My Prefix ", 1));
41
42 // Create a page labeling scheme that starts with the fourth page in
43 // the document and is using decimal arabic numbering style.
44 // Also the numeric portion of the first label should start with number
45 // 4 (otherwise the first label would be "My Prefix 1").
46 PageLabel L2 = PageLabel.create(doc, PageLabel.e_decimal, "My Prefix ", 4);
47 doc.setPageLabel(4, L2);
48
49 // Create a page labeling scheme that starts with the seventh page in
50 // the document and is using alphabetic numbering style. The numeric
51 // portion of the first label should start with number 1.
52 PageLabel L3 = PageLabel.create(doc, PageLabel.e_alphabetic_uppercase, "My Prefix ", 1);
53 doc.setPageLabel(7, L3);
54
55 doc.save(output_path + "newsletter_with_pagelabels.pdf", SDFDoc.SaveMode.LINEARIZED, null);
56 System.out.println("Done. Result saved in newsletter_with_pagelabels.pdf...");
57 }
58
59 //-----------------------------------------------------------
60 // Example 2: Read page labels from an existing PDF document.
61 //-----------------------------------------------------------
62 try (PDFDoc doc = new PDFDoc((output_path + "newsletter_with_pagelabels.pdf"))) {
63 doc.initSecurityHandler();
64
65 PageLabel label;
66 int page_num = doc.getPageCount();
67 for (int i = 1; i <= page_num; ++i) {
68 System.out.println("Page number: " + i);
69 label = doc.getPageLabel(i);
70 if (label.isValid()) {
71 System.out.println(" Label: " + label.getLabelTitle(i));
72 } else {
73 System.out.println(" No Label.");
74 }
75 }
76 }
77
78 //-----------------------------------------------------------
79 // Example 3: Modify page labels from an existing PDF document.
80 //-----------------------------------------------------------
81 try (PDFDoc doc = new PDFDoc((output_path + "newsletter_with_pagelabels.pdf"))) {
82 doc.initSecurityHandler();
83
84 // Remove the alphabetic labels from example 1.
85 doc.removePageLabel(7);
86
87 // Replace the Prefix in the decimal lables (from example 1).
88 PageLabel label = doc.getPageLabel(4);
89 if (label.isValid()) {
90 label.setPrefix("A");
91 label.setStart(1);
92 }
93
94 // Add a new label
95 PageLabel new_label = PageLabel.create(doc, PageLabel.e_decimal, "B", 1);
96 doc.setPageLabel(10, new_label); // starting from page 10.
97
98 doc.save(output_path + "newsletter_with_pagelabels_modified.pdf", SDFDoc.SaveMode.LINEARIZED, null);
99 System.out.println("Done. Result saved in newsletter_with_pagelabels_modified.pdf...");
100
101 int page_num = doc.getPageCount();
102 for (int i = 1; i <= page_num; ++i) {
103 System.out.print("Page number: " + i);
104 label = doc.getPageLabel(i);
105 if (label.isValid()) {
106 System.out.println(" Label: " + label.getLabelTitle(i));
107 } else {
108 System.out.println(" No Label.");
109 }
110 }
111 }
112
113 //-----------------------------------------------------------
114 // Example 4: Delete all page labels in an existing PDF document.
115 //-----------------------------------------------------------
116 try (PDFDoc doc = new PDFDoc((output_path + "newsletter_with_pagelabels.pdf"))) {
117 doc.getRoot().erase("PageLabels");
118 // ...
119 }
120
121 } catch (Exception e) {
122 e.printStackTrace();
123 }
124
125 PDFNet.terminate();
126 }
127}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6//-----------------------------------------------------------------------------------
7// The sample illustrates how to work with PDF page labels.
8//
9// PDF page labels can be used to describe a page. This is used to
10// allow for non-sequential page numbering or the addition of arbitrary
11// labels for a page (such as the inclusion of Roman numerals at the
12// beginning of a book). PDFNet PageLabel object can be used to specify
13// the numbering style to use (for example, upper- or lower-case Roman,
14// decimal, and so forth), the starting number for the first page,
15// and an arbitrary prefix to be pre-appended to each number (for
16// example, 'A-' to generate 'A-1', 'A-2', 'A-3', and so forth.)
17//-----------------------------------------------------------------------------------
18
19const { PDFNet } = require('@pdftron/pdfnet-node');
20const PDFTronLicense = require('../LicenseKey/LicenseKey');
21
22((exports) => {
23 'use strict';
24
25 exports.runPageLabelsTest = () => {
26 const main = async () => {
27 const inputPath = '../TestFiles/';
28 const outputPath = inputPath + 'Output/';
29 const outputFile = outputPath + 'newsletter_with_pagelabels.pdf';
30
31 try {
32 //-----------------------------------------------------------
33 // Example 1: Add page labels to an existing or newly created PDF
34 // document.
35 //-----------------------------------------------------------
36 {
37 const doc = await PDFNet.PDFDoc.createFromFilePath(inputPath + 'newsletter.pdf');
38 doc.initSecurityHandler();
39
40 // Create a page labeling scheme that starts with the first page in
41 // the document (page 1) and is using uppercase roman numbering
42 // style.
43 const L1 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_roman_uppercase, 'My Prefix ', 1);
44 doc.setPageLabel(1, L1);
45
46 // Create a page labeling scheme that starts with the fourth page in
47 // the document and is using decimal Arabic numbering style.
48 // Also the numeric portion of the first label should start with number
49 // 4 (otherwise the first label would be 'My Prefix 1').
50 const L2 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_decimal, 'My Prefix ', 4);
51 doc.setPageLabel(4, L2);
52
53 // Create a page labeling scheme that starts with the seventh page in
54 // the document and is using alphabetic numbering style. The numeric
55 // portion of the first label should start with number 1.
56 const L3 = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_alphabetic_uppercase, 'My Prefix ', 1);
57 doc.setPageLabel(7, L3);
58
59 doc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
60 console.log('Done. Result saved in newsletter_with_pagelabels.pdf...');
61 }
62
63 //-----------------------------------------------------------
64 // Example 2: Read page labels from an existing PDF document.
65 //-----------------------------------------------------------
66 {
67 const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
68 doc.initSecurityHandler();
69
70 const page_num = await doc.getPageCount();
71 for (let i = 1; i <= page_num; ++i) {
72 console.log('Page number: ' + i);
73 const label = await doc.getPageLabel(i);
74 if (await label.isValid()) {
75 console.log(' Label: ' + await label.getLabelTitle(i));
76 }
77 else {
78 console.log(' No Label.');
79 }
80 }
81 }
82
83 //-----------------------------------------------------------
84 // Example 3: Modify page labels from an existing PDF document.
85 //-----------------------------------------------------------
86 {
87 const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
88 doc.initSecurityHandler();
89
90 // Remove the alphabetic labels from example 1.
91 doc.removePageLabel(7);
92
93 // Replace the Prefix in the decimal labels (from example 1).
94 const label = await doc.getPageLabel(4);
95 if (await label.isValid()) {
96 await label.setPrefix('A');
97 label.setStart(1);
98 }
99
100 // Add a new label
101 const new_label = await PDFNet.PageLabel.create(doc, PDFNet.PageLabel.Style.e_decimal, 'B', 1);
102 doc.setPageLabel(10, new_label); // starting from page 10.
103
104 doc.save(outputPath + 'newsletter_with_pagelabels_modified.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
105 console.log('Done. Result saved in newsletter_with_pagelabels_modified.pdf...');
106
107 const page_num = await doc.getPageCount();
108 for (let i = 1; i <= page_num; ++i) {
109 console.log('Page number: ' + i);
110 const label = await doc.getPageLabel(i);
111 if (await label.isValid()) {
112 console.log(' Label: ' + await label.getLabelTitle(i));
113 }
114 else {
115 console.log(' No Label.');
116 }
117 }
118 }
119
120 //-----------------------------------------------------------
121 // Example 4: Delete all page labels in an existing PDF document.
122 //-----------------------------------------------------------
123 {
124 const doc = await PDFNet.PDFDoc.createFromFilePath(outputFile);
125 (await doc.getRoot()).eraseFromKey('PageLabels');
126 }
127
128 } catch (err) {
129 console.log(err);
130 }
131 }
132 PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
133 console.log('Error: ' + JSON.stringify(error));
134 }).then(function(){ return PDFNet.shutdown(); });
135 };
136 exports.runPageLabelsTest();
137})(exports);
138// eslint-disable-next-line spaced-comment
139//# sourceURL=PageLabelsTest.js
1#---------------------------------------------------------------------------------------
2# Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3# Consult LICENSE.txt regarding license information.
4#---------------------------------------------------------------------------------------
5
6import site
7site.addsitedir("../../../PDFNetC/Lib")
8import sys
9from PDFNetPython import *
10
11sys.path.append("../../LicenseKey/PYTHON")
12from LicenseKey import *
13
14#-----------------------------------------------------------------------------------
15# The sample illustrates how to work with PDF page labels.
16#
17# PDF page labels can be used to describe a page. This is used to
18# allow for non-sequential page numbering or the addition of arbitrary
19# labels for a page (such as the inclusion of Roman numerals at the
20# beginning of a book). PDFNet PageLabel object can be used to specify
21# the numbering style to use (for example, upper- or lower-case Roman,
22# decimal, and so forth), the starting number for the first page,
23# and an arbitrary prefix to be pre-appended to each number (for
24# example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
25#-----------------------------------------------------------------------------------
26
27# Relative path to the folder containing the test files.
28input_path = "../../TestFiles/"
29output_path = "../../TestFiles/Output/"
30
31def main():
32 # Initialize PDFNet
33 PDFNet.Initialize(LicenseKey)
34
35 #-----------------------------------------------------------
36 # Example 1: Add page labels to an existing or newly created PDF
37 # document.
38 #-----------------------------------------------------------
39
40 doc = PDFDoc(input_path + "newsletter.pdf")
41 doc.InitSecurityHandler()
42
43 # Create a page labeling scheme that starts with the first page in
44 # the document (page 1) and is using uppercase roman numbering
45 # style.
46 L1 = PageLabel.Create(doc.GetSDFDoc(), PageLabel.e_roman_uppercase, "My Prefix ", 1)
47 doc.SetPageLabel(1, L1)
48
49 # Create a page labeling scheme that starts with the fourth page in
50 # the document and is using decimal arabic numbering style.
51 # Also the numeric portion of the first label should start with number
52 # 4 (otherwise the first label would be "My Prefix 1").
53 L2 = PageLabel.Create(doc.GetSDFDoc(), PageLabel.e_decimal, "My Prefix ", 4)
54 doc.SetPageLabel(4, L2)
55
56 # Create a page labeling scheme that starts with the seventh page in
57 # the document and is using alphabetic numbering style. The numeric
58 # portion of the first label should start with number 1.
59 L3 = PageLabel.Create(doc.GetSDFDoc(), PageLabel.e_alphabetic_uppercase, "My Prefix ", 1)
60 doc.SetPageLabel(7, L3)
61
62 doc.Save(output_path + "newsletter_with_pagelabels.pdf", SDFDoc.e_linearized)
63 doc.Close()
64 print("Done. Result saved in newsletter_with_pagelabels.pdf...")
65
66 #-----------------------------------------------------------
67 # Example 2: Read page labels from an existing PDF document.
68 #-----------------------------------------------------------
69
70 doc = PDFDoc(output_path + "newsletter_with_pagelabels.pdf")
71 doc.InitSecurityHandler()
72
73 label = PageLabel()
74 page_num = doc.GetPageCount()
75
76 i = 1
77 while i <= page_num:
78 print("Page number: " + str(i))
79 label = doc.GetPageLabel(i)
80
81 if label.IsValid():
82 print("Label: " + label.GetLabelTitle(i))
83 else:
84 print("No Label.")
85 i = i + 1
86
87 doc.Close()
88
89 #-----------------------------------------------------------
90 # Example 3: Modify page labels from an existing PDF document.
91 #-----------------------------------------------------------
92
93 doc = PDFDoc(output_path + "newsletter_with_pagelabels.pdf")
94 doc.InitSecurityHandler()
95
96 # Remove the alphabetic labels from example i.
97 doc.RemovePageLabel(7)
98
99 # Replace the Prefix in the decimal labels (from example 1).
100 label = doc.GetPageLabel(4)
101 if label.IsValid():
102 label.SetPrefix("A")
103 label.SetStart(1)
104
105 # Add a new label
106 new_label = PageLabel.Create(doc.GetSDFDoc(), PageLabel.e_decimal, "B", 1)
107 doc.SetPageLabel(10, new_label) # starting from page 10
108
109 doc.Save(output_path + "newsletter_with_pagelabels_modified.pdf", SDFDoc.e_linearized)
110 print("Done. Result saved in newsletter_with_pagelabels_modified.pdf...")
111
112 page_num = doc.GetPageCount()
113 i = 1
114 while i <= page_num:
115 print("Page number: " + str(i))
116 label = doc.GetPageLabel(i)
117 if label.IsValid():
118 print("Label: " + label.GetLabelTitle(i))
119 else:
120 print("No Label.")
121 i = i + 1
122
123 doc.Close()
124
125 #-----------------------------------------------------------
126 # Example 4: Delete all page labels in an existing PDF document.
127 #-----------------------------------------------------------
128
129 doc = PDFDoc(output_path + "newsletter_with_pagelabels.pdf")
130 doc.GetRoot().Erase("PageLabels")
131 doc.Save(output_path + "newsletter_with_pagelabels_removed.pdf", SDFDoc.e_linearized)
132
133 doc.Close()
134 PDFNet.Terminate()
135
136if __name__ == '__main__':
137 main()
1<?php
2//---------------------------------------------------------------------------------------
3// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
4// Consult LICENSE.txt regarding license information.
5//---------------------------------------------------------------------------------------
6if(file_exists("../../../PDFNetC/Lib/PDFNetPHP.php"))
7include("../../../PDFNetC/Lib/PDFNetPHP.php");
8include("../../LicenseKey/PHP/LicenseKey.php");
9
10// Relative path to the folder containing the test files.
11$input_path = getcwd()."/../../TestFiles/";
12$output_path = $input_path."Output/";
13
14//-----------------------------------------------------------------------------------
15// The sample illustrates how to work with PDF page labels.
16//
17// PDF page labels can be used to describe a page. This is used to
18// allow for non-sequential page numbering or the addition of arbitrary
19// labels for a page (such as the inclusion of Roman numerals at the
20// beginning of a book). PDFNet PageLabel object can be used to specify
21// the numbering style to use (for example, upper- or lower-case Roman,
22// decimal, and so forth), the starting number for the first page,
23// and an arbitrary prefix to be pre-appended to each number (for
24// example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
25//-----------------------------------------------------------------------------------
26
27 PDFNet::Initialize($LicenseKey);
28 PDFNet::GetSystemFontList(); // Wait for fonts to be loaded if they haven't already. This is done because PHP can run into errors when shutting down if font loading is still in progress.
29
30 //-----------------------------------------------------------
31 // Example 1: Add page labels to an existing or newly created PDF
32 // document.
33 //-----------------------------------------------------------
34
35 $doc = new PDFDoc($input_path."newsletter.pdf");
36 $doc->InitSecurityHandler();
37
38 // Create a page labeling scheme that starts with the first page in
39 // the document (page 1) and is using uppercase roman numbering
40 // style.
41 $L1 = PageLabel::Create($doc->GetSDFDoc(), PageLabel::e_roman_uppercase, "My Prefix ", 1);
42 $doc->SetPageLabel(1, $L1);
43
44 // Create a page labeling scheme that starts with the fourth page in
45 // the document and is using decimal Arabic numbering style.
46 // Also the numeric portion of the first label should start with number
47 // 4 (otherwise the first label would be "My Prefix 1").
48 $L2 = PageLabel::Create($doc->GetSDFDoc(), PageLabel::e_decimal, "My Prefix ", 4);
49 $doc->SetPageLabel(4, $L2);
50
51 // Create a page labeling scheme that starts with the seventh page in
52 // the document and is using alphabetic numbering style. The numeric
53 // portion of the first label should start with number 1.
54 $L3 = PageLabel::Create($doc->GetSDFDoc(), PageLabel::e_alphabetic_uppercase, "My Prefix ", 1);
55 $doc->SetPageLabel(7, $L3);
56
57 $doc->Save($output_path."newsletter_with_pagelabels.pdf", SDFDoc::e_linearized);
58 echo nl2br("Done. Result saved in newsletter_with_pagelabels.pdf...\n");
59
60 //-----------------------------------------------------------
61 // Example 2: Read page labels from an existing PDF document.
62 //-----------------------------------------------------------
63
64 $doc = new PDFDoc($output_path."newsletter_with_pagelabels.pdf");
65 $doc->InitSecurityHandler();
66
67 $label = new PageLabel();
68 $page_num = $doc->GetPageCount();
69 for ($i=1; $i<=$page_num; ++$i)
70 {
71 echo "Page number: ".$i;
72 $label = $doc->GetPageLabel($i);
73 if ($label->IsValid()) {
74 echo nl2br(" Label: ".$label->GetLabelTitle($i)."\n");
75 }
76 else {
77 echo nl2br(" No Label.\n");
78 }
79 }
80
81 //-----------------------------------------------------------
82 // Example 3: Modify page labels from an existing PDF document.
83 //-----------------------------------------------------------
84
85 $doc = new PDFDoc($output_path."newsletter_with_pagelabels.pdf");
86 $doc->InitSecurityHandler();
87
88 // Remove the alphabetic labels from example 1.
89 $doc->RemovePageLabel(7);
90
91 // Replace the Prefix in the decimal labels (from example 1).
92 $label = $doc->GetPageLabel(4);
93 if ($label->IsValid()) {
94 $label->SetPrefix("A");
95 $label->SetStart(1);
96 }
97
98 // Add a new label
99 $new_label = PageLabel::Create($doc->GetSDFDoc(), PageLabel::e_decimal, "B", 1);
100 $doc->SetPageLabel(10, $new_label); // starting from page 10.
101
102 $doc->Save($output_path."newsletter_with_pagelabels_modified.pdf", SDFDoc::e_linearized);
103 echo nl2br("Done. Result saved in newsletter_with_pagelabels_modified.pdf...\n");
104
105 $page_num = $doc->GetPageCount();
106 for ($i=1; $i<=$page_num; ++$i)
107 {
108 echo "Page number: ".$i;
109 $label = $doc->GetPageLabel($i);
110 if ($label->IsValid()) {
111 echo nl2br(" Label: ".$label->GetLabelTitle($i)."\n");
112 }
113 else {
114 echo nl2br(" No Label.\n");
115 }
116 }
117
118 $doc->Close();
119
120 //-----------------------------------------------------------
121 // Example 4: Delete all page labels in an existing PDF document.
122 //-----------------------------------------------------------
123
124 $doc = new PDFDoc ($output_path."newsletter_with_pagelabels.pdf");
125 $doc->GetRoot()->Erase("PageLabels");
126 $doc->Save($output_path."newsletter_with_pagelabels_removed.pdf", SDFDoc::e_linearized);
127 PDFNet::Terminate();
128 echo nl2br("Done. Result saved in newsletter_with_pagelabels_removed.pdf...\n");
129 // ...
130?>
1#---------------------------------------------------------------------------------------
2# Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3# Consult LICENSE.txt regarding license information.
4#---------------------------------------------------------------------------------------
5
6require '../../../PDFNetC/Lib/PDFNetRuby'
7include PDFNetRuby
8require '../../LicenseKey/RUBY/LicenseKey'
9
10$stdout.sync = true
11
12#-----------------------------------------------------------------------------------
13# The sample illustrates how to work with PDF page labels.
14#
15# PDF page labels can be used to describe a page. This is used to
16# allow for non-sequential page numbering or the addition of arbitrary
17# labels for a page (such as the inclusion of Roman numerals at the
18# beginning of a book). PDFNet PageLabel object can be used to specify
19# the numbering style to use (for example, upper- or lower-case Roman,
20# decimal, and so forth), the starting number for the first page,
21# and an arbitrary prefix to be pre-appended to each number (for
22# example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
23#-----------------------------------------------------------------------------------
24
25# Relative path to the folder containing the test files.
26input_path = "../../TestFiles/"
27output_path = "../../TestFiles/Output/"
28
29 # Initialize PDFNet
30 PDFNet.Initialize(PDFTronLicense.Key)
31
32 #-----------------------------------------------------------
33 # Example 1: Add page labels to an existing or newly created PDF
34 # document.
35 #-----------------------------------------------------------
36
37 doc = PDFDoc.new(input_path + "newsletter.pdf")
38 doc.InitSecurityHandler
39
40 # Create a page labeling scheme that starts with the first page in
41 # the document (page 1) and is using uppercase roman numbering
42 # style.
43 L1 = PageLabel.Create(doc.GetSDFDoc, PageLabel::E_roman_uppercase, "My Prefix ", 1)
44 doc.SetPageLabel(1, L1)
45
46 # Create a page labeling scheme that starts with the fourth page in
47 # the document and is using decimal arabic numbering style.
48 # Also the numeric portion of the first label should start with number
49 # 4 (otherwise the first label would be "My Prefix 1").
50 L2 = PageLabel.Create(doc.GetSDFDoc, PageLabel::E_decimal, "My Prefix ", 4)
51 doc.SetPageLabel(4, L2)
52
53 # Create a page labeling scheme that starts with the seventh page in
54 # the document and is using alphabetic numbering style. The numeric
55 # portion of the first label should start with number 1.
56 L3 = PageLabel.Create(doc.GetSDFDoc, PageLabel::E_alphabetic_uppercase, "My Prefix ", 1)
57 doc.SetPageLabel(7, L3)
58
59 doc.Save(output_path + "newsletter_with_pagelabels.pdf", SDFDoc::E_linearized)
60 doc.Close
61 puts "Done. Result saved in newsletter_with_pagelabels.pdf..."
62
63 #-----------------------------------------------------------
64 # Example 2: Read page labels from an existing PDF document.
65 #-----------------------------------------------------------
66
67 doc = PDFDoc.new(output_path + "newsletter_with_pagelabels.pdf")
68 doc.InitSecurityHandler
69
70 label = PageLabel.new
71 page_num = doc.GetPageCount
72
73 i = 1
74 while i <= page_num do
75 puts "Page number: " + i.to_s
76 label = doc.GetPageLabel(i)
77
78 if label.IsValid
79 puts "Label: " + label.GetLabelTitle(i)
80 else
81 puts "No Label."
82 end
83 i = i + 1
84 end
85
86 doc.Close
87
88 #-----------------------------------------------------------
89 # Example 3: Modify page labels from an existing PDF document.
90 #-----------------------------------------------------------
91
92 doc = PDFDoc.new(output_path + "newsletter_with_pagelabels.pdf")
93 doc.InitSecurityHandler
94
95 # Remove the alphabetic labels from example i.
96 doc.RemovePageLabel(7)
97
98 # Replace the Prefix in the decimal labels (from example 1).
99 label = doc.GetPageLabel(4)
100 if label.IsValid
101 label.SetPrefix("A")
102 label.SetStart(1)
103 end
104
105 # Add a new label
106 new_label = PageLabel.Create(doc.GetSDFDoc, PageLabel::E_decimal, "B", 1)
107 doc.SetPageLabel(10, new_label) # starting from page 10
108
109 doc.Save(output_path + "newsletter_with_pagelabels_modified.pdf", SDFDoc::E_linearized)
110 puts "Done. Result saved in newsletter_with_pagelabels_modified.pdf..."
111
112 page_num = doc.GetPageCount
113 i = 1
114 while i <= page_num do
115 puts "Page number: " + i.to_s
116 label = doc.GetPageLabel(i)
117 if label.IsValid
118 puts "Label: " + label.GetLabelTitle(i)
119 else
120 puts "No Label."
121 end
122 i = i + 1
123 end
124
125 doc.Close
126
127 #-----------------------------------------------------------
128 # Example 4: Delete all page labels in an existing PDF document.
129 #-----------------------------------------------------------
130
131 doc = PDFDoc.new(output_path + "newsletter_with_pagelabels.pdf")
132 doc.GetRoot.Erase("PageLabels")
133 doc.Save(output_path + "newsletter_with_pagelabels_removed.pdf", SDFDoc::E_linearized)
134
135 doc.Close
136 PDFNet.Terminate
1'
2' Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3'
4Imports System
5
6Imports pdftron
7Imports pdftron.Common
8Imports pdftron.SDF
9Imports pdftron.PDF
10
11
12'-----------------------------------------------------------------------------------
13' The sample illustrates how to work with PDF page labels.
14'
15' PDF page labels can be used to describe a page. This is used to
16' allow for non-sequential page numbering or the addition of arbitrary
17' labels for a page (such as the inclusion of Roman numerals at the
18' beginning of a book). PDFNet PageLabel object can be used to specify
19' the numbering style to use (for example, upper- or lower-case Roman,
20' decimal, and so forth), the starting number for the first page,
21' and an arbitrary prefix to be pre-appended to each number (for
22' example, "A-" to generate "A-1", "A-2", "A-3", and so forth.)
23'-----------------------------------------------------------------------------------
24Module PageLabelsTestVB
25 Dim pdfNetLoader As PDFNetLoader
26 Sub New()
27 pdfNetLoader = pdftron.PDFNetLoader.Instance()
28 End Sub
29
30 ' Relative path to the folder containing test files.
31 Dim input_path As String = "../../../../TestFiles/"
32 Dim output_path As String = "../../../../TestFiles/Output/"
33
34 Sub Main()
35
36 PDFNet.Initialize(PDFTronLicense.Key)
37 Try
38 '-----------------------------------------------------------
39 ' Example 1: Add page labels to an existing or newly created PDF
40 ' document.
41 '-----------------------------------------------------------
42 Using doc As PDFDoc = New PDFDoc(input_path + "newsletter.pdf")
43 doc.InitSecurityHandler()
44
45 ' Create a page labeling scheme that starts with the first page in
46 ' the document (page 1) and is using uppercase roman numbering
47 ' style.
48 doc.SetPageLabel(1, PageLabel.Create(doc.GetSDFDoc(), PageLabel.Style.e_roman_uppercase, "My Prefix ", 1))
49
50 ' Create a page labeling scheme that starts with the fourth page in
51 ' the document and is using decimal arabic numbering style.
52 ' Also the numeric portion of the first label should start with number
53 ' 4 (otherwise the first label would be "My Prefix 1").
54 Dim L2 As PageLabel = PageLabel.Create(doc.GetSDFDoc(), PageLabel.Style.e_decimal, "My Prefix ", 4)
55 doc.SetPageLabel(4, L2)
56
57 ' Create a page labeling scheme that starts with the seventh page in
58 ' the document and is using alphabetic numbering style. The numeric
59 ' portion of the first label should start with number 1.
60 Dim L3 As PageLabel = PageLabel.Create(doc.GetSDFDoc(), PageLabel.Style.e_alphabetic_uppercase, "My Prefix ", 1)
61 doc.SetPageLabel(7, L3)
62
63 doc.Save(output_path + "newsletter_with_pagelabels.pdf", SDF.SDFDoc.SaveOptions.e_linearized)
64 Console.WriteLine("Done. Result saved in newsletter_with_pagelabels.pdf...")
65 End Using
66 Catch ex As PDFNetException
67 Console.WriteLine(ex.Message)
68 Catch ex As Exception
69 MsgBox(ex.Message)
70 End Try
71
72 '-----------------------------------------------------------
73 ' Example 2: Read page labels from an existing PDF document.
74 '-----------------------------------------------------------
75 Try
76 Using doc As PDFDoc = New PDFDoc(output_path + "newsletter_with_pagelabels.pdf")
77 doc.InitSecurityHandler()
78
79 Dim label As PageLabel
80 Dim page_num As Integer = doc.GetPageCount()
81
82 Dim i As Integer
83 For i = 1 To page_num
84 Console.Write("Page number: {0}", i)
85 label = doc.GetPageLabel(i)
86 If label.IsValid() Then
87 Console.WriteLine(" Label: {0}", label.GetLabelTitle(i))
88 Else
89 Console.WriteLine(" No Label.")
90 End If
91 Next i
92 End Using
93 Catch ex As PDFNetException
94 Console.WriteLine(ex.Message)
95 Catch ex As Exception
96 MsgBox(ex.Message)
97 End Try
98
99 '-----------------------------------------------------------
100 ' Example 3: Modify page labels from an existing PDF document.
101 '-----------------------------------------------------------
102 Try
103 Using doc As PDFDoc = New PDFDoc(output_path + "newsletter_with_pagelabels.pdf")
104 doc.InitSecurityHandler()
105
106 'Remove the alphabetic labels from example 1.
107 doc.RemovePageLabel(7)
108
109 ' Replace the Prefix in the decimal lables (from example 1).
110 Dim label As PageLabel = doc.GetPageLabel(4)
111 If (label.IsValid()) Then
112 label.SetPrefix("A")
113 label.SetStart(1)
114 End If
115
116 ' Add a new label
117 Dim new_label As PageLabel = PageLabel.Create(doc.GetSDFDoc(), PageLabel.Style.e_decimal, "B", 1)
118 doc.SetPageLabel(10, new_label) ' starting from page 10.
119
120 doc.Save(output_path + "newsletter_with_pagelabels_modified.pdf", SDF.SDFDoc.SaveOptions.e_linearized)
121 Console.WriteLine("Done. Result saved in newsletter_with_pagelabels_modified.pdf...")
122
123 Dim page_num As Integer = doc.GetPageCount()
124 Dim i As Integer
125 For i = 1 To page_num
126 Console.Write("Page number: {0}", i)
127 label = doc.GetPageLabel(i)
128 If (label.IsValid()) Then
129 Console.WriteLine(" Label: {0}", label.GetLabelTitle(i))
130 Else
131 Console.WriteLine(" No Label.")
132 End If
133 Next i
134 End Using
135 Catch ex As PDFNetException
136 Console.WriteLine(ex.Message)
137 Catch ex As Exception
138 MsgBox(ex.Message)
139 End Try
140
141 '-----------------------------------------------------------
142 ' Example 4: Delete all page labels in an existing PDF document.
143 '-----------------------------------------------------------
144 Try
145 Using doc As PDFDoc = New PDFDoc(output_path + "newsletter_with_pagelabels.pdf")
146 doc.GetRoot().Erase("PageLabels")
147 ' ...
148 End Using
149 Catch ex As PDFNetException
150 Console.WriteLine(ex.Message)
151 Catch ex As Exception
152 MsgBox(ex.Message)
153 End Try
154 PDFNet.Terminate()
155 End Sub
156End Module
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales