VSD to PDF - Text is getting wrapped as compared to Office Export to PDF

SampleVsd.zip (187.8 KB)

Hi,

We are having an issue with the attached VSD. When exporting it to PDF using Aspose, a lot of the text is wrapped compared to Office Export and VSD fidelity (see attached screenshot).

Thank you,
Mark

image.png (38.9 KB)

@markmanley.adlib

It appears you are experiencing issues with text wrapping when converting a VSD file to PDF using Aspose, particularly in comparison to the output from Microsoft Office. This discrepancy may be due to the configuration settings in your Aspose setup.

Cause: The issue likely stems from the text wrapping settings in Aspose.PDF, which can differ from those in Microsoft Office.

Solution: I recommend checking the WordWrap property in your Aspose.PDF configuration. Setting the WordWrap property to true will allow text to break into multiple lines to fit within the specified width. Additionally, consider adjusting the width settings to see if that enhances the text fidelity in your PDF output.

Next Steps: Experiment with the WordWrap property and width settings in your code. If you continue to face challenges, please share specific code snippets or settings you are using for more tailored advice.

For further assistance, reviewing similar posts in the Aspose forums may provide additional insights or solutions from users who have encountered similar issues.

Please let me know if you need any more help!

That’s not applicable here, we just want it to come out how it looks in VSD.

Thanks,
Mark

@markmanley.adlib
Thanks for the template file and screenshots.
After an initial testing, I am able to reproduce the issue as you mentioned by using your template file. I found the text is getting wrapped when saving to pdf.

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): DIAGRAMNET-53810

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.

The issues you have found earlier (filed as DIAGRAMNET-53810) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou

@markmanley.adlib
The width and other shape data stored in the original file are incorrect. We need to recalculate and refresh this data.
Please try this code to refresh shape’s data before save:

    foreach (Shape shape in diagram.Pages[0].Shapes)
    {
        CalculateOptions o = new CalculateOptions();
        o.Type = Aspose.Diagram.CalculateItemType.XForm;
        shape.RefreshData(o);
    }

That worked. Is there not an option to always refresh all the things that need it?

Cheers,
Mark

@markmanley.adlib
It is great that you were able to resolve this issue on your end.
By default, we refresh all data of shape, but this can be time-consuming.
Thanks.

Oh that’s not good. If this can be time consuming, how do we detect when we should do it?

@markmanley.adlib
This issue is caused by incorrect data stored by Visio, which rarely occurs. We can refresh the data when the shape’s width/height contain formulas. We will also gradually improve the performance of data refresh operations.
We apologize for any inconvenience caused.

Since implementing this, we are getting errors sometimes with that new code. Try running above code on the attached file (Crime scene investigation(2007)). If I put a try/catch around RefreshData, will that suffice for now? Either way, it’s an issue.

Am I able to use Aspose to detect if it needs refreshing?

We have another file that does not error, but when we refresh, it makes the logo incorrect (Computer network(2003)). So we are back at square one now.

It should be noted that Native Visio export for all 3 files works fine.

Edit: I should add that for the “Computer Network (2003)” file, it takes 20 seconds to go through and Refresh the data (only to make it worse).

Computer network(2003).zip (653.4 KB)

Crime scene investigation(2007).zip (701.3 KB)

@markmanley.adlib
Thanks for the template files.
I have tested the new template files “Crime scene investigation(2007).vsd” and “Computer network(2003).vsd” using our latest version : Aspose.Diagram for .net v25.11 . It works fine and as expected.

In most cases, we don’t need to refresh the data when saving to pdf. You can save the problematic file with Visio, or we can refresh the data when there is a formula in the shape’s width.Also We will improve the performance of data refreshing Later.
We are sorry for the inconvenience.

 foreach (Shape shape in diagram.Pages[0].Shapes)
 {
     if (shape.MasterShape != null && shape.XForm.Width.Ufe.F.Length > 0)
     {
         CalculateOptions o = new CalculateOptions();
         o.Type = Aspose.Diagram.CalculateItemType.XForm;
         shape.RefreshData(o);
     }
 }

I am using 25.11 as well, but still having issues even using latest sample code.

I have uploaded my outputs that show good and bad where I have the refresh logic and without it. As you can see, I can’t use a single flow of code to handle both, and there’s no way to know.

var fileInfo = FileFormatUtil.DetectFileFormat(inputPath);

if (!Enum.TryParse(fileInfo.LoadFormat.ToString(), true, out LoadFileFormat format))
    throw new Exception($"Could not validate file format: ({fileInfo.FileFormatType}/{fileInfo.LoadFormat})");

var loadOptions = new LoadOptions
{
    LoadFormat = format
};
var LoadFilter = new LoadFilter
{
    LoadDataFilterOptions = LoadDataFilterOptions.All
};
loadOptions.LoadFilter = LoadFilter;
var visio = new Diagram(inputPath, loadOptions);

var saveOptions = new PdfSaveOptions()
{
    SaveFormat = SaveFileFormat.Pdf,
    JpegQuality = (byte)100,
    SaveForegroundPagesOnly = true
};

CalculateOptions o = new CalculateOptions
{
    Type = CalculateItemType.XForm
};
foreach (Page page in visio.Pages)
{
    foreach (Shape shape in page.Shapes)
    {
        try
        {
            if (shape.MasterShape != null && shape.XForm.Width.Ufe.F.Length > 0)
                shape.RefreshData(o);
        }
        catch
        {

        }
    }
}
visio.Save(outputPath, saveOptions);

WithAndWithoutRefresh.zip (2.4 MB)

@markmanley.adlib
Thanks for the output files.
We will remove unnecessary refreshes in subsequent versions, ensuring that all data is correctly updated after refresh xform.

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): DIAGRAMNET-53857

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.

The issues you have found earlier (filed as DIAGRAMNET-53857) have been fixed in this update. This message was posted using Bugs notification tool by philip.zhou

What is the solution? Do I still need to go through and refresh shapes?

@markmanley.adlib

The original data saved in the Visio file “TimeLine(2010).vsd” does not match its actual display. Therefore, we must either refresh the data or resave this file using Visio.
The data refresh errors in the other files have also been fixed.

        foreach (Shape shape in diagram.Pages[0].Shapes)
        {
            if (shape.MasterShape != null && shape.XForm.Width.Ufe.F.Length > 0)
            {
                CalculateOptions o = new CalculateOptions();
                o.Type = Aspose.Diagram.CalculateItemType.XForm;
                shape.RefreshData(o);
            }
        }

We apologize for any inconvenience caused.