com.aspose.pdf.internal.ms.System.z106: Specified method is not supported

@senthil125

Please check following code snippet which we have used for testing the scenario. We did not create blank PDF and add page to it - instead, we have performed find and replace operation on the PDF which you have shared after setting the font substitution.

public void FindAndReplace() throws java.lang.Exception
{
	//Set the folder with the only one font LiberationSans-Regular.ttf
        Document.setLocalFontPaths(new ArrayList());
        Document.addLocalFontPath("/usr/share/fonts/");

        //configure font substitution
        CustomSubst1 subst1 = new CustomSubst1();
        FontRepository.getSubstitutions().add(subst1);
        
        // Open document
        com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(dataDir + "templateVOE.pdf");

        // Create TextAbsorber object to find all instances of the input search phrase
        com.aspose.pdf.TextFragmentAbsorber textFragmentAbsorber = new com.aspose.pdf.TextFragmentAbsorber("#borrowerName");

        // Accept the absorber for first page of document
        pdfDocument.getPages().accept(textFragmentAbsorber);

        // Get the extracted text fragments into collection
        com.aspose.pdf.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();

        // Loop through the fragments
        for (com.aspose.pdf.TextFragment textFragment : (Iterable<com.aspose.pdf.TextFragment>) textFragmentCollection)
        {
            // Update text and other properties
            textFragment.setText("Batman");

        }
        // Save the updated PDF file
        pdfDocument.save(dataDir + "Updated_Text_new.pdf");
    }
	
    private static class CustomSubst1 extends com.aspose.pdf.text.CustomFontSubstitutionBase
    {
        public boolean trySubstitute(com.aspose.pdf.text.CustomFontSubstitutionBase.OriginalFontSpecification originalFontSpecification, /*out*/ com.aspose.pdf.Font[] substitutionFont)
        {        
            try
            {
                substitutionFont[0] = FontRepository.findFont("DejaVuSans");;
            } catch (java.lang.NullPointerException e)
            {
                return false;
            }
            return true;            
        }
    } 

Please also check the font directory in attached image, which path was used in the above code snippet. Font_Directory.png (39.7 KB) In case we have missed some routine while testing the scenario, you may please highlight it, so that we can again test the scenario and try to replicate the error in our environment.

Asad,

Thanks for your fast response. I am getting “Sorry, this file is private. Only visible to topic owner and staff members.” when I try to open the files you uploaded.

@senthil125

Please try to login again after logging out and download the attachment. In case you still face any issue, you may please download the image from this link.

Asad,

I am still facing the issue. I can’t download from the link you provided because of our proxy. Is that possible for you to send me as text here?

@senthil125

There is font directory shown in the screenshot which we have share with you.

It is the same as we had shared you in our earlier reply i.e /usr/share/fonts/.