我正在使用iTextSharp库和C#.Net来分割我的PDF文件。
I am using iTextSharp library and C#.Net for splitting my PDF file.
考虑一个名为sample.pdf的PDF文件,其中包含72页。此sample.pdf包含具有导航到其他页面的超链接的页面。例如:在第4页中有三个超链接,点击时可导航到相应的第24,27,28页。与第4页一样,有近12页与它们有这个超链接。
Consider a PDF file named sample.pdf containing 72 pages. This sample.pdf contains pages that have hyperlink that navigate to other page. Eg: In the page 4 there are three hyperlinks which when clicked navigates to corresponding 24th,27th,28th page. As same as the 4th page there are nearly 12 pages that is having this hyperlinks with them.
现在使用iTextSharp库我将这个PDF页面分成72个单独的文件,并保存为名称为.pdf,2.pdf .... 72.pdf。所以在4.pdf中点击超链接我需要让PDF导航到24.pdf,27.pdf,28.pdf。
Now using iTextSharp library I had split this PDF pages into 72 separate file and saved with the name as 1.pdf,2.pdf....72.pdf. So in the 4.pdf when clicking that hyperlinks I need to make the PDF navigate to 24.pdf,27.pdf,28.pdf.
请帮帮我。如何编辑和设置4.pdf中的超链接,以便导航到相应的pdf文件。
Please help me out here. How can I edit and set the hyperlinks in the 4.pdf so that it navigates to corresponding pdf files.
谢谢你, Ashok
Thank you, Ashok
推荐答案你是什么想要很有可能。您想要的是需要使用低级PDF对象(PdfDictionary,PdfArray等)。
What you want is quite possible. What you want will require you to work with the low-level PDF objects (PdfDictionary, PdfArray, etc).
每当有人需要处理这些对象时,我总是请参阅 PDF参考。在您的情况下,您将要检查第7章(特别是第3节)和第12章,第3节(文档级导航)和第5章(注释)。
And whenever someone needs to work with those objects, I always refer them to the PDF Reference. In your case, you'll want to examine chapter 7 (particularly section 3) and chapter 12, sections 3 (doc-level navigation) and 5 (annotations).
假设你已经读过,这就是你需要做的事情:
Assuming you've read that, here's what you need to do:
步骤1.1并不简单。有几种不同的本地goto注释格式。您需要确定给定链接指向的页面。某些链接可能表示PDF等效于下一页或上一页,而其他链接则包含对特定页面的引用。这将是间接对象引用,而不是页码。
Step 1.1 isn't simple. There are several different kinds of "local goto" annotation formats. You need to determine which page a given link points to. Some links might say the PDF equivalent of "next page" or "previous page", while others will include a reference to a particular page. This will be an "indirect object reference", not a page number.
要确定页面引用的页码,您需要... ouch。好的。最有效的方法是为原始文档中的每个页面调用PdfReader.GetPageRef(int pageNum)并将其缓存在地图中(reference-> pageNum)。
To determine the page number from a page reference, you need to... ouch. Okay. The most efficient way would be to call PdfReader.GetPageRef(int pageNum) for each page in the original document and cache it in a map (reference->pageNum).
然后,您可以通过创建远程goto PdfAction并将其写入链接注释的A(操作)条目来构建远程goto链接,删除之前存在的任何内容(可能是Dest)。
You can then build "remote goto" links by creating a remote goto PdfAction, and writing that into the link annotation's "A" (action) entry, removing anything that was there before (probably a "Dest").
我不太会说C#,所以我会把实际的实现留给你。
I don't speak C# very well, so I'll leave the actual implementation to you.
更多推荐
使用ITextSharp编辑PDF中的超链接和锚点
发布评论