【发布时间】:2017-12-27 14:34:18
【问题描述】:
我正在尝试将使用 cameraa 拍摄的图像转换为 A4 PDF
// Read image width and height
float imageWidth = bitmap.getWidth();
float imageHeight = bitmap.getHeight();
// Read page width and height ignoring the margins
float pageWidth = PDRectangle.A4.getWidth() - (margin_left_right * 2);
float pageHeight = PDRectangle.A4.getHeight() - (margin_top_bottom * 2);
Log.d("Image Resize", String.valueOf(imageWidth) + " x " + String.valueOf(imageHeight));
Log.d("Image Resize", String.valueOf(pageWidth) + " x " + String.valueOf(pageHeight));
# Image: 4160.0 x 3120.0
# Page: 575.27563 x 821.8898
Log.d("Image Resize", String.valueOf(requiredRatio));
Log.d("Image Resize", String.valueOf(newImageWidth) + " x " + String.valueOf(newImageHeight));
# Required ratio: 0.13828741
# After scaling: 575 x 431
问题是大小为4160 x 3120 的图像,在调整为575 x 431 后,看起来非常像素化。
PDF 一般如何解决这个问题?使用contentStream.drawImage()写作时,有没有办法在600 dpi说4160 x 3120?
这个question 还支持这样一个事实,即如果在不调整大小等于图像高度和宽度的页面上编写,OP 只能看到 15% 的图像,应该如何缩小而不损失质量?
【问题讨论】: