Aar*_*ron 8 c# pdf asp.net abcpdf
我正在使用ABCpdf动态生成PDF,其中包含可链接到同一PDF中其他页面的目录.问题是HTML中锚标记的路径更改为临时文件的绝对路径.
例如,ABCpdf将呈现链接的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();
}
任何想法我如何获得正确渲染的锚链接,以便点击它将跳转到另一个页面?
Websupergoo回到我身边,我能够从他们提供的示例项目中调试我的问题.我的问题的解决方案很简单,我会在这里发布答案以防其他人遇到同样的问题:
我的HTML设置如下:
<a href="#elementId">Link to another page</a>
<div id="elementId">A div that's on another page</div>
我只需将其更改为:
<a href="#elementId">Link to another page</a>
<div><a name="elementId">A div that's on another page</a></div>
您需要使用具有指定名称的锚标记,以便ABCpdf使链接跳转到同一PDF中的另一个页面.