PDF to Image(JPG) Words are overlapping

Hi I am using following code to convert my pdf into image. And its working fine on my Windows 10 machine. Images are same pdf. But when i upload my code to Linux server. And try to convert PDF to Image. All the chars of pdf are overlapping to each other. I do not understand why this is happening…
I have attached image created from both server and actual document also. We are using Paid version( Order ID: 190430152208)

LINUX_SERVER_IMAGE_sales contract-salesforce-no-cc_duplicate_1560413223129-2.jpg (104.4 KB)
sales contract-salesforce-no-cc_duplicate(1).pdf (167.8 KB)
WINDOW10_SERVER_IMAGE_sales contract-salesforce-no-cc_duplicate_1560413036306-2.jpg (526.8 KB)

@chetanblu

Thanks for contacting support.

We have tested the scenario in our environment with Aspose.PDF for Java 19.5 and were unable to notice the issue. For your kind reference, an output image is also attached.

Converted_Image1.jpg (527.2 KB)

It seems that the issue is related to missing fonts in your environment. Would you please make sure to install all Microsoft Essential Fonts in your Linux Server and in case issue still persists, please share the OS Name and Version with us. We will further proceed to assist you accordingly.

But you can see my attachments that i sent you see " [LINUX_SERVER_IMAGE_sales contract-salesforce-no-cc_duplicate_1560413223129-2.jpg]" file all characters are overlap

@chetanblu

Yes, we observed the abnormalities in the image share by you but we were unable to replicate similar issue in our environment. As requested earlier, please try to install Microsoft Essential Fonts in your environment and try the conversion again as the issue seems related to missing fonts in system. In case issue still persists, please share OS Name and Version with us so that we can proceed further.

we’re running “Amazon Linux AMI release 2018.03”. The server is an EC2 instance on AWS.

@blusynergy

We have logged an investigation ticket as PDFJAVA-38634 in our issue tracking system for further analysis. We will look into details of the issue and keep you posted with the status of ticket resolution. Please be patient and spare us little time. Would you please confirm if all suggested fonts are installed in target system?

These are the installed fonts:

[ec2-user@prod01 ~]$ yum list available font | grep noarch | sed -e “s/noarch.*$/noarch/” | sort
cjkuni-fonts-common.noarch
cjkuni-fonts-ghostscript.noarch
cjkuni-ukai-fonts.noarch
cjkuni-uming-fonts.noarch
dejavu-lgc-sans-fonts.noarch
dejavu-lgc-sans-mono-fonts.noarch
dejavu-lgc-serif-fonts.noarch
dejavu-sans-mono-fonts.noarch
fontpackages-devel.noarch
fontpackages-tools.noarch
ghostscript-fonts.noarch
ipa-gothic-fonts.noarch
ipa-mincho-fonts.noarch
liberation-fonts-common.noarch
liberation-mono-fonts.noarch
liberation-sans-fonts.noarch
liberation-serif-fonts.noarch
overpass-fonts.noarch
perl-Font-AFM.noarch
perl-Font-TTF.noarch
stix-fonts.noarch
stix-math-fonts.noarch
texlive-amsfonts-doc.noarch
texlive-amsfonts.noarch
texlive-collection-fontsrecommended.noarch
texlive-fontbook-doc.noarch
texlive-fontbook.noarch
texlive-fontspec-doc.noarch
texlive-fontspec.noarch
texlive-fontware.noarch
texlive-fontwrap-doc.noarch
texlive-fontwrap.noarch
texlive-latex-fonts-doc.noarch
texlive-latex-fonts.noarch
texlive-metafont.noarch
texlive-pxfonts-doc.noarch
texlive-pxfonts.noarch
texlive-txfonts-doc.noarch
texlive-txfonts.noarch
texlive-xetexfontinfo-doc.noarch
texlive-xetexfontinfo.noarch
urw-fonts.noarch
vlgothic-fonts-common.noarch
vlgothic-fonts.noarch
vlgothic-p-fonts.noarch
wqy-zenhei-fonts-common.noarch
wqy-zenhei-fonts.noarch
xorg-x11-fonts-100dpi.noarch
xorg-x11-fonts-75dpi.noarch
xorg-x11-fonts-cyrillic.noarch
xorg-x11-fonts-ethiopic.noarch
xorg-x11-fonts-ISO8859-1-100dpi.noarch
xorg-x11-fonts-ISO8859-14-100dpi.noarch
xorg-x11-fonts-ISO8859-14-75dpi.noarch
xorg-x11-fonts-ISO8859-15-100dpi.noarch
xorg-x11-fonts-ISO8859-15-75dpi.noarch
xorg-x11-fonts-ISO8859-1-75dpi.noarch
xorg-x11-fonts-ISO8859-2-100dpi.noarch
xorg-x11-fonts-ISO8859-2-75dpi.noarch
xorg-x11-fonts-ISO8859-9-100dpi.noarch
xorg-x11-fonts-ISO8859-9-75dpi.noarch
xorg-x11-fonts-misc.noarch

