【发布时间】:2021-08-12 06:56:07
【问题描述】:
我想在生成的 pdf 中除了我的标题之外添加我的应用程序的徽标。我正在使用下面的代码来执行此操作,但图像的大小并没有减小。任何帮助表示赞赏。
// Creating Paragraphs
String heading = "Declaration Letter";
Paragraph head = new Paragraph(heading).setBold().setFontSize(20);
Paragraph paragraph1 = new Paragraph();
paragraph1.add("This is to certify that the Product Serial Number ");
// Adding paragraphs to document
ImageData data = ImageDataFactory.create("img.png");
Image image = new Image(data);
// set Absolute Position
//image.setFixedPosition(450f, 10f);
image.scaleAbsolute(20f, 20f);
// set Scaling
image.setAutoScaleHeight(true);
image.setAutoScaleWidth(true);
document.add(image);
document.add(head);
document.add(space);
document.add(space);
document.add(paragraph1);
现在它看起来像 image1。我想要标题左侧的小图标。
【问题讨论】:
-
看起来您使用的是 itext 7。在这种情况下,您应该添加 itext7 标记。话虽这么说,通过将
AutoScale设置为true,您告诉itext 忽略您的scaleAbsolute呼叫,不是吗?