首页 > 解决方案 > linktoDestination 不适用于 pdfmake

问题描述

目前我正在使用 pdfmake 将 html 转换为 pdf,这是我第一次使用它。

我正在尝试将 Ashish、twitter、aaa 链接到他们的特定部分。我尝试在操场上运行以下代码,但仅用于 aaa 导航到该部分。

// playground requires you to assign document definition to a variable called dd

var dd = {
    content: [
    {
        "columns": [
            {
                "text": "",
                "priority": 0
            },
            {
                "stack": [
                    "2/17/2021, 2:41:01 PM",
                    {
                        "text": "AshishTemplate v4"
                    }
                ],
                "style": {
                    "alignment": "right"
                },
                "priority": 1
            }
        ]
    },
    {
        "text": "\n Table of Contents \n\n",
        "style": "header"
    },
    {
        "columns": [
            {
                "text": "Ashish",
                "width": "auto",
                "style": "tableOfContents",
                "linkToDestination": "Ashish1"
            },
            {
                "text": "Twitter",
                "width": "auto",
                "style": "tableOfContents",
                "linkToDestination": "Twitter1"
            },
            {
                "text": "aaa",
                "width": "auto",
                "style": "tableOfContents",
                "linkToDestination": "aaa"
            }
        ],
        "columnGap": 10
    },
    {
        "text": "Ashish",
        "style": "sectionHeader",
        "id": "Ashish1"
    },
    "",
    {
        "columns": [
            {
                "width": "100%",
                "text": ""
            }
        ]
    },
    {
        "text": "Twitter",
        "style": "sectionHeader",
        "id": "Twitter1"
    },
    "AShish",
    {
        "columns": [
            {
                "style": "listViewTable",
                "table": {
                    "widths": [
                        "50%",
                        "50%"
                    ],
                    "body": [
                        [
                            "Address",
                            "-"
                        ],
                        
                    ]
                },
                "layout": {
                    "defaultBorder": false
                }
            }
        ]
    },
    {
        "text": "aaa",
        "style": "sectionHeader",
        "id": "aaa"
    },
    "aa",
    {
        "columns": [
            {
                "width": "100%",
                "stack": []
            }
        ]
    }
]
}

我错过了什么?Ashish 和 Twitter 不应该有指向他们特定部分的链接吗?我想要的目录输出如下:

Ashish 推特 aaa

并且每当用户将鼠标悬停在文本上时,用户应该能够单击它并导航到该部分。

标签: javascripthtml-to-pdfpdfmake

解决方案


推荐阅读