unable to change the default fall back font in webviewer in springboot application

Product: apryse webviewer

Please give a brief summary of your issue:
unable to change the default fall back font in webviewer in springboot application

Please describe your issue and provide steps to reproduce it:

  • We are having an springboot application to convert pdf document to word

  • Unable to change the default fall back font in webviewer in springboot application using the fonts inside our application in resource folder and the resource folder path is fed to : PDFNet.addResourceSearchPath

  • PDFNet.addResourceSearchPath(“/usr/local/WebSphere/AppServer/customlib/apryse-webviewer/fonts”);

  • the fonts folder has
    └── fonts/
    ├── arial.ttf
    ├── arialbd.ttf
    ├── ariali.ttf
    └── arialbi.ttf

  • All the needed permissions has been given.

  • By default the font fonts are changes to dejavu sans condensed and

Please provide a link to a minimal sample where the issue is reproducible:

byte[] fileBytes = null;
File tempDocx = null;
PDFDoc pdfDoc = null;

try{
PDFNet.initialize(webViewerLicense);
PDFNet.addResourceSearchPath(structureOutputPath); // Update path
PDFNet.addResourceSearchPath(“/usr/local/WebSphere/AppServer/customlib/apryse-webviewer/fonts”);

if (!StructuredOutputModule.isModuleAvailable()) {
    throw new ServiceException("STRUCTURED_OUTPUT_MODULE_NOT_AVAILABLE");
}

    pdfDoc = new PDFDoc(new ByteArrayInputStream(document);
    tempDocx = File.createTempFile(docId.toString(), ".docx", new File(junkFilePath));
    Convert.toWord(pdfDoc, tempDocx.getAbsolutePath());
    fileBytes = Files.readAllBytes(tempDocx.toPath());

} catch (Exception e){
LoggerUtils.error(e);
throw new ServiceException(e.getMessage());
} finally {
if (tempDocx != null) tempDocx.delete();
if(pdfDoc != null) pdfDoc.close();
PDFNet.terminate();
}
LoggerUtils.logExit();
return fileBytes;

=> Kindly help with this scenario

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


It seems like you’re having trouble setting custom fallback fonts in your Spring Boot application using Apryse’s WebViewer. This issue often arises when the custom fonts are not correctly recognized or prioritized over the default fonts like DejaVu Sans Condensed.

Some things you can try:

  • Ensure the custom fonts are correctly placed in the specified directory and that the directory is accessible by your application.

  • Verify that the PDFNet.addResourceSearchPath method is called before initializing the PDF document and any conversion tasks.

  • Check the font files to ensure they are not corrupted and are in a supported format (e.g., TTF or OTF).

  • Ensure that the application has the necessary permissions to read the fonts from the specified directory.

  • Review the order of the addResourceSearchPath calls to ensure your custom path is added before any default paths.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

Hi there,

Please see this guide on setting the fallback/substitution font in WebViewer:

You will need to host the fonts in an HTTPS server and then use the setCustomFontURL API in WebViewer to fetch it.

Best regards,

Kevin