Free Support Forum -

Bad pdf Effect in converting Image

the result is like SXST2011S2054-1.jpg SXST2011S2054-2.jpg

Hi there,

Thanks for your inquiry. I have tested the PDF to JPEG scenario with shared document using Aspose.Pdf for Java 11.1.0 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWJAVA-35487 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

We are sorry for the inconvenience caused.

<span style=“font-size:10.0pt;line-height:115%;font-family:“Arial”,“sans-serif”;
mso-fareast-language:EN-US;mso-bidi-language:AR-SA”>Best Regards,,

Thanks for your patience.

We have further investigated the earlier reported issue and it does not seem to be a bug. In order o generate correct output, you need to correctly find the fonts used in the document. Therefore we advice the usage of following approach to check which font is missing on the system and how to substitute such fonts.

Please try using the latest release of Aspose.Pdf for Java 17.6 and in case you still face the same issue or you have any further query, please feel free to contact.

String myDir = "c:/pdftest/";

//configure font substitution
CustomSubstitutor subst1 = new CustomSubstitutor();
//create PdfConverter object
com.aspose.pdf.facades.PdfConverter objConverter = new com.aspose.pdf.facades.PdfConverter();
//bind input pdf file

//Configure notifier to console
((Document)objConverter.getDocument()).FontSubstitution.add(new Document.FontSubstitutionHandler()
    public void invoke(com.aspose.pdf.Font font, com.aspose.pdf.Font newFont)
        //print substituted FontNames into console
        System.out.println("Warning: Font "+ font.getFontName() + " was substituted with another font -> " + newFont.getFontName());

//initialize the converting process
int i=1;
//check if pages exist and then convert to image one by one
while (objConverter.hasNextImage()){
objConverter.getNextImage(myDir +i + "_subsituted.jpg",com.aspose.pdf.ImageType.getJpeg());// new java.util.Date().toString()
//close the PdfConverter object

  private static class CustomSubstitutor extends com.aspose.pdf.text.CustomFontSubstitutionBase
        public boolean trySubstitute(OriginalFontSpecification originalFontSpecification, /*out*/ com.aspose.pdf.Font[] substitutionFont)
        if (!originalFontSpecification.isEmbedded())
            	com.aspose.pdf.Font f = com.aspose.pdf.FontRepository.findFont(originalFontSpecification.getOriginalFontName());
            } catch (com.aspose.pdf.exceptions.FontNotFoundException e)
                System.out.println("Warning: Font is not embedded and not found in the system ("+ originalFontSpecification.getOriginalFontName() + ") should be substituted -> ");
                //substitute all the missed fonts with the existing compatible font, for example:  MSGothic
                substitutionFont[0] = FontRepository.findFont("MSGothic");
        return true;   
          return super.trySubstitute(originalFontSpecification, /*out*/ substitutionFont);

The “MSGothic” font is not the intended font and it is used only for example to show process of the fonts substitution and it does not contain all the necessary symbols. Please, use more appropriate font for this document.