PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Works on windows doesn't work on MAC os X
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4241
Page 1 of 1

Author:  osuna.jm [ Sat Mar 06, 2021 9:05 am ]
Post subject:  Works on windows doesn't work on MAC os X

HI,

My program developed in C #, using the unity platform, generates an document in pdf and saves it.
The executable for windows works perfectly. The executable for MAC OS X doesn't work.
It is a simple code. I don't know if it's a file permission problem, or is there something special to do for Mac OS.
thanks for your help.

1. Error:
NullReferenceException: Object reference not set to an instance of an object
at PdfSharp.Pdf.PdfPage.Initialize () [0x00000] in <filename unknown>:0
at PdfSharp.Pdf.PdfPage..ctor () [0x00000] in <filename unknown>:0
at PdfSharp.Pdf.PdfPages.Add () [0x00000] in <filename unknown>:0
at PdfSharp.Pdf.PdfDocument.AddPage () [0x00000] in <filename unknown>:0
at PdfSharp.Drawing.XGraphics.CreateMeasureContext (XSize size, XGraphicsUnit pageUnit, XPageDirection pageDirection) [0x00000] in <filename unknown>:0
at MigraDoc.Rendering.DocumentRenderer.PrepareDocument () [0x00000] in <filename unknown>:0
at MigraDoc.Rendering.PdfDocumentRenderer.PrepareDocumentRenderer (Boolean prepareCompletely) [0x00000] in <filename unknown>:0
at MigraDoc.Rendering.PdfDocumentRenderer.PrepareRenderPages () [0x00000] in <filename unknown>:0
at MigraDoc.Rendering.PdfDocumentRenderer.RenderDocument () [0x00000] in <filename unknown>:0
at Pdf.CrearHistorial (System.Data.DataTable tablaFormato) [0x00000] in <filename unknown>:0
at GestorPapiro.Imprimir () [0x00000] in <filename unknown>:0
at UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) [0x00000] in <filename unknown>:0
at UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0
at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <filename unknown>:0
at UnityEngine.UI.Button.Press () [0x00000] in <filename unknown>:0
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <filename unknown>:0
at UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) [0x00000] in <filename unknown>:0
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMousePress(MouseButtonEventData)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent(Int32)
UnityEngine.EventSystems.StandaloneInputModule:ProcessMouseEvent()
UnityEngine.EventSystems.StandaloneInputModule:Process()
UnityEngine.EventSystems.EventSystem:Update()

(Filename: Line: -1)

2. Code:

public void CrearHistorial(DataTable tablaFormato)
{
// Create a MigraDoc document
Papiro _papiro = GameObject.Find("MenuInicio2").GetComponent<Papiro>();
Document document = _papiro.CreateHistorial(tablaFormato);

//string ddl = MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToString(document);
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, "MigraDoc.mdddl");

PdfDocumentRenderer renderer = new PdfDocumentRenderer(true, PdfFontEmbedding.Always);

renderer.Document = document;

renderer.RenderDocument();

// Save the document...
//string filename = "Historial.pdf";
string filename = Application.dataPath + "/Historial.pdf";
renderer.PdfDocument.Save(filename);
// ...and start a viewer.
Process.Start(filename);
}

Author:  osuna.jm [ Mon Mar 15, 2021 12:47 pm ]
Post subject:  Re: Works on windows doesn't work on MAC os X

I found out that the error appears in the call " renderer.RenderDocument() ".
Any ideas?

Author:  rsoeung [ Wed Jun 23, 2021 5:56 am ]
Post subject:  Re: Works on windows doesn't work on MAC os X

I believed the internal workings of that method calls Win32 APIs which are probably never going to work on a Mac.

Author:  TH-Soft [ Wed Jun 23, 2021 10:24 am ]
Post subject:  Re: Works on windows doesn't work on MAC os X

rsoeung wrote:
I believed the internal workings of that method calls Win32 APIs which are probably never going to work on a Mac.
There is no ETA for a PDFsharp version that works with .NET Core or .NET 5. The current internal build still has many limitations, but support for Linux and Mac will come one day.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/