PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Apr 12, 2021 7:38 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



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

Joined: Sat Mar 06, 2021 8:36 am
Posts: 2
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);
}


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

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


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 16 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