The image of the stamp of approval was converted incorrectly

The image of the stamp of approval was converted incorrectly.
It is like as □□.
Please give me solution.
sample.pdf (42.5 KB)

@tetsurokawabata

Cause

The issue with the stamp of approval image not rendering correctly may be due to unsupported image formats, incorrect image settings, or problems during the conversion process.

Solution

To resolve this issue, please follow these steps:

  1. Check Image Format: Verify that the image format of the stamp is supported by Aspose.Cells. Common formats such as PNG, JPEG, and BMP are recommended.

  2. Adjust Image Settings: Ensure that the image settings are correctly configured. If the image is being resized or manipulated during conversion, check the resolution and compression settings.

  3. Use PdfOptions: When saving the document, utilize the PdfOptions class to manage image handling. For instance, set the EmbedFullFonts property to true to ensure all font characters are embedded.

  4. Test with Different Images: Use a different image to determine if the issue is specific to the original image.

Code

Here’s a sample code snippet to set up the PdfOptions when saving your document:

var workbook = new Workbook("input.xlsx");
var pdfOptions = new PdfSaveOptions
{
    EmbedFullFonts = true,
    BestImagesCompressionRatio = true,
    SaveMetafilesAsPng = true
};

workbook.Save("output.pdf", pdfOptions);

Next Steps

  1. Implement the provided code and check if the image renders correctly in the output PDF.
  2. If the issue persists, inspect the original image file for any corruption or issues.
  3. Consult the Aspose documentation for specific image handling options that may be relevant to your situation.

Please let me know if you need further assistance!

@tetsurokawabata
Please check your sample file to see if the fonts used in the stamps have been installed. If not installed, please install the font first. Of course, you can also download the fonts and set custom font folders when exporting to PDF. Regarding how to set custom font folders, please refer to the following document.

If the issue still cannot be solved after installing the required fonts. Would you like to provide excel sample file and runnable test code? We will check it soon.

@John.He
Please check it.
Thank you.

sample.zip (24.8 KB)

@tetsurokawabata
We can obtain the correct results by testing on the latest version v25.7 using the following sample code. Please refer to the attachment. out_java.pdf (50.1 KB)

Workbook workbook = new Workbook(filePath + "sample.xlsx");
workbook.save(filePath + "out_java.pdf");

We recommend you to kindly try using our latest version: Aspose.Cells for Java v25.7.

If you still find the issue, kindly do share your complete sample (runnable) code to reproduce the issue on our end, we will check it soon.

Thank you.

I will try it by using the latest version v25.7 .

@tetsurokawabata
Thank you for your feedback. Please take your time to try using our latest version: Aspose.Cells for Java v25.7. Hopefully, your issue will be sorted out. Please let us know your feedback.

@John.He
I already try it by using the latest version v25.7.
But it was converted incorrectly also. □□

Can I convert it as image, but not string by using some option ?

@tetsurokawabata
Through further research, we found that the errors in exporting your file to PDF were all caused by the use of the “HGPMinchoB” font. Please ensure that the “HGPMinchoB” font is installed on your machine.

Of course, you can also download the fonts and set custom font folders when exporting to PDF. Regarding how to set custom font folders, please refer to the following document.

@tetsurokawabata

If you don’t want to install fonts, replacing the wrong places with images is also a solution. Also, please replace the incorrect areas with PNG format images. EMF and SVG are both vector graphics that contain textual description information.

“HGPMinchoB” font is not installed on my machine.

If you don’t want to install fonts, replacing the wrong places with images is also a solution. Also, please replace the incorrect areas with PNG format images. EMF and SVG are both vector graphics that contain textual description information.

I understand it.

@tetsurokawabata
Thank you for your feedback. You have two options to solve this issue. One is to install “HGPMinchoB” font. The second is to replace the wrong places with PNG format images.

In addition, if you need to modify many files, installing fonts is a better choice. This can also avoid similar issues in the future due to “HGPMinchoB” font.

@John.He
“HGPMinchoB” font is non-free.
Can I convert from “HGPMinchoB” font to other font by using aspose ?

@tetsurokawabata
Aspose.Cells uses fonts already installed on the machine to draw text. If you need to use other fonts instead, please manually replace the font in the Excel file and install it on the machine.

Of course, you can also specify the substitute font for rendering purposes in the program. Regarding how to specify the substitute font, please refer to the following document.

@tetsurokawabata ,

Please set a default font which is installed on your side at the beginning. e.g.

FontConfigs.setDefaultFontName("MS PGothic");

@John.He
Thank you.
I already try to use PdfSaveOptions.setDefaultFont.
OK ?
And Is this default Font used only when the font don’t exists on my machine ?

@tetsurokawabata
Setting the default font name is also a choice. But there is a prerequisite that the default font also needs to be installed on the machine, and this font can display the text you need to display normally.

@John.He
[FontConfigs.setDefaultFontName] and [ PdfSaveOptions.setDefaultFont] works only when the other font don’t exists on my machine ?
For example, I set default font = ‘MS PGothic’(exsists on my machine) and
only when the font exists on my machine such as ‘HGPMinchoB’, It’s default font works ?

@tetsurokawabata ,

Yes, the default fonts only work when the specified font is not installed.
For your case, if “HGPMinchoB” font is installed, “HGPMinchoB” font will be used, otherwise, the default fonts will be used.

@tetsurokawabata
Your understanding is correct. When the required font is not installed, Cells will use the default font set for display. But the prerequisite is to ensure that the default font is installed on the machine and can display those words, otherwise display errors may also occur.