ABCpdf转换HTML锚跳转到另一个网页在同一PDF [英] ABCpdf converting html anchors to jump to another page in the same PDF
问题描述
我动态生成的使用ABCpdf其中包含将相同的PDF中链接到其他网页内容的表格的PDF文件。的问题是,在HTML中的锚标签的路径得到改变为绝对路径到一个临时文件中。
I'm dynamically generating a PDF using ABCpdf which contains a table of contents that would link to other pages within the same PDF. The problem is that the path of the anchor tags in the HTML get changed to an absolute path to a temporary file.
例如,ABCpdf将使该链接的href:
For example, ABCpdf would render the link's href:
<a href="#elementId">Link</a>
在PDF为:的file:/// C:/Users/Aaron/AppData/Local/Temp/ABCpdf/pdfCMMYPSF.htm#elementId
这是怎么生成PDF:
Doc pdf = new Doc();
pdf.HtmlOptions.AddLinks = true;
pdf.Rect.Rectangle = new System.Drawing.Rectangle(20, 80, 572, 702);
int id = pdf.AddImageHtml(pdfHTML, true, pdf.HtmlOptions.BrowserWidth, true);
while (pdf.Chainable(id))
{
pdf.Page = pdf.AddPage();
id = pdf.AddImageToChain(id);
}
pdf.HtmlOptions.LinkPages();
for (int i = 0; i < pdf.PageCount; i++)
{
pdf.PageNumber = i;
pdf.Flatten();
}
任何想法如何,我可以得到锚链接来呈现正常使用,这时单击它会跳转到另一个页面?
Any ideas how I can get the anchor links to render properly so clicking it will jump to another page?
推荐答案
Websupergoo回来给我,我能够从他们提供了一个示例项目调试我的问题。我的问题的解决方案是pretty简单,我会在这里发布答案的情况下,其他人是否有同样的问题:
Websupergoo got back to me and I was able to debug my problem from a sample project they provided. The solution to my problem was pretty simple, I'll post the answer here in case anyone else is having the same issue:
我的HTML成立这样的:
My HTML was set up like this:
<a href="#elementId">Link to another page</a>
<div id="elementId">A div that's on another page</div>
我只是需要将其更改为:
I simply needed to change it to:
<a href="#elementId">Link to another page</a>
<div><a name="elementId">A div that's on another page</a></div>
您需要使用,以便为ABCpdf指定的名称一个锚标记,以相同的PDF中的链接跳转到另一个页面。
You need to use an anchor tag with the name specified in order for ABCpdf to make the link jump to another page within the same PDF.
这篇关于ABCpdf转换HTML锚跳转到另一个网页在同一PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!