We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problems with save() Method on mac C#

Hello,

My group and I have developed within a study program with a free license a program that should run on Mac and Windows and a partial function is the PDF export.
This also works on Windows, only on mac there is always an error that we could not fix. Now we ask for help. The error picture is below the text. Principal the Save() methode doesnt work on Mac.
We use:
.net core 3.0
avalonia / wpf on C #

I hope someone can help us
thanks in advance

The code:
using System.Collections.Generic;
using Aspose.Pdf;
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Net.Mime;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.ComTypes;
using Aspose.Pdf.Text;
using Aspose.Pdf.Facades;
using DynamicData.Annotations;
using Settings_lib;
using Hotpatch_Toolbox.ViewModels;

namespace Hotpatch_Toolbox.Models
{
public class PDF_Exporter // can only export to pdf, no import | current works only for windows, support is contacted
{
//Function to export PDF
public static void PdfExport(string filename , string projectName,ObservableCollection sortByCicuitCollection, ObservableCollection sortBySpotCollection)
{
#region Variables
ExceptionViewModel exceptionView = new ExceptionViewModel();
Logger exception = Logger.Instance;

        #endregion

        #region HeaderLists
        List<string> CircuitListHeader = new List<string>();
        CircuitListHeader.Add("Plugbox");
        CircuitListHeader.Add("Type");
        CircuitListHeader.Add("#");
        CircuitListHeader.Add("Wattage");
        CircuitListHeader.Add("FixtureID");
        CircuitListHeader.Add("Position");
        CircuitListHeader.Add("Distributor");
        CircuitListHeader.Add("Mistake");

        List<string> SpotListHeader = new List<string>();
        SpotListHeader.Add("FixtureID");
        SpotListHeader.Add("#");
        SpotListHeader.Add("Type");
        SpotListHeader.Add("DMX");
        SpotListHeader.Add("Mode");
        SpotListHeader.Add("Position");
        SpotListHeader.Add("Focus");
        SpotListHeader.Add("Function");
        #endregion
        

        
        try
        {
            #region PDF document variables

            //new Document
            Document doc = new Document();
            PageInfo pageInfo = doc.PageInfo;
            Aspose.Pdf.MarginInfo marginInfo = pageInfo.Margin;

            // page margin
            marginInfo.Left = 37;
            marginInfo.Right = 37;
            marginInfo.Top = 37;
            marginInfo.Bottom = 37;

            pageInfo.IsLandscape = true;

            #endregion
            
            #region Construct

            #region Page SortBySpot

            // Added page for first Table SortByCircuit.
            Page curPage = doc.Pages.Add();
            Aspose.Pdf.Paragraphs paragraphs = curPage.Paragraphs;

            #region Text
            //Page header with project name
            TextFragment name = new TextFragment(projectName);
            
            //Text properties
            name.Position = new Position(330, 535);
            name.TextState.FontSize = 14;
            name.TextState.FontStyle = FontStyles.Bold;


            // Create text fragment
            TextFragment textFragmentHeader = new TextFragment("SortByCircuit: ");
            textFragmentHeader.Position = new Position(37, 495);

            // Set text properties
            textFragmentHeader.TextState.FontSize = 12;
            textFragmentHeader.TextState.FontStyle = FontStyles.Bold;


            // Create TextBuilder object
            TextBuilder textBuilder = new TextBuilder(curPage);

            //Append text to page
            textBuilder.AppendText(name);
            textBuilder.AppendText(textFragmentHeader);
            #endregion

            #region Table


            /********************************************/
            //Creating table SortByCircuit
            Aspose.Pdf.Table sortByCircuitTable = new Aspose.Pdf.Table();
            sortByCircuitTable.ColumnWidths = "50 175 15 50 75 100 100 150";
            sortByCircuitTable.Margin.Top = 70;

            // Set the table border 
            sortByCircuitTable.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .1f,
                Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
            // Set the border for table cells
            sortByCircuitTable.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .1f,
                Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));

            //Table header
            //new row
            Aspose.Pdf.Row rowHeader = new Aspose.Pdf.Row();
            rowHeader.FixedRowHeight = 15;
            sortByCircuitTable.Rows.Add(rowHeader);

