Options to use when creating custom bookmarks based when creating Adobe Portable Document Format (PDF) documents.
[DataContractAttribute()][SerializableAttribute()]public struct PdfCustomBookmark : System.ValueType
<DataContractAttribute()><SerializableAttribute()>Public Structure PdfCustomBookmarkInherits System.ValueType
[DataContractAttribute()][SerializableAttribute()]public class PdfCustomBookmark
@interface LTPdfCustomBookmark : NSObject <NSCopying, NSCoding>public class PdfCustomBookmarkJAVASCRIPT_NOSTRUCTS[DataContractAttribute()][SerializableAttribute()]public value class PdfCustomBookmark : public System.ValueType
Use the PdfCustomBookmark structure with PdfDocumentOptions when saving a document using the DocumentFormat.Pdf format.
Custom bookmarks will only be used if creating auto-bookmarks is disabled in the PDF options. So to use custom bookmarks, set the PdfDocumentOptions.AutoBookmarksEnabled property to false.
This example will use OCR to convert an input multi-page TIF file to searachble PDF creating a custom bookmark for each page in the output PDF file.
Imports Leadtools.Forms.DocumentWritersImports Leadtools.Forms.OcrImports LeadtoolsImports Leadtools.CodecsPublic Sub OcrToPDFWithCustomBookmarksExample()Dim tifFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Example.tif")Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf")Dim pageCount As Integer' Get the input multi-page TIF fileUsing codecs As New RasterCodecs()codecs.Options.RasterizeDocument.Load.Resolution = 30CreateMultiPageTifFile(codecs, tifFileName)' We are going to create a bookmark for each page, so get number of pages of input filepageCount = codecs.GetTotalPages(tifFileName)End Using' Create the OCR engineUsing ocrEngine As IOcrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, False)' Start re-useing the RasterCodecs we have for performanceocrEngine.Startup(Nothing, Nothing, Nothing, LEAD_VARS.OcrAdvantageRuntimeDir)' Get the DocumentWriter instance used in this OCR engineDim docWriter As DocumentWriter = ocrEngine.DocumentWriterInstance' Get the current PDF options, modify and then set it backDim pdfOptions As PdfDocumentOptions = DirectCast(docWriter.GetOptions(DocumentFormat.Pdf), PdfDocumentOptions)pdfOptions.DocumentType = PdfDocumentType.PdfApdfOptions.ImageOverText = True' Set bookmark optionspdfOptions.AutoBookmarksEnabled = FalseFor pageNumber As Integer = 1 To pageCountDim bookmark As New PdfCustomBookmark()bookmark.Name = String.Format("Page {0}", pageNumber)bookmark.PageNumber = pageNumberbookmark.LevelNumber = 0bookmark.XCoordinate = 0bookmark.YCoordinate = 0pdfOptions.CustomBookmarks.Add(bookmark)NextdocWriter.SetOptions(DocumentFormat.Pdf, pdfOptions)' ocr and save document with bookmark options appliedocrEngine.AutoRecognizeManager.Run(tifFileName, pdfFileName, Nothing, DocumentFormat.Pdf, Nothing)End UsingEnd SubPrivate Sub CreateMultiPageTifFile(codecs As RasterCodecs, tifFileName As String)' Create a multi-page tif file from shipping Ocr1, Ocr2, Ocr3 and Ocr4.tifDim tifFileNameTemplate As String = Path.Combine(LEAD_VARS.ImagesDir, "Ocr{0}.tif")If File.Exists(tifFileName) Then File.Delete(tifFileName)Dim image As RasterImage = NothingFor pageNumber As Integer = 1 To 4Dim tempImage As RasterImage = codecs.Load(String.Format(tifFileNameTemplate, pageNumber))If IsNothing(image) Thenimage = tempImageElseimage.AddPage(tempImage)tempImage.Dispose()End IfNextcodecs.Save(image, tifFileName, RasterImageFormat.CcittGroup4, 1)image.Dispose()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"Public Const OcrAdvantageRuntimeDir As String = "C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime"End Class
using Leadtools.Forms.DocumentWriters;using Leadtools.Forms.Ocr;using Leadtools;using Leadtools.Codecs;public void OcrToPDFWithCustomBookmarksExample(){var tifFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.tif");var pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf");int pageCount;// Get the input multi-page TIF fileusing (var codecs = new RasterCodecs()){codecs.Options.RasterizeDocument.Load.Resolution = 300;CreateMultiPageTifFile(codecs, tifFileName);// We are going to create a bookmark for each page, so get number of pages of input filepageCount = codecs.GetTotalPages(tifFileName);}// Create the OCR engineusing (var ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.Advantage, false)){// Start re-useing the RasterCodecs we have for performanceocrEngine.Startup(null, null, null, LEAD_VARS.OcrAdvantageRuntimeDir);// Get the DocumentWriter instance used in this OCR enginevar docWriter = ocrEngine.DocumentWriterInstance;// Get the current PDF options, modify and then set it backvar pdfOptions = docWriter.GetOptions(DocumentFormat.Pdf) as PdfDocumentOptions;pdfOptions.DocumentType = PdfDocumentType.PdfA;pdfOptions.ImageOverText = true;// Set bookmark optionspdfOptions.AutoBookmarksEnabled = false;for (var pageNumber = 1; pageNumber <= pageCount; pageNumber++){var bookmark = new PdfCustomBookmark();bookmark.Name = string.Format("Page {0}", pageNumber);bookmark.PageNumber = pageNumber;bookmark.LevelNumber = 0;bookmark.XCoordinate = 0;bookmark.YCoordinate = 0;pdfOptions.CustomBookmarks.Add(bookmark);}docWriter.SetOptions(DocumentFormat.Pdf, pdfOptions);// ocr and save document with bookmark options appliedocrEngine.AutoRecognizeManager.Run(tifFileName, pdfFileName, null, DocumentFormat.Pdf, null);}}private void CreateMultiPageTifFile(RasterCodecs codecs, string tifFileName){// Create a multi-page tif file from shipping Ocr1, Ocr2, Ocr3 and Ocr4.tifvar tifFileNameTemplate = Path.Combine(LEAD_VARS.ImagesDir, "Ocr{0}.tif");if (File.Exists(tifFileName))File.Delete(tifFileName);RasterImage image = null;for (var pageNumber = 1; pageNumber <= 4; pageNumber++){var tempImage = codecs.Load(string.Format(tifFileNameTemplate, pageNumber));if (image == null){image = tempImage;}else{image.AddPage(tempImage);tempImage.Dispose();}}codecs.Save(image, tifFileName, RasterImageFormat.CcittGroup4, 1);image.Dispose();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";public const string OcrAdvantageRuntimeDir = @"C:\LEADTOOLS 19\Bin\Common\OcrAdvantageRuntime";}
Leadtools.Forms.DocumentWriters Namespace
Programming with LEADTOOLS Document Writers
|
Products |
Support |
Feedback: PdfCustomBookmark Structure - Leadtools.Forms.DocumentWriters |
Introduction |
Help Version 19.0.2017.3.21
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.