求助:aspose.cad- dwg文件转换成PDF文件,如何使用SHX字体进行转换?

public static void dwgToPdf (String uuid, String fileName, String fileExtension) throws IOException
{
// 根据uuid得到文件在服务器的存储路径
String zipFilePath = StringUtils.format(“{}/{}”, getUploadPath(), uuid);

    // 如果文件不存在抛出异常
    File file = new File(zipFilePath);
    if (!file.exists())
    {
        throw new FileNotFoundException("文件在服务器上不存在!");
    }
    try(ZipFile zipFile = new ZipFile(zipFilePath))
    {
        List<FileHeader> headers = zipFile.getFileHeaders();
        if(headers.stream().noneMatch(x -> x.getFileName().toLowerCase().endsWith(".dwg")))
        {
            throw new FileNotFoundException("文件异常!");
        }
        if(headers.stream().anyMatch(x -> x.getFileName().toLowerCase().endsWith(".pdf")))
        {
            zipFile.removeFile(StringUtils.format("{}{}",fileName,".pdf"));
        }
        try(
                net.lingala.zip4j.io.inputstream.ZipInputStream zis = zipFile.getInputStream(zipFile.getFileHeader(StringUtils.format("{}{}",fileName,fileExtension)));
                BufferedInputStream bis = new BufferedInputStream(zis);
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                BufferedOutputStream bos = new BufferedOutputStream(os);
        )
        {
            LoadOptions opts = new LoadOptions();
            opts.setSpecifiedEncoding(CodePages.Utf8);

            Image image = Image.load(bis, opts);

            CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
            cadRasterizationOptions.setBackgroundColor(Color.getWhite());
            cadRasterizationOptions.setScaleMethod(ScaleType.GrowToFit);

// cadRasterizationOptions.setDrawType(CadDrawTypeMode.UseObjectColor);

            PdfOptions pdfOptions = new PdfOptions();
            pdfOptions.setVectorRasterizationOptions(cadRasterizationOptions);

            image.save(bos, pdfOptions);
            bos.flush();

            ZipParameters parameters = new ZipParameters();
            parameters.setFileNameInZip(StringUtils.format("{}{}",fileName,".pdf"));

            try(
                    InputStream is = new ByteArrayInputStream(os.toByteArray());
                    BufferedInputStream bis2 = new BufferedInputStream(is)
            )
            {
                zipFile.addStream(bis2, parameters);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        catch (Exception e)
        {
            throw e;
        }
    }
    catch (Exception e)
    {
        throw e;
    }
}

font.zip (4.6 MB)

@dream.xg,
你好。
您需要指定每个 SHX 字体文件的路径:

...
cadRasterizationOptions.setShxFonts( new String[] {
		"pathTo\\bigfont.shx",
		"pathTo\\txt.shx",
});
...