Rhino.FileIO.FilePdf crashes

Hi @stevebaer,

i am using Rhino.FileIO.FilePdf to write some lines and polylines to a pdf file. This works fine so far, however i need a litle bit more control, eg. exporting beziers, linetypes or gradient fills etc. All this is available in XFinium so i tried to access:

doc = pdf.PdfDocumentImplementation()

on Windows and Mac. The problem is, it only gets me the PdfFixedDocument subclass, but i need to get the parent class. Using below works on Windows to get it:

doc.GetType().BaseType.Assembly.Xfinium

but crashes Rhino 7 for Mac SR14 immediately. It actually crashes using doc.GetType() so i’ve sent in 2 crash reports.

Why do i want to access this ? In order to create a pen (PdfPen) and color (PdfRgbColor) i need to define the full namespace. Can you tell how to get there using PdfDocumentImplementation() ?

(i know how to import using clr.AddReference under Windows, but on Mac the required dll does not exist).

thanks,
c.

Hi @clement,

Can you share a simple way of repeating the crash you are seeing?

Thanks,

– Dale

It would probably be best to figure out exactly what you need and provide these functions in RhinoCommon. I’m very happy with the Xfinium library that we are using, but it would not be good to have your code tied to this library if there ever came a day where we swapped it out for something else.

Hi @dale and @stevebaer, below are 3 examples to make Rhino for Mac SR14 crash. Please open _EditPythonScript and run it from there:

import Rhino
import scriptcontext as sc
import System
import rhinoscriptsyntax as rs

pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
size = System.Drawing.Size(8.5*dpi,11*dpi)
settings = Rhino.Display.ViewCaptureSettings(sc.doc.Views.ActiveView, size, dpi)
settings.OutputColor = Rhino.Display.ViewCaptureSettings.ColorMode.DisplayColor
settings.RasterMode = False
pdf.AddPage(settings)

fixed_doc = pdf.PdfDocumentImplementation()
# this line crashes
print fixed_doc.GetType().BaseType.Assembly.Xfinium

It seems above crashes right after using fixed_doc.GetType() so i’ve tried an alternative eg:

import Rhino
import scriptcontext as sc
import System
import rhinoscriptsyntax as rs
import clr

pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
size = System.Drawing.Size(8.5*dpi,11*dpi)
settings = Rhino.Display.ViewCaptureSettings(sc.doc.Views.ActiveView, size, dpi)
settings.OutputColor = Rhino.Display.ViewCaptureSettings.ColorMode.DisplayColor
settings.RasterMode = False
pdf.AddPage(settings)

fixed_doc = pdf.PdfDocumentImplementation()
# this line crashes too
print clr.GetClrType(type(fixed_doc))

The best crash i had today is actually this one, it seems to run fine at first:

import Rhino
import scriptcontext as sc
import System
import rhinoscriptsyntax as rs

pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
size = System.Drawing.Size(8.5*dpi,11*dpi)
settings = Rhino.Display.ViewCaptureSettings(sc.doc.Views.ActiveView, size, dpi)
settings.OutputColor = Rhino.Display.ViewCaptureSettings.ColorMode.DisplayColor
settings.RasterMode = False
pdf.AddPage(settings)

fixed_doc = pdf.PdfDocumentImplementation()
print fixed_doc

after you’ve run it, try to type this below the last line in the editor:

print type(fixed_doc)

without running it, it crashes exactly after entering the first bracket. I can repeat all 3 examples and sent the last one through the bug reporting dialog. Please let me know if you can repeat it on Mac Rhino 7 SR14. All 3 work fine under Windows.

Thanks ! If you could add equivalents to PdfPen.DashPattern, PdfPen.LineType and DrawBezier it would be a big help. Btw. the reason why i want to write the beziers on my own is that ViewCapture (Rhino 7 Windows) for some reason sometimes outputs polylines even when the input where degree 3 curves. I have not figured out yet why this happens on some curves.

I thought for legacy version, this would not matter and welcome any new additions to do it the regular way using RhinoCommon. There are so many goodies in Xfinium i would like to use…
_
c.

Hi @clement,

I’ve logged this issue so we can keep track of it.

https://mcneel.myjetbrains.com/youtrack/issue/RH-67073

– Dale

1 Like