Scale page to fit diagram

Hy,

i’ve search for hours to find an answer but didn’t get it, hope to find it here.
Im using VISIO 2016 and C# as a consol.
So want to make a single page with shapes on it from an extern CSV in right order. Thats working fine but i can’t scale the page on the diagram, couse its have to be dynamically i cant use a fix page size.
I’ve tryied out:

var.PageSheet.PageProps.DrawingResizeType.Value = DrawingResizeType.Automaticlly
var.PageSheet.PageProps.DrawingSizeType.Value = DrawingSizeType.FitPageDrawContents
var.PageSheet.PageProps.DrawingScale.Value = XXX
var.PageSheet.PageProps.PageScale.Value = XXX
var.AutoFitPageToDraingContet = true;

That doesnt work for me, maybe its a problem on my side, becouse i don’t used scale for pages befor. Would be nice if somebody could help me with tips or link, thx.

@dvvde,
Kindly send us the complete details of the use case, including source files, code and let us know which Aspose.Diagram API version you are using. We will investigate and share our findings with you.

Thank you for your answer. Of course i can do, that modul became informations about some references, now the modul have to draw this with VISIO 2016. The Informations came over a CSV-File.
This happens in here:

    static List<Felder> getCSV(String csvname, System.Char seperator)
    {
        List<Felder> result = new List<Felder>();
        TxtLoadOptions txtloadoption = new TxtLoadOptions();
        txtloadoption.Separator = seperator;
        txtloadoption.Encoding = System.Text.Encoding.UTF8;
        Workbook workbook = new Workbook(csvname, txtloadoption);
        var worksheet = workbook.Worksheets.First();
        int numCols = 0;
        int numRow = 1;

        while (worksheet.Cells[numRow, 0].Value != null)
        {
            Felder felder = new Felder();
            felder.Inhalt = worksheet.Cells[numRow, numCols].StringValue;
            numCols++;
            Console.WriteLine(felder.Inhalt);
            felder.PosX = worksheet.Cells[numRow, numCols].StringValue;
            numCols++;
            Console.WriteLine(felder.PosX);
            felder.PosY = worksheet.Cells[numRow, numCols].StringValue;
            numCols++;
            felder.Vorgaenger = worksheet.Cells[numRow, numCols].StringValue;
            numCols++;
            felder.Typ = worksheet.Cells[numRow, numCols].StringValue;
            numCols++;
            felder.Farbe = worksheet.Cells[numRow, numCols].StringValue;
            numCols++;
            Console.WriteLine(felder.PosY);
            numCols = 0;
            numRow++;
            result.Add(felder);
        }

        worksheet.Dispose();
        workbook.Dispose();
        
        System.GC.Collect();

        return result;
    }

After that VISIO should Draw the contet in a copy of a definied VISIO file, what happens in here:

            foreach (Felder felderauscsv in felderEigenschaften)
            {
                posX = Double.Parse(felderauscsv.PosX, CultureInfo.InvariantCulture);
                posY = Double.Parse(felderauscsv.PosY, CultureInfo.InvariantCulture);
                felderauscsv.ShapeID = diagram.AddShape(posX, posY, width, height, felderauscsv.Typ, pageIndex);

                setShapeAttribute(felderauscsv.Inhalt, diagram, felderauscsv.ShapeID, 0, "0", felderauscsv.Farbe);
                idName.Add(felderauscsv.Inhalt, felderauscsv.ShapeID);

                if (!String.IsNullOrEmpty(felderauscsv.Vorgaenger))
                {
                    if (idName.ContainsKey(felderauscsv.Vorgaenger))
                    {
                        Console.WriteLine("test");
                        long key = idName[felderauscsv.Vorgaenger];
                        setConnection(diagram, key, felderauscsv.ShapeID);                            
                    }
                }
            }

Untill this moment it works fine, but the page will not fit to the drawn diagram. So the page is bigger, or smaller as the diagram.
visio.zip (1.6 KB)

