Free Support Forum - aspose.com

Trial not creating or manipluating items

I am trying to get your diagram solution to work but every example I try it fails to do the manipulation.

code

string dataDir = @“c:\temp”;

        // Create directory if it is not already present.
        //bool IsExists = System.IO.Directory.Exists(dataDir);
        //if (!IsExists)
        //    System.IO.Directory.CreateDirectory(dataDir);
        // Initialize a new Visio
        //Diagram diagram = new Diagram();
        Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");


        // Add page number at the right corner of header
        diagram.HeaderFooter.HeaderRight = "&p";

        // Set text at the center
        diagram.HeaderFooter.HeaderCenter = "Center of the header";

        // Set text at the left side
        diagram.HeaderFooter.HeaderLeft = "Left of the header";

        // Add text at the right corner of footer
        diagram.HeaderFooter.FooterRight = "Right of the footer";

        // Set text at the center
        diagram.HeaderFooter.FooterCenter = "Center of the footer";

        // Set text at the left side
        diagram.HeaderFooter.FooterLeft = "Left of the footer";

        // Set header & footer color
        diagram.HeaderFooter.HeaderFooterColor = Color.AliceBlue;

        // Set text font properties
        diagram.HeaderFooter.HeaderFooterFont.Italic = BOOL.True;
        diagram.HeaderFooter.HeaderFooterFont.Underline = BOOL.False;

        // Save Visio diagram
        diagram.Save(dataDir + "ManageHeadersandFooters_out.vsdx", SaveFileFormat.VSDX);


        Page myPage = new Page();

        string masterName = "Firewall"; // "Rectangle";
        string sStencil = @"C:\Temp\s_symbols_Concepts_2014.vss";

        if (true)
        {
            sStencil = @"C:\Temp\Basic Shapes.vss";
             masterName = "Rectangle";
        }
        else
        {
            sStencil = @"C:\Temp\s_symbols_Concepts_2014.vss";
            masterName = "Firewall";
        }
        

        // /* dataDir +*/ "Basic Shapes.vss";
         

        // Add master with stencil file path and master name
        
        //diagram.AddMaster(sStencil, masterName);
        diagram.AddMaster(sStencil, masterName);

        int PageIndex = diagram.Pages.Add(myPage);
        // diagram.Pages.

        Page myPage2 = new Page();
        myPage2.Name = "pete-Page2";
        diagram.Pages.Add(myPage2);


        // Page indexing starts from 0
        // int PageIndex = 1;
        double width = 2, height = 2, pinX = 4.25, pinY = 4.5;
        // Add a new rectangle shape
        long rectangleId = diagram.AddShape(pinX, pinY, width, height, masterName, PageIndex);

        // Set shape properties 
        Shape rectangle = myPage.Shapes.GetShape(rectangleId);
        rectangle.XForm.PinX.Value = 5;
        rectangle.XForm.PinY.Value = 5;
        rectangle.Type = TypeValue.Shape;
        rectangle.Text.Value.Add(new Txt("Aspose Diagram"));
        rectangle.TextStyle = diagram.StyleSheets[3];
        rectangle.Line.LineColor.Value = "#ff0000";
        rectangle.Line.LineWeight.Value = 0.03;
        rectangle.Line.Rounding.Value = 0.1;
        rectangle.Fill.FillBkgnd.Value = "#ff00ff";
        rectangle.Fill.FillForegnd.Value = "#ebf8df";


        /* refreshes shape's position, including XForm, TextXForm, connection and geom data
            when changing the shape's text and other's*/
        rectangle.RefreshData();
        











        string fileName   = string.Format("VisioDoc_{0}.vsdx", DateTime.UtcNow);


        MemoryStream ms = new MemoryStream();

        diagram.Save(ms, SaveFileFormat.VSDX);
        return File(ms.ToArray(), "application/vnd.vsdx", fileName);

ManageHeadersandFooters_out.zip (12.3 KB)

@peterm44,

Aspose.Diagram API has limitations to not add more than 10 shapes with the evaluation version. You need to apply a license to Aspose.Diagram for .NET API. You can get a 30 day temporary license from the purchase portal and its option is available in step 5. You will see a button with caption Get a Temp License in step 5 of the purchase portal. A temporary license is a time-restricted full license that lets you test every aspect of API before buying it. Please refer to these help topics: Apply License to Aspose.Diagram for .NET API

Hi Imran
I have a trial licence and it has removed the message but still no luck in getting a diagram created.
Is there an example download?
Peter

@peterm4,

You can download and try the demo application project in your environment, and let us know in case of any more assistance. You may send us an expected drawing, we will help you to build the same drawing. Download: GitHub Project of Aspose.Diagram for .NET API