@blusynergy

Thanks for providing requested information.

We have updated the issue description accordingly and will let you know in case of additional updates.

We need a resolution on this ticket in a timely manner or a refund of the payment please. It’s been a month and this product is not usable due to this issue

@blusynergy

We apologize for the inconvenience faced.

The issue was logged on June 18, 2019 under free support model and it has low priority. As issues are resolved on first come first serve basis in free support model, your issue has been pending for analysis. However, we have recorded your concerns and will definitely consider them during issue investigation. We will surely inform you as soon as we make significant progress towards issue resolution. Please spare us little time.

We are sorry for the inconvenience.

@asad.ali, what is update on this? As mentioned previously, this product was purchased for this one task, and if we are unable to use it for its stated purchase, then please refund the purchase price to our credit card.

@blusynergy

We would like to share with you that we have investigated your issue and found that the reason of exception was absence of basic MS Fonts on the Linux Machine. It is recommended to install all basic MS Fonts before performing operation using Aspose.PDF for Java. In your particular case, the Times New Roman font is necessary because this font was not embedded in the PDF document and still used in it. Please see attached image:

Structure.png (66.3 KB)

Also, please note that every font has own metrics (symbol height, weight, interval, etc.) and the structure of you PDF document contains words as separate characters or group of characters which is reason for overlapping. This cannot be handled without a suitable font because, each new group starts in the absolute position and because of different characters width and intervals, symbols can be overlapped.

There are two ways to fix the conversion:

  • Install msttcorefonts package for CentOS/Linux
  • Copy required fonts and set path to the font directory by method:
FontRepository.addLocalFontPath("path_to_fonts");

Also, you can use notification to know if any font was substituted because of absent font and handle default font used. Please add following code before conversion:

 CustomFontSubstitutionBase subst = new CustomFontSubstitutionBase() {
            public boolean trySubstitute(CustomFontSubstitutionBase.OriginalFontSpecification originalFontSpecification, /*out*/ com.aspose.pdf.Font[] substitutionFont) {

                System.out.println("Warning: Font " + originalFontSpecification.getOriginalFontName() + " is try to be substituted");

                if (!originalFontSpecification.isEmbedded()) {
                    try {
                        Font fSrcInRepository = FontRepository.findFont(originalFontSpecification.getOriginalFontName());
                        if (fSrcInRepository==null){

                            System.out.println("font not found");
                            return false;
//                            substitutionFont[0] = FontRepository.openFont("/path_to_font/times.ttf");//or use default specified font
//                            System.out.println("Font " + originalFontSpecification.getOriginalFontName()
//                                    + " was substituted with another font -> " + substitutionFont[0].getFontName());
                        }else {
                            substitutionFont[0] = fSrcInRepository;
                        }
                    } catch (FontNotFoundException e) {
                        System.out.println("font not found");
                        return false;
//                        substitutionFont[0] = FontRepository.openFont("/path_to_font/times.ttf");//or use default specified font
//                        System.out.println("Font " + originalFontSpecification.getOriginalFontName()
//                                + " was substituted with another font -> " + substitutionFont[0].getFontName());
                    }
                    return true;
                } else {
                    return super.trySubstitute(originalFontSpecification, substitutionFont);
                }

            }};
        FontRepository.getSubstitutions().add(subst);

We really hope that above details would help resolving your issue. In case you still face any issue, please feel free to let us know.