public static void Run( String email, // authorization email String licenseKey, // authorization license key String openPath, // source PDF document String savePath // dest PDF document ) { pdfix = new Pdfix(); if (pdfix == null) { throw new Exception("Pdfix initialization fail"); } if (!pdfix.Authorize(email, licenseKey)) { throw new Exception(pdfix.GetErrorType().ToString()); } PdfDoc doc = pdfix.OpenDoc(openPath, ""); if (doc == null) { throw new Exception(pdfix.GetError()); } // cleanup any previous structure tree if (!doc.RemoveTags(null, IntPtr.Zero)) { throw new Exception(pdfix.GetErrorType().ToString()); } // autotag document first if (!doc.AddTags(null, IntPtr.Zero)) { throw new Exception(pdfix.GetErrorType().ToString()); } // get the struct tree PdsStructTree struct_tree = doc.GetStructTree(); if (struct_tree == null) { throw new Exception(pdfix.GetErrorType().ToString()); } PdsStructElement paragraph = GetFirstParagraph(struct_tree); if (paragraph == null) { throw new Exception("No paragraph found."); } PdfRect annot_bbox = new PdfRect(); GetStructElementBBox(paragraph, ref annot_bbox); // add new link annotation to the page PdfPage page = doc.AcquirePage(0); PdfLinkAnnot annot = page.AddLinkAnnot(0, annot_bbox); if (annot == null) { throw new Exception(pdfix.GetErrorType().ToString()); } // re-tag the document the link annotation if (!doc.RemoveTags(null, IntPtr.Zero)) { throw new Exception(pdfix.GetErrorType().ToString()); } if (!doc.AddTags(null, IntPtr.Zero)) { throw new Exception(pdfix.GetErrorType().ToString()); } if (!doc.Save(savePath, PdfSaveFlags.kSaveFull)) { throw new Exception(pdfix.GetError()); } doc.Close(); pdfix.Destroy(); }