0

I would like to associate a PDX search catalog file with a PDF document. Apparently there is currently no library that supports this out of the box, so what I have to do is manipulate the /Search entry in the document directly. I know next to nothing about the PDF standard, so a library I can access from .NET code that would encapsulate most of the details for me would be great.

This is what the structure looks like: PDF structure

0

With PDFNet you can easily insert/edit a PDF like you are looking for.

https://www.pdftron.com/documentation/samples/cs/SDFTest?platforms=windows https://www.pdftron.com/pdf-sdk/windows-library

There is also Universal Windows Platform, and Xamarin, versions available if you are looking to do this on mobile.

https://www.pdftron.com/documentation/uwp/guides https://www.pdftron.com/documentation/xamarin/guides

0

XFINIUM.PDF library includes a COS API that lets you create custom structures in PDF files.

The code below shows how to build the Search structure in your sample:

// Create a new document.
PdfFixedDocument document = new PdfFixedDocument();
// Or load an existing document.
// PdfFixedDocument document = new PdfFixedDocument("sample.pdf");

// Fill the document information.
document.DocumentInformation = new PdfDocumentInformation();
document.DocumentInformation.Author = "XFINIUM Software";
document.DocumentInformation.CreationDate = DateTime.Now;
document.DocumentInformation.ModifyDate = DateTime.Now;
document.DocumentInformation.Creator = "XFINIUM.PDF COS objects sample";
document.DocumentInformation.Producer = "XFINIUM.PDF Toolkit";
document.DocumentInformation.Title = "XFINIUM.PDF COS objects sample";
document.DocumentInformation.Subject = "XFINIUM.PDF sample code";
document.DocumentInformation.Keywords = "xfinium.pdf, pdf, sample";

// Create the /Search structure
PdfCosDictionaryContainer cosSearchDictionary = new PdfCosDictionaryContainer();
document.CosDictionary["/Search"] = cosSearchDictionary;

PdfCosArray indexesArray = new PdfCosArray();
cosSearchDictionary["/Indexes"] = indexesArray;

PdfCosDictionaryContainer indexDefinitionDictionary = new PdfCosDictionaryContainer();
indexesArray.Add(indexDefinitionDictionary);

indexDefinitionDictionary["/Name"] = new PdfCosName("/PDX");

PdfCosDictionaryContainer indexFileDictionary = new PdfCosDictionaryContainer();
indexDefinitionDictionary["/Index"] = indexFileDictionary;

indexFileDictionary["/Type"] = new PdfCosName("/Filespec");
indexFileDictionary["/F"] = new PdfCosString("c:\\Folder1\\Folder2\\index.pdx");

PdfPage page = document.Pages.Add();

document.Save("D:\\Temp\\Sample_SearchIndex.pdf");

The /Search structure can be seen in the image below:

XFINIUM.PDF Inspector

Disclaimer: I work for the company that develops the library.

0

Sorry, didn't see the replies earlier. I was able to solve this using PdfSharp.

Code posted here: https://stackoverflow.com/questions/51127552/how-to-associate-search-catalog-file-pdx-with-pdf-document/51177573#51177573

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.