【问题标题】:Gecko Engine in ABCPDF not finding tagsABCPDF 中的 Gecko 引擎找不到标签
【发布时间】:2015-02-16 16:03:19
【问题描述】:

有没有人尝试过使用 ABCPDF Gecko 引擎来实现标签?只要我使用 Gecko,它就可以在 MSHTML 引擎 (Internet Explorer) 上正常工作,它可以更好地呈现我的 HTML,它找不到 HTML 中指定的标签。

我正在使用 style="abcpdf-tag-visible: true;"指定使用默认引擎工作的标签。

以下代码生成一个空白文档。

 [Test]
        public void Tags_With_Gecko()
        {
            Doc theDoc = new Doc();
            theDoc.Rect.Inset(100, 100);
            theDoc.Rect.Top = 700;

            theDoc.HtmlOptions.Engine = EngineType.Gecko;
            // Tag elements with style 'abcpdf-tag-visible: true'
            theDoc.HtmlOptions.ForGecko.AddTags = true;
            int id = theDoc.AddImageHtml("<FONT id=\"p1\" style=\"abcpdf-tag-visible: true; font-size: 72pt\">Gallia est omnis divisa in partes tres.</FONT>");
            // Frame location of the tagged element
            XRect[] tagRects = theDoc.HtmlOptions.ForGecko.GetTagRects(id);
            foreach (XRect theRect in tagRects)
            {
                theDoc.Rect.String = theRect.ToString();
                theDoc.FrameRect();
            }
            // Output tag ID
            string[] tagIds = theDoc.HtmlOptions.ForGecko.GetTagIDs(id);
            theDoc.Rect.String = theDoc.MediaBox.String;
            theDoc.Rect.Inset(20, 20);
            theDoc.FontSize = 64;
            theDoc.Color.String = "255 0 0";
            theDoc.AddText("Tag ID \"" + tagIds[0] + "\":");
            // Save the document
            const string testFilename = @"C:\pdf\HtmlOptionsGetTagRects.pdf";
            if (File.Exists(testFilename))
                File.Delete(testFilename);

            theDoc.Save(testFilename);
            theDoc.Clear();
            Process.Start(testFilename);
        }

默认引擎几乎相同的代码可以正确生成它。

【问题讨论】:

  • 我遇到了完全相同的问题。向 WebSuperGoo 发送电子邮件寻求支持。如果我得到解决,将在此处更新......它在一台服务器上工作,在另一台服务器上失败,使用 Gecko。

标签: gecko abcpdf


【解决方案1】:

我一直在与 WebSuperGoo 支持人员交谈。发现文档不一致/不完整。

http://www.websupergoo.com/helppdfnet/source/5-abcpdf/xhtmloptions/2-properties/addtags.htm

在 Gecko 中,您的标签必须对页面产生明显的影响才能被拾取。在我的例子中,我有一个显示不间断空格的标签,因此没有找到。

从他们的示例中,将样式更改为以下样式使其易于查找: style="abcpdf-tag-visible: true; border: 1px solid transparent"

请注意,边框设置显然是这项工作的原因。

同样,这修复了他们的演示,因此应该修复 Dillorscroft 的示例。

我必须做更多的事情来解决我的问题,因为我正在尝试在页面上分配空白空间(用于目录),以便可以在呈现 html 后更新它们并且我知道第一个内容在哪里页面将开始。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-09
    • 1970-01-01
    • 1970-01-01
    • 2021-11-20
    相关资源
    最近更新 更多