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); }
|