@dvvde,
Your code is not in fully compilable form because the Felder class is unknown. Kindly share details of the Felder class or simplify the code. Your response is awaited.

Sry for that:

using System;

namespace DependencyDiagramGenerator
{
class Felder
{
public String Inhalt { get; set; }
public String Typ { get; set; }
public String PosX { get; set; }
public String PosY { get; set; }
public String Vorgaenger { get; set; }
public String Farbe { get; set; }
public long ShapeID { get; set; }
}
}

Not all of them used for now.

@dvvde,
We require your source documents Vorlage.vsdx and Testdaten.csv to replicate the problem in our environment. We recommend our clients to share the complete details of the use case.

Thanks for your anwser, now i have solved the problem, but im not lucky with that. My “Vorlage.vsdx” is at size A0, so the programm count the Elements at y and x axis and calculate the max height and max width, so it can set the propertys. It works with other formats fine, but if there any other way to resolve this problem? I guess my solution is not the proper way.
My project is at attachement, hope its complette now.

DependencyDiagramGenerator.zip (23.5 KB)

I have a new probleme here, the Icons of the shapes don’t scale themselfe, but the field does, so how can i resize the icons?

Thanks for your patience.
Size of Icons.png (8.5 KB)

@dvvde,
We could not find the icons in the generated output VSDX drawing as shown in the screenshot. Kindly let us know the shapes which you have added and page scale factor value. We will investigate and share our findings with you.

No problem, its a standart shape from VISIO, so i supposed that you know it.
I have the issues at every 2D and 3D model. The icons inside the shape doesnt fit in automaticly. After the *.vsdx is created, if you now open the data and resize a shape from hand, it skales itself. So i guess i do not “nudge” it.
The problem is with the shapes called, Gruppe, Benutzer and Computer (thats on the picture), they are just to small, the kind of shapes from typ: Rechenzentrum and Stadt are to large to fit.

Vorlage.zip (57.0 KB)

@dvvde,
We have created a Visio drawing with Microsoft Visio application and placed a Computer shape as shown in your screenshot. We have set DrawingScale value at 1.5, and then saved as a VSDX drawing. We changed DrawingScale value with the latest version 17.8 of Aspose.Diagram API and this works fine in our environment.

[C#]

Diagram diagram = new Diagram(@"C:\Diagram\test2188\Input.vsdx");
diagram.Pages[0].PageSheet.PageProps.DrawingScale.Value = 0.5;
diagram.Save(@"C:\Diagram\test2188\Output101.vsdx", SaveFileFormat.VSDX);

These are the input and output drawings: InputVSDX.zip (108.2 KB) and Output17.8_VSDX.zip (97.2 KB). Your project application does not place Gruppe, Benutzer and Computer shapes. If this does not help, then kindly remove additional code steps and simply the use case. We will investigate and share our findings with you.

Thanks for your example, but my problem seems to be antoher one, it is the size, or dimension from the, i guess thats are the 2D and 3D shapemodels. So the “Computer” icon, in the upload, dosent fill the complete pixels of that shape, as you can see in “This is”, but it should fill the entire pinX and pinY size (thats 0.5 and 0.5 for me), as seen in the “This should”. The only way to make this come true is, when you resize the shape in the saved visio file.
Hope this is helpful and makes my problem visible.

isandshould.zip (59.4 KB)

@dvvde,
We have changed the size of shape ID 1 and managed to replicate the said behavior in our environment. It has been logged under the ticket ID DIAGRAMNET-51343 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available updates.

Thank you very much for your help. I am Unfortunately in an advanced training next week. So when i find the time i am working on the project, but after that training on 18.09 i will be back.

@dvvde,
Sure, please take your time and let us know in case of any further assistance.

Thanks the “Computer”, “Benutzer” and “Gruppe” are shown correct. Some other models too, you can close this Ticket.

@dvvde,

Thank you for the confirmation. It is nice to hear from you that the problem has been resolved.

The issues you have found earlier (filed as DIAGRAMNET-51343) have been fixed in Aspose.Diagram for .NET 19.1.