Ich möchte eine PDX-Suchkatalogdatei mit einem PDF-Dokument verknüpfen. Anscheinend gibt es derzeit keine Bibliothek, die dies out of the box unterstützt, also muss ich den /Search
Eintrag im Dokument direkt manipulieren. Ich weiß so gut wie nichts über den PDF-Standard, daher wäre eine Bibliothek, auf die ich über .NET-Code zugreifen kann und die die meisten Details für mich kapseln würde, großartig.
Mit PDFNet können Sie ganz einfach ein PDF einfügen/bearbeiten, wie Sie es suchen.
https://www.pdftron.com/documentation/samples/cs/SDFTest?platforms=windows https://www.pdftron.com/pdf-sdk/windows-library
Es sind auch Versionen für die universelle Windows-Plattform und Xamarin verfügbar, wenn Sie dies auf Mobilgeräten tun möchten.
https://www.pdftron.com/documentation/uwp/guides https://www.pdftron.com/documentation/xamarin/guides
Die XFINIUM.PDF- Bibliothek enthält eine COS-API, mit der Sie benutzerdefinierte Strukturen in PDF-Dateien erstellen können.
Der folgende Code zeigt, wie Sie die Suchstruktur in Ihrem Beispiel erstellen:
// 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");
Die /Search-Struktur ist im Bild unten zu sehen:
Haftungsausschluss: Ich arbeite für das Unternehmen, das die Bibliothek entwickelt.
Sorry, hatte die Antworten nicht früher gesehen. Ich konnte dies mit PdfSharp lösen .
Code hier gepostet: https://stackoverflow.com/questions/51127552/how-to-associate-search-catalog-file-pdx-with-pdf-document/51177573#51177573