为有中文需求的客户提供多渠道中文技术支持.

Mon Oct 24, 2022 6:38 am

Spire.Presentation for Java 7.10.1
saveToSVG()函数
同一个文件在不同的系统环境中存在不同的运行结果

Code: Select all
byte[] svgByte = ppt.getSlides().get(slide_num).saveToSVG();
            String svgStr = new String(svgByte, StandardCharsets.UTF_8);
            log.info("s第{}页vg信息\t{}",slide_num,svgStr);


在windows 11系统中运行结果是
Code: Select all
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="main2" width="1280" height="720">

   <g transform="matrix(1.333333 0 0 1.333333 0 0)">
        <path stroke="none" fill="#333f50" fill-rule="evenodd" d="M0 0L960 0L960 540L0 540z" transform="matrix(1 0 0 1 0 0)"  />
        <path stroke="none" fill="#ffc000" fill-rule="evenodd" d="M42.01629 49.23126L280.5559 49.23126L280.5559 92.73126L42.01629 92.73126z" transform="matrix(1 0 0 1 0 0)"  />
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="0.5483246" y="28.52813">ADD</text>
      <text style="fill:#ffffff;font-family:Times New Roman;font-weight:bold;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="45.34911" y="28.52813"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="50.77489" y="28.52813">YOUR</text>
      <text style="fill:#ffffff;font-family:Times New Roman;font-weight:bold;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="108.6538" y="28.52813"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="114.0796" y="28.52813">TITLE</text>
      <text style="fill:#ffffff;font-family:Times New Roman;font-weight:bold;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="166.0991" y="28.52813"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="171.5249" y="28.52813">HERE</text>
        <path stroke="none" fill="#ffc000" fill-rule="evenodd" d="M42.01638 106.5596L165.1272 106.5596L165.1272 150.0596L42.01638 150.0596z" transform="matrix(1 0 0 1 0 0)"  />
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21638 110.1596)" x="3.232391" y="28.52813">ADD</text>
      <text style="fill:#ffffff;font-family:Times New Roman;font-weight:bold;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21638 110.1596)" x="48.03317" y="28.52813"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21638 110.1596)" x="53.45895" y="28.52813">TITLE</text>
   </g>
</svg>



在centOs环境中,运行结果是

Code: Select all

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="main17" width="1280" height="720">

   <g transform="matrix(1.333333 0 0 1.333333 0 0)">
        <path stroke="none" fill="#333f50" fill-rule="evenodd" d="M0 0L960 0L960 540L0 540z" transform="matrix(1 0 0 1 0 0)"  />
        <path stroke="none" fill="#ffc000" fill-rule="evenodd" d="M42.01629 49.23126L280.5559 49.23126L280.5559 92.73126L42.01629 92.73126z" transform="matrix(1 0 0 1 0 0)"  />
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="0.5483246" y="25.35001">ADD</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="45.34911" y="25.35001"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="50.77489" y="25.35001">YOUR</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="108.6538" y="25.35001"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="114.0796" y="25.35001">TITLE</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="166.0991" y="25.35001"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="171.5249" y="25.35001">HERE</text>
        <path stroke="none" fill="#ffc000" fill-rule="evenodd" d="M42.01638 106.5596L165.1272 106.5596L165.1272 150.0596L42.01638 150.0596z" transform="matrix(1 0 0 1 0 0)"  />
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21638 110.1596)" x="3.232391" y="25.35001">ADD</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21638 110.1596)" x="48.03317" y="25.35001"> </text>
      <text style="fill:#ffffff;font-family:Calibri;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21638 110.1596)" x="53.45895" y="25.35001">TITLE</text>
   </g>
</svg>

Last edited by DemosHume on Mon Oct 24, 2022 7:04 am, edited 2 times in total.

DemosHume
 
Posts: 35
Joined: Mon Jan 17, 2022 10:22 am

Mon Oct 24, 2022 6:43 am

各文本元素的y值并不相同,在linux环境中之前甚至出现过文本错误换行的情况。

尝试过在代码中增加

Code: Select all
        Locale newLocale = Locale.SIMPLIFIED_CHINESE;
        Locale.setDefault(newLocale);


但是并没有使两个环境下运行结果一致。

DemosHume
 
Posts: 35
Joined: Mon Jan 17, 2022 10:22 am

Mon Oct 24, 2022 7:02 am

在7.9.1 的版本中,centOS 环境下运行结果为

Code: Select all
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="main1" width="1280" height="720">

   <g transform="matrix(1.333333 0 0 1.333333 0 0)">
        <path stroke="none" fill="#333f50" fill-rule="evenodd" d="M0 0L960 0L960 540L0 540z" transform="matrix(1 0 0 1 0 0)"  />
        <path stroke="none" fill="#ffc000" fill-rule="evenodd" d="M42.01629 49.23126L280.5559 49.23126L280.5559 92.73126L42.01629 92.73126z" transform="matrix(1 0 0 1 0 0)"  />
      <text style="fill:#ffffff;font-family:Liberation Sans;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="12.72411" y="12.3151">ADD</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="63.39598" y="12.3151"> </text>
      <text style="fill:#ffffff;font-family:Liberation Sans;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="70.06395" y="12.3151">YOUR</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="139.4038" y="12.3151"> </text>
      <text style="fill:#ffffff;font-family:Liberation Sans;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="146.0718" y="12.3151">TITLE</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21629 52.83126)" x="211.4155" y="12.3151"> </text>
      <text style="fill:#ffffff;font-family:Liberation Sans;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21629 52.83126)" x="78.72997" y="41.1151">HERE</text>
        <path stroke="none" fill="#ffc000" fill-rule="evenodd" d="M42.01638 106.5596L165.1272 106.5596L165.1272 150.0596L42.01638 150.0596z" transform="matrix(1 0 0 1 0 0)"  />
      <text style="fill:#ffffff;font-family:Liberation Sans;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21638 110.1596)" x="29.0195" y="12.31511">ADD</text>
      <text style="fill:#ffffff;font-family:Liberation Sans;" font-size="24" xml:space="preserve" transform="matrix(1 0 0 1 49.21638 110.1596)" x="79.69138" y="12.31511"> </text>
      <text style="fill:#ffffff;font-family:Liberation Sans;font-weight:bold;" font-size="24" transform="matrix(1 0 0 1 49.21638 110.1596)" x="21.68356" y="41.11511">TITLE</text>
   </g>
</svg>


ADD 和 TITLE 字符串间发生了换行,与实际的显示效果不同,这令为很困惑。

DemosHume
 
Posts: 35
Joined: Mon Jan 17, 2022 10:22 am

Mon Oct 24, 2022 9:34 am

您好,

感谢你的询问。
在使用最新版本7.10.1测试你的PPT文件后,确实发现在windows和centos 系统转换的SVG中文本元素的y值存在差异。我已经用SPIREPPT-2095将这个问题记录到我们的问题跟踪系统中,我们的开发团队会进一步来调查这个问题。一旦有任何更新,我们会第一时间通知您。感谢您的理解。

Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Fri Nov 18, 2022 3:21 am

Hello,

感谢您的耐心等待。
针对SPIREPPT-2095这个问题,根据我们进一步调查测试发现,要确保转换后数据完全一致,需要Linux系统中安装文档使用的字体(Calibri bold),并且使用一样的JDK,因为OpenJDK和OracleJDK本身在计算上是有不一致的。所以请先检查您的Linux系统中是否安装了Calibri bold字体,并使用的同Windows中一致OpenJDK或OracleJDK,期待你的测试结果。

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to 中文技术支持