PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Tue Aug 03, 2021 9:02 pm

All times are UTC

Forum rules

Please read this before posting on this forum: Forum Rules

Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Mar 06, 2021 9:05 am 

Joined: Sat Mar 06, 2021 8:36 am
Posts: 2

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.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)

(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;


// Save the document...
//string filename = "Historial.pdf";
string filename = Application.dataPath + "/Historial.pdf";
// ...and start a viewer.

Reply with quote  
PostPosted: Mon Mar 15, 2021 12:47 pm 

Joined: Sat Mar 06, 2021 8:36 am
Posts: 2
I found out that the error appears in the call " renderer.RenderDocument() ".
Any ideas?

Reply with quote  
PostPosted: Wed Jun 23, 2021 5:56 am 

Joined: Sat Jan 09, 2021 7:09 am
Posts: 18
I believed the internal workings of that method calls Win32 APIs which are probably never going to work on a Mac.

Reply with quote  
PostPosted: Wed Jun 23, 2021 10:24 am 
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 655
Location: CCAA
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.

Best regards
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 15 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group