本文介绍了如何将书签从XML导入到现有的pdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我目前正在研究pdf项目(dotnet / c#[Itextsharp pdf]),我想从一个pdf导出和导入书签到另一个pdf(两个pdf都有相同的内容,唯一的区别是书签/没有书签和一个是正​​常的pdf和另一个链接的pdf)。将书签导出到xml工作正常,但我没有想法将导出的书签(xml)导入到另一个pdf。任何机构都可以提出解决方案。 我尝试过: 在这里我附上我的代码。 string inputpdf =D:\\\\ section1.pdf; string outputbookmark =D:\\chapter1Bookmark.xml; PdfReader reader = new PdfReader(inputpdf); IList< dictionary>< string,> > bookmarks = SimpleBookmark.GetBookmark(reader); 使用(StreamWriter Sw = new StreamWriter(outputbookmark)) { SimpleBookmark.ExportToXML(书签) ,Sw,ISO8859-1,真实); } reader.Close(); 我的xml输出文件是 < bookmark> < Title Color =0 0 0Page =1 XYZ 36 806Action =GoTo> Introduction< / title> < Title Color =0 0 0Page =1 XYZ 36 410行动=GoTo>入门 < Title Color =0 0 0Page =1 XYZ 36 364行动=GoTo>打印测试页< / Title> < Title Color =0 0 0Page =4 XYZ 36 740Action =GoTo>访问novaPDF打印首选项 - 测试多行书签检测选项< / Title> < Title Color =0 0 0Page =5 XYZ 36 806Action =GoTo>创建PDF文件< / TITL e> < / title> 我的Pdf文件在 $ b中可用$ b http://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-bookmarks.original.pdf解决方案 你真的需要一份iText in Action(第7章)的副本 iText开发人员 [ ^ ]了解处理书签的iTextsharp示例 https://sourceforge.net/p/itextsharp/ code / HEAD / tree / book / iTextExamplesWeb / iTextExamplesWeb / iTextInAction2Ed / Chapter07 / BookmarkedTimeTable.cs [ ^ ] I am currently working on pdf projects (dotnet/c#[Itextsharp pdf]), I want to export and import bookmarks from one pdf to another pdf (both pdf are having same content, only difference are with bookmark/without bookmark and one is normal pdf and another linked pdf). Exporting bookmarks to xml is working fine but I don`t have the idea of importing exported bookmark(xml) to another pdf. Can any body suggest solution.What I have tried:Here I am attaching my code. string inputpdf = "D:\\chapter1.pdf"; string outputbookmark="D:\\chapter1Bookmark.xml"; PdfReader reader = new PdfReader(inputpdf); IList<dictionary><string,>> bookmarks = SimpleBookmark.GetBookmark(reader); using (StreamWriter Sw = new StreamWriter(outputbookmark)) { SimpleBookmark.ExportToXML(bookmarks, Sw,"ISO8859-1", true); } reader.Close();My xml output file is<bookmark> <Title Color="0 0 0" Page="1 XYZ 36 806" Action="GoTo" >Introduction</Title> <Title Color="0 0 0" Page="1 XYZ 36 410" Action="GoTo" >Getting Started <Title Color="0 0 0" Page="1 XYZ 36 364" Action="GoTo" >Printing a test page</Title> <Title Color="0 0 0" Page="4 XYZ 36 740" Action="GoTo" >Accessing the novaPDF Printing Preferences – test the multiline bookmark detection option</Title> <Title Color="0 0 0" Page="5 XYZ 36 806" Action="GoTo" >Creating PDF Files</Title> </Title>My Pdf file available inhttp://www.novapdf.com/uploads/novapdf_en/media_items/pdf-example-bookmarks.original.pdf 解决方案 You really need a copy of "iText in Action" (Chapter 7) Books | iText Developers[^] to understand the iTextsharp example dealing with bookmarks https://sourceforge.net/p/itextsharp/code/HEAD/tree/book/iTextExamplesWeb/iTextExamplesWeb/iTextInAction2Ed/Chapter07/BookmarkedTimeTable.cs[^] 这篇关于如何将书签从XML导入到现有的pdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-04 20:08