            foreach (string header in CircuitListHeader)
            {
                Aspose.Pdf.Cell cellHeader = new Aspose.Pdf.Cell();
                TextFragment headFragment = new TextFragment(header);
                headFragment.Margin.Left = 1;
                cellHeader.BackgroundColor = Color.LightGray;
                cellHeader.Paragraphs.Add(headFragment);
                rowHeader.Cells.Add(cellHeader);
            }

            //Table content
            foreach (Spotlight spotlight in sortByCicuitCollection)
            {
                Aspose.Pdf.Row row = new Aspose.Pdf.Row();
                row.FixedRowHeight = 15;
                sortByCircuitTable.Rows.Add(row);


                Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell();
                TextFragment Plugbox = new TextFragment(spotlight.Breaker_ID);
                Plugbox.Margin.Left = 1;
                cell1.Paragraphs.Add(Plugbox);
                row.Cells.Add(cell1);

                Aspose.Pdf.Cell cell2 = new Aspose.Pdf.Cell();
                TextFragment Type = new TextFragment(spotlight.Inst_Type);
                Type.Margin.Left = 1;
                cell2.Paragraphs.Add(Type);
                row.Cells.Add(cell2);

                Aspose.Pdf.Cell cell3 = new Aspose.Pdf.Cell();
                TextFragment Count = new TextFragment(Convert.ToString(spotlight.Count));
                Count.Margin.Left = 1;
                cell3.Paragraphs.Add(Count);
                row.Cells.Add(cell3);

                Aspose.Pdf.Cell cell4 = new Aspose.Pdf.Cell();
                TextFragment Wattage = new TextFragment(spotlight.Wattage);
                Wattage.Margin.Left = 1;

                cell4.Paragraphs.Add(Wattage);
                row.Cells.Add(cell4);

                Aspose.Pdf.Cell cell5 = new Aspose.Pdf.Cell();
                TextFragment fixtureID = new TextFragment(spotlight.Channel);
                fixtureID.Margin.Left = 1;
                cell5.Paragraphs.Add(fixtureID);
                row.Cells.Add(cell5);

                Aspose.Pdf.Cell cell6 = new Aspose.Pdf.Cell();
                TextFragment Position = new TextFragment(spotlight.Position);
                Position.Margin.Left = 1;
                cell6.Paragraphs.Add(Position);
                row.Cells.Add(cell6);

                Aspose.Pdf.Cell cell7 = new Aspose.Pdf.Cell();
                TextFragment Distributor = new TextFragment(spotlight.User_Field_4);
                Distributor.Margin.Left = 1;
                cell7.Paragraphs.Add(Distributor);
                row.Cells.Add(cell7);

                Aspose.Pdf.Cell cell8 = new Aspose.Pdf.Cell();
                TextFragment Mistake = new TextFragment(spotlight.User_Field_5);
                Mistake.Margin.Left = 1;
                cell8.Paragraphs.Add(Mistake);
                row.Cells.Add(cell8);

            }


            sortByCircuitTable.IsInNewPage = true;

            paragraphs.Add(sortByCircuitTable);

            #endregion

            #endregion

            #region Page SortByCircuit

            

            
            /********************************************/

            //new page for table SortBySpot
            Page curPage2 = doc.Pages.Add();
            Aspose.Pdf.Paragraphs paragraphs2 = curPage2.Paragraphs;

            #region Text

            TextBuilder textBuilder2 = new TextBuilder(curPage2);

            // Create text fragment 
            TextFragment textFragmentHeader2 = new TextFragment("SortBySpot: ");
            textFragmentHeader2.Position = new Position(37, 495);
            // Set text properties
            textFragmentHeader2.TextState.FontSize = 12;
            textFragmentHeader2.TextState.FontStyle = FontStyles.Bold;

            //Page header
            TextFragment name2 = new TextFragment(projectName);
            name2.Position = new Position(330, 535);

            //Text properties
            name2.TextState.FontSize = 14;
            name2.TextState.FontStyle = FontStyles.Bold;

            //Append headers 
            textBuilder2.AppendText(name2);
            textBuilder2.AppendText(textFragmentHeader2);
            #endregion

            #region Table

            /********************************************/
            //new Table sortBySpot
            Aspose.Pdf.Table sortBySpotTable = new Aspose.Pdf.Table();
            sortBySpotTable.Margin.Top = 70;
            sortBySpotTable.ColumnWidths = "100 15 100 50 100 100 100 150";

