@ironsoftware/ironpdf
Version:
IronPDF for Node
53 lines • 2.72 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBookmarks = void 0;
const access_1 = require("../../access");
const util_1 = require("../util");
/**
* Retrieve the document's outline bookmarks via the {@code Pdfium_Bookmark_GetBookmarksDescriptor}
* unary RPC. Mirrors {@code IronPdf.PdfDocument.Bookmarks} on the C# side.
*/
function getBookmarks(id) {
return __awaiter(this, void 0, void 0, function* () {
const client = yield access_1.Access.ensureConnection();
return new Promise((resolve, reject) => {
client.Pdfium_Bookmark_GetBookmarksDescriptor({ document: { documentId: id } }, (err, value) => {
var _a, _b;
if (err) {
reject(`${err.name}/n${err.message}`);
return;
}
if (!value) {
reject("No response from IronPdfEngine for getBookmarks");
return;
}
if (value.exception) {
(0, util_1.handleRemoteException)(value.exception, reject);
return;
}
const descriptors = (_b = (_a = value.result) === null || _a === void 0 ? void 0 : _a.bookmarkDescriptors) !== null && _b !== void 0 ? _b : [];
resolve(descriptors.map(d => {
var _a, _b, _c, _d, _e;
return ({
text: (_a = d.text) !== null && _a !== void 0 ? _a : "",
pageIndex: (_b = d.pageIndex) !== null && _b !== void 0 ? _b : 0,
hierarchy: (_c = d.hierarchy) !== null && _c !== void 0 ? _c : "",
itemId: (_d = d.itemId) !== null && _d !== void 0 ? _d : "",
parentItemId: (_e = d.parentItemId) !== null && _e !== void 0 ? _e : "",
});
}));
});
});
});
}
exports.getBookmarks = getBookmarks;
//# sourceMappingURL=bookmarks.js.map