I am trying to convert image shot using cameraa to 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
Problem is image with size 4160 x 3120
, after getting resized to 575 x 431
, looks very pixelated.
How do PDFs solve this problem in general? Is there a way to say 4160 x 3120
at 600 dpi
when writing using contentStream.drawImage()
?
This question also supports the fact that if written without resizing on pages of size equal to the height and width of the image, OP could only see the images at 15%, how should that be scaled down without loss of quality?