            // Set the table border 
            sortBySpotTable.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .2f,
                Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
            // Set the border for table cells
            sortBySpotTable.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, .1f,
                Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Black));
            
            
            //sortBySpot header
            Aspose.Pdf.Row rowname2 = new Aspose.Pdf.Row();
            rowname2.FixedRowHeight = 15;
            sortBySpotTable.Rows.Add(rowname2);
            
            foreach (string header in SpotListHeader)
            {
                Aspose.Pdf.Cell cellHeader = new Aspose.Pdf.Cell();
                TextFragment headFragment = new TextFragment(header);
                headFragment.Margin.Left = 1;
                cellHeader.BackgroundColor = Color.LightGray;
                cellHeader.Paragraphs.Add(headFragment);
                rowname2.Cells.Add(cellHeader);
            }

            //Table content
            foreach (Spotlight spotlight in sortBySpotCollection)
            {
                Aspose.Pdf.Row row = new Aspose.Pdf.Row();
                row.FixedRowHeight = 15;
                sortBySpotTable.Rows.Add(row);


                Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell();
                TextFragment fixtureId = new TextFragment(spotlight.Channel);
                fixtureId.Margin.Left = 1;
                cell1.Paragraphs.Add(fixtureId);
                row.Cells.Add(cell1);

                Aspose.Pdf.Cell cell2 = new Aspose.Pdf.Cell();
                TextFragment Count = new TextFragment(Convert.ToString(spotlight.Count));
                Count.Margin.Left = 1;
                cell2.Paragraphs.Add(Count);
                row.Cells.Add(cell2);

                Aspose.Pdf.Cell cell3 = new Aspose.Pdf.Cell();
                TextFragment Type = new TextFragment(Convert.ToString(spotlight.Inst_Type));
                Type.Margin.Left = 1;
                Type.Margin.Top = 1;
                cell3.Paragraphs.Add(Type);
                row.Cells.Add(cell3);

                Aspose.Pdf.Cell cell4 = new Aspose.Pdf.Cell();
                TextFragment DMX = new TextFragment(spotlight.UniverseAddress);
                DMX.Margin.Left = 1;
                cell4.Paragraphs.Add(DMX);
                row.Cells.Add(cell4);

                Aspose.Pdf.Cell cell5 = new Aspose.Pdf.Cell();
                TextFragment Mode = new TextFragment(spotlight.User_Field_1);
                Mode.Margin.Left = 1;
                cell5.Paragraphs.Add(Mode);
                row.Cells.Add(cell5);

                Aspose.Pdf.Cell cell6 = new Aspose.Pdf.Cell();
                TextFragment Position = new TextFragment(spotlight.Position);
                Position.Margin.Left = 1;
                cell6.Paragraphs.Add(Position);
                row.Cells.Add(cell6);

                Aspose.Pdf.Cell cell7 = new Aspose.Pdf.Cell();
                TextFragment Focus = new TextFragment(spotlight.Focus);
                Focus.Margin.Left = 1;
                cell7.Paragraphs.Add(Focus);
                row.Cells.Add(cell7);

                Aspose.Pdf.Cell cell8 = new Aspose.Pdf.Cell();
                TextFragment Function = new TextFragment(spotlight.User_Field_6);
                Function.Margin.Left = 1;
                cell8.Paragraphs.Add(Function);
                row.Cells.Add(cell8);
                
            }

            //  table 1 to next page 
            sortBySpotTable.IsInNewPage = true;
             
            paragraphs2.Add(sortBySpotTable);
            #endregion

            #endregion

            #endregion

            #region Save

            // save document
            using (FileStream saFileStream = File.OpenWrite(filename))
            {
                doc.Save(saFileStream);
            }
            #endregion

        }

        //adding Exception to Logger
        catch (Exception e)
        {
            exception.AddError("Exception occured: " + e.ToString());
            exceptionView.ShowMessage();
        }

    }
}

}
The error: WhatsApp Image 2020-07-07 at 09.24.00.jpeg (202.9 KB)

@Icemen45

Would you please try installing 1. libgdiplus package and 2. package with Microsoft compatible fonts in your MAC environment and then run the program. In case you still face any issue, please let us know.