嗨,我们如何在iText 7中调整图像大小。我现在在itext7中找不到用于裁剪图像的PDFTemplate。。
public Image cropImage(PdfWriter writer, Image image, float leftReduction, float rightReduction, float topReduction, float bottomReduction) throws DocumentException {
float width = image.getScaledWidth();
float height = image.getScaledHeight();
PdfTemplate template = writer.getDirectContent().createTemplate(
width - leftReduction - rightReduction,
height - topReduction - bottomReduction);
template.addImage(image,
width, 0, 0,
height, -leftReduction, -bottomReduction);
return Image.getInstance(template);
}
它用于itext 5
https://stackoverflow.com/questions/46114654
复制相似问题