Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sat Jul 02, 2022 3:21 pm

(I have not yet obtained sufficient information from our user.)

Hi,
When I convert a PDF to PNG with embedded fonts, probably PostScript(Type 1) fonts, the text is misaligned.
The PDF was probably created by "PDF reDirect" and probably has Type 1 fonts.

I have attached screenshots.
I am asking the user if I can upload the PDF to this forum.
01_pdf: Part of the PDF
02_to_png: Created PNG
03_pdf_properties: Properties of the PDF
04_font: Font of the text shown in 01_pdf (copied and pasted from AcrobatReader to MS Word)

Code:
BufferedImage image = srcDocument.saveAsImage(i, PdfImageType.Bitmap, 300, 300);
ImageIO.write(image, "PNG", pngPath.toFile());

OS:
Amazon Linux 2

team_ssb
 
Posts: 14
Joined: Fri Nov 26, 2021 1:30 pm

Mon Jul 04, 2022 5:38 am

Hello,

Thanks for your inquiry.

I noticed that after pasting the text into Word, the glyphs were already inconsistent with the PDF. I think this is because the font "TT17AC2o00" is not installed in your system. Word makes a substitution for the actual display font for this text.
Also, for the problem of text offset after converting to pictures. I think this does require the original PDF file to reproduce and investigate. If you can get it from the user, please provide it to us. For security, you can send it to us via email (support@e-iceblue.com). The file will be kept strictly confidential and used for testing purposes only. Thanks in advance for your assistance.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed Jul 06, 2022 12:22 pm

Hi,
Thank you for your reply.
I got the PDF and attached it.

pom.xml
Code: Select all
<dependency>
    <groupId>e-iceblue</groupId>
    <artifactId>spire.pdf</artifactId>
    <version>5.5.0</version>
</dependency>


code:
Code: Select all
PdfDocument srcDocument = ...;
Path dstDirPath = ...;

int numPages = srcDocument.getPages().getCount();
for (int i = 0; i < numPages; i++) {
    String baseFileName = String.format("%04d", i + 1);
    Path pngPath = dstDirPath.resolve(baseFileName + ".png");
    BufferedImage image = srcDocument.saveAsImage(i, PdfImageType.Bitmap, 300, 300);
    ImageIO.write(image, "PNG", pngPath.toFile());
}


Thank you

team_ssb
 
Posts: 14
Joined: Fri Nov 26, 2021 1:30 pm

Thu Jul 07, 2022 7:49 am

Hi,

Thanks for your sharing.

I did reproduce this issue and reproted it to our Dev team with the ticket SPIREPDF-5322. We'll investigate further and fix it. Sorry for the inconvenience caused.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed Jul 20, 2022 12:07 pm

Hi,
Thank you for your reply.

We tested our test PDF to PNG conversion with pdftocairo in poppler-utils.
We did not encounter this problem.

Code: Select all
pdftocairo -png -r 300 ${src_pdf} ${dst_png}


Thank you

team_ssb
 
Posts: 14
Joined: Fri Nov 26, 2021 1:30 pm

Thu Jul 21, 2022 8:44 am

Hi,

Thanks for your reply.

Glad to know that you have solved this problem in other ways. But for Spire.PDF, we also just fixed this issue. The fix will be added to the next new release, and I'll let you know when that time.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed Aug 03, 2022 8:48 am

Hi,

Thanks for your patience!

Glad to inform you that we just released Spire.Pdf For Java Version:8.8.0 which fixes your issue SPIREPDF-5322.

Please download the fix version from the following links to test.
Website link:
Code: Select all
https://www.e-iceblue.com/Download/pdf-for-java.html

Maven:
Code: Select all
https://repo.e-iceblue.com/service/rest/repository/browse/maven-public/e-iceblue/spire.pdf/8.8.0/
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Return to Spire.PDF