Project文件中文时间戳在导出为pdf后显示成英文

projectbug.zip (439.3 KB)
在进行project文件转换为pdf时中文时间戳等内容会转换成英文,请问这是一个bug还是需要在转换时添加特殊操作,谢谢
压缩包中包含截图、原文件、转换后的pdf及测试代码

@wdacat

您可以尝试以下代码示例,它工作正常。 如果问题没有解决,请回复我们。

// Read the input Project file
Project project = new Project("D:\\projectbug\\" + "project2007.mpp");

// Save the Project as PDF
project.save("D:\\projectbug\\" + "Project1.pdf", SaveFileFormat.PDF);

    // Fitting contents to cell size
    Project project1 = new Project("D:\\projectbug\\" + "project2007.mpp");
    SaveOptions o = new PdfSaveOptions();

    // Set the LegendOnEachPage property to false to hide legends

    // Set the row height to fit cell content
    o.setFitContent(true);
    o.setTimescale(Timescale.Months);
    o.setPresentationFormat(PresentationFormat.TaskUsage);
    project1.save("result_months.pdf", o);
    o.setLegendOnEachPage(false);
    project1.save("D:\\projectbug\\" + "result_months_WithoutLegend.pdf", o);

    //Display result of conversion.
    System.out.println("Process completed Successfully");

在增加了这段代码之后文字显示不全的问题得到了解决
但是中文内容显示为英文并没有得到解决
请您继续关注一下
如果您不知道是在哪里您可以注意一下两个截图中年月日的显示方式
转换前为年月日汉字,转换后为year month day,我们希望能够正确获得转换为中文的pdf

@wdacat

我们已使用ID“TASKS JAVA-748”记录此问题以供进一步调查。 一旦我们有更多信息要分享,您将自动收到通知。

不知道您那边进度如何,如果方便的话能否告诉我一下这个问题什么时候可以解决

@wdacat

我们仍在努力解决这个问题,我们会在收到更多相关信息后立即通知您。

@wdacat

我们调查了这个问题并发现:

1)我们目前无法实现持续时间列的特定于文化的格式。 因为它使用MS Project的语言包而不是操作系统的区域设置。
这意味着我们必须为MS Project支持的所有现有语言实现持续时间格式。

2)我们将修复日期列格式化(‘开始’和’完成’),以使其正确使用当前的区域设置。

3)用户现在可以使用以下解决方法(使用最新版本的Aspose.Tasks):

private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy'年'M'月'd'日'");

    private void Test() throws IOException
    {
        Project project = new Project("e:\\project2007.mpp");
        PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
        ProjectView v = ProjectView.getDefaultGanttChartView();

        v.getColumns().set(3, new GanttChartColumn(
                "Duration",
                120,
                new FormatDuration()));

        v.getColumns().set(4, new GanttChartColumn(
                "Start",
                150,
                new FormatStartDate()));

        v.getColumns().set(5, new GanttChartColumn(
                "Finish",
                150,
                new FormatFinishDate()));


        pdfSaveOptions.setView(v);

        project.save("e:\\SaveProjectAsPDF_out.pdf", pdfSaveOptions);
    }

    private class FormatStartDate implements TaskToColumnTextConverter
    {
        public String invoke(Task task)
        {
            return formatter.format(task.get(Tsk.START));
        }
    }

    private class FormatFinishDate implements TaskToColumnTextConverter
    {
        public String invoke(Task task)
        {
            return formatter.format(task.get(Tsk.FINISH));
        }
    }


    private class FormatDuration implements TaskToColumnTextConverter
    {
        public String invoke(Task task)
        {
            // here we can implement culture-specific format
            return task.get(Tsk.DURATION).toString();
        }
    }

请在此处找到生成文件的屏幕截图 Screen 023.png (40.3 KB).

此外,如果您有任何疑问,请随时回复我们。