Batch Printing: Background Color Layout?

Hello there!

I am trying to batch print quite a few .3dm files. Each one has a different background color for the layout, and what I would like to achieve is simply to print the layout integrating the appropiate background-color.
Now, I have a small script (provided by @lando.schumpich) which is able to print layouts without passing through the pop-up printing settings.
I have tried to use "Rhino.Display.ViewCaptureSettings.DrawBackground " but I do not really know how to integrate it into the settings of pdf.AddPage.
Could anyone give me a hint? Thank you in advance!

Here’s the code:

def createSinglePDF(view):
pdf = Rhino.FileIO.FilePdf.Create()
dpi = 300
settings = Rhino.Display.ViewCaptureSettings(view, dpi)
pdf.AddPage(settings)
filename = ‘{0}{1}.pdf’.format(sPath, nameProject)
pdf.Write(filename)

EDIT: just to be clear about the problem. Here’s my workspace:

And here’s the “wrong” output not considering the background color:

Hello @andrea.settimi,
You should be able to just set the DrawBackground on your ViewCaptureSettings instance, before adding pages to your pdf https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_Display_ViewCaptureSettings_DrawBackground.htm:

dpi = 300
settings = Rhino.Display.ViewCaptureSettings(view, dpi)
settings.DrawBackground = True
pdf.AddPage(settings)

Hello, thank you for your reply. Unfortunately this is what I’ve first tried and it doesn’t work. It seems to always neglect the background color boolean.

Hmmm looking at this I see, it also does not work manually (with the _Print Dialog)

Looks like this when printed:

So I think your best bet for now would be putting a solid hatch in your background color of choice behind your drawing.

Looks like a bug to me though… @stevebaer

I will try with the solid hatch behind for now then. However I have to say that if I print manualy it does work for me (by thicking the Background color case just as you did).

I added this to our bug tracking system at
https://mcneel.myjetbrains.com/youtrack/issue/RH-55672