Some file extension is not supported by Viewer API in Java

Some file extension is not supported by viewer plesse find below list of extension

  • Programming and Script Files:
    • Java files (.java)
    • JavaScript files (.js)
    • C# files (.cs)
    • C++ files (.cpp)
    • CSS files (.css)
  • 3D Modeling and CAD Files:
    • Industry Foundation Classes files (.ifc)
    • STL files (.stl)
    • OBJ files (.obj)
  • Microsoft Office and Adobe Files:
    • Visio files (.vsd)
    • Macro-Enabled Excel Template files (.xltm)
    • Photoshop files (.psd)
    • Illustrator files (.ai)
  • Graphic and Image Files:
    • TIFF files (.tiff)
    • EPS files (.eps)
    • EMF files (.emf)
  • Others:
    • EPUB files (.epub)
    • TAR archive files (.tar)
    • JSON files (.json)

Please find below code for viewer

public AppResonse<GroupDocsRenderResponse> processView(GroupDocsRenderRequest renderRequest) throws JsonProcessingException {
        String successMessage = null;
        String errorMessage = null;
        String detailedErrorMessage = null;
        ErrorResponse errorResponse=null;
        GroupDocsRenderResponse successResponse = null;
        AppResonse<GroupDocsRenderResponse> appResonse;
        Viewer viewer = null;
        try {
            if (ObjectUtils.allNotNull(renderRequest, renderRequest.getProcess(), renderRequest.getSourceFile(), renderRequest.getExtension(), renderRequest.getDestinationFile())) {

                if (renderRequest.getProcess().trim().equalsIgnoreCase("viewer")) {
                    String providedFileExtension = renderRequest.getExtension();
                    LoadOptions loadOptions = new LoadOptions();
                    loadOptions.setFileType(FileType.fromExtension(providedFileExtension.trim().toUpperCase()));
                    viewer = new Viewer(Files.newInputStream(Paths.get(renderRequest.getSourceFile())), loadOptions);
                    PdfViewOptions viewOptions = new PdfViewOptions(renderRequest.getDestinationFile());
                    viewer.view(viewOptions);
                    successMessage = AppConstant.SUCCESS_MESSAGE;
                } else {
                    errorMessage = AppConstant.OPERATION_NOT_SUPPORTED;
                }
            } else {
                errorMessage = AppConstant.INVALID_INPUT;
            }

        } catch (Exception e) {
            e.printStackTrace();//TODO remove in production
            if(e instanceof NoSuchFileException){
                NoSuchFileException noSuchFileException =(NoSuchFileException)e;
                errorMessage= e.getMessage() +" invalid file location";
                detailedErrorMessage="File not found at source location";
            }else{
                errorMessage = e.getMessage();
                detailedErrorMessage = e.toString();
            }

        } finally {
            String debugId =appUtil.randomUUIDGenerator();
            if (null != viewer)
                viewer.close();
            if(ObjectUtils.anyNotNull(errorMessage,detailedErrorMessage))
                errorResponse = ErrorResponse.builder().message(errorMessage).issue(detailedErrorMessage).debugId(debugId).build();
            if(ObjectUtils.isNotEmpty(successMessage))
                successResponse = GroupDocsRenderResponse.builder().message(successMessage).build();

            appResonse = AppResonse.<GroupDocsRenderResponse>builder().data(successResponse).errors(errorResponse).build();
            log.info("request payload for debugId "+debugId+ " {}  " + objectMapper.writeValueAsString(renderRequest));
            log.info("response payload for debugId "+debugId+ " {}  " + objectMapper.writeValueAsString(appResonse));
        }
        return appResonse;
    }

and below code license setup

@Configuration
public class GroupDocsConfig {
    
    @Value("classpath:GroupDocs.Total.Product.Family.lic")
    Resource resourceFile;


   @Bean
   @Scope("prototype")
   public License setLicense() throws IOException {
        License license = new License();
        try (InputStream fileStream = resourceFile.getInputStream()) {
            license.setLicense(fileStream);
        }
        return license;
    }

}
 versions of api 

type or paste code here
parser - 23.9
viewer - 23.7
jdk 17
find below exception
Screenshot 2023-12-08 at 2.06.34 PM.jpg (144.2 KB)

hope above information is enough for troubleshoot so please find out why license is not working for parser and extension is not supported for viewer

Thanks & Regards
Parashar


This Topic is created by atir.tahir using Email to Topic tool.

@inforskgroup
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): VIEWERJAVA-3321

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.