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.

Thu Oct 10, 2024 3:29 pm

Hi,
I am trying to add SVG as a layer to a PDF.
The code is below. And I attach the SVG and PDF to this post.
Code: Select all
String licenseKey = ...;
LicenseProvider.setLicenseKey(licenseKey);

String basePdfPath = ...;
String svgPath = ...;

String destPdfPath = ...;
String layerName = "l...;

PdfDocument basePdf = new PdfDocument(basePdfPath);

PdfDocument svg = new PdfDocument();
svg.loadFromSvg(svgPath);

PdfLayer pdfLayer = basePdf.getLayers().addLayer(layerName);
PdfCanvas canvas = pdfLayer.createGraphics(basePdf.getPages().get(0).getCanvas());
canvas.drawTemplate(svg.getPages().get(0).createTemplate(), new Point2D.Float(0, 0));

basePdf.saveToFile(destPdfPath, FileFormat.PDF);
basePdf.clone();

Spire.PDF Version: 10.7.3
OS: Windows 11

1
When I add a layer using the above method, I get an error when I open it in Acrobat Reader.
I was able to view this PDF in Google Chrome.
With PNG, the error does not occur.
Is there any solution?
(It may possibly be a problem with Acrobat Reader.)

2
When I run the above code on Linux and open the PDF with Google Chrome on Windows, Japanese characters are garbled (Tofu characters).
When I convert SVG to PNG in the same environment, the characters are not garbled. I think the font issue in this environment is cleared.
Also, the fonts are installed in the environment where the PDF is displayed.
What could be the cause?

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

Fri Oct 11, 2024 6:22 am

Hello,

Thanks for your inquiry.
Question 1:
I reproduced the problem using the document you provided. This issue has been logged in our bug tracking system under the number SPIREPDF-7113. Our Dev team will investigate it further, once there is any update, we will let you know.
Question 2:
I tested on 'Ubuntu 22.04.4 LTS' and found that when the 'Arial Unicode MS' font is missing in the system environment, Japanese characters appear as garbled. Are you sure you have installed this font in your system? You can check if the font exists in the '/usr/share/fonts' directory and ensure that your program has permission to access the font. If the problem still persists, please provide us with your Linux version information for investigation.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Thu Oct 31, 2024 1:58 am

Hello,

Thank you for your patience.
Glad to inform that we just released Spire.Pdf for Java 10.10.7 hotfix which fixes the bug of SPIREPDF-7113, welcome to download it from the following link and test it.

Our website link: https://www.e-iceblue.com/Download/pdf-for-java.html

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Tue Nov 19, 2024 12:19 pm

Hello,
Thanks for your reply.
We will try it.
Thank you

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

Wed Nov 20, 2024 1:26 am

Hello,

Thanks for your reply. Looking forward to your test results! If you have any questions or need further assistance during the process, please don't hesitate to reach out. I'm here to help.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 283
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF