Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在itextpdf列表中添加图像?_Itext - Fatal编程技术网

如何在itextpdf列表中添加图像?

如何在itextpdf列表中添加图像?,itext,Itext,这是我下面的简单代码,我想在列表中添加一个图像,但它不起作用,如果我想添加字符串为“item 2”的图像,我应该怎么做?有人有什么建议吗?非常感谢 Image image = Image.getInstance("xx.jpg"); List unorderedList = new List(List.UNORDERED); unorderedList.add(new ListItem("Item 1")); unorder

这是我下面的简单代码,我想在列表中添加一个图像,但它不起作用,如果我想添加字符串为“item 2”的图像,我应该怎么做?有人有什么建议吗?非常感谢

Image image = Image.getInstance("xx.jpg");
    List unorderedList = new List(List.UNORDERED);
                unorderedList.add(new ListItem("Item 1"));
                unorderedList.add(new ListItem("Item 2"));
                unorderedList.add(image);
                document.add(unorderedList);

我做到了!因为类ListItem扩展了类段落,所以我们可以编写

Paragraph a = new ListItem(); a.add(image); unorderedList.add(a);

然后可以将图像添加到列表中

我已经做到了!因为类ListItem扩展了类段落,所以我们可以编写

Paragraph a = new ListItem(); a.add(image); unorderedList.add(a);
然后可以将图像添加到列表中