The next day I first came to the new company and asked me a question.
The DPI of the result image generated into the PDF is different from the resolution of the generated PDF.
I have never touched on DPI before. I don't know what it is. I can't help it. I can only use Baidu.
DPI: the abbreviation of "dot Per Inch" refers to the number of points in the length of each inch. In the Chinese version of Photoshop, we can see that the Chinese explanation is a representation of "resolution"-"pixel/Inch", that is, the pixel of the inch. The larger the DPI, the higher the quota. Generally, the DPI required by the computer is 72, and the 300 dpi is required for photo printing and printing.
Know the DPI of the image, but the DPI estimation of the PDF is the same. But I don't know how to view it. Du Niang told me to use PS to check the PS. The generated PDF is the size of the image in the PS toolbar. The resolution is 72.
At first, I thought that the PDI of PDF has something to do with the image. Just set the DPI of the image.
It won't work after half a day. Originally, my image DPI was 96. Why is the PDF always generated 72.
After studying itextpdf, I have read nothing about DPI for a long time. (Ah, the research capability is too weak)
Then stop using itexpdf.
Several PDF class libraries are used, which are powerful but not about DPI. (Total headache)
I read the pdfrenderer, but people only read the PDF, and it has not been maintained for a long time.
I read icepdf and haven't looked for it for a long time.
Looking for it and seeing pdfjet, I feel that there is a full range of dome in it.
I found example_03.java for testing. I looked at DPI changes with PS and checked every code sentence.
Finally, we can see that there is a way to set image. scaleby, but what to set in it.
Try to set 1f to 72 dpi first.
I want to convert DPI to 96, and set 72/96 = 0.75 to 0.75f.
Result The DPI of the PDF file is actually 96.
Return the code in the project to see if itexpdf also has this method called scalepercent but percentage.
Image jpeg;jpeg = Image.getInstance(buffimg, null);jpeg.scalePercent(75f);
Setting a 75f DPI changes. Finally, we can solve the problem.
Alas, it's not easy. It's about 1.5D.