Predefined filename and location with RhinoPDF

Hi

It try to script in python a PDF output from the current view to a predefined map and file name but I doesn’t get to the result I like.

import rhinoscriptsyntax as rs

def PrintCurrentView():
doc=rs.DocumentName()

printer='RhinoPDF'
dir="C:\\pdf_output\\"
Name='test.pdf'

cmd='-_Print Setup Margins TopMargin=5 BottomMargin=5 LeftMargin=5 RightMargin=5 _Enter '
 
cmd+='Destination '
cmd+='OutputColor PrintColor '
cmd+='Pagesize 297.0 210.0 '
cmd+='OutputType=Raster _Enter '
cmd+='View ViewportArea=Viewport _Enter '
cmd+='Visibility Footer '+doc+' _Enter '
#cmd+="_Enter _GO "+dir+Name+' '
cmd+='_Enter Preview '
rs.Command(cmd)
return

if name==“main”:
PrintCurrentView()

I like to use the Commented row to predefine the file location and name but it doesn’t work.

Or is the another way to print the current view as and PDF to a predefined map and name?

Hello - take a look here:

There is an example script in that thread as well.

-Pascal

Hi Pascal

It tried this option but where can i change the display settings to raster format.

The pdf is in vector format but i like to have the view capture in raster format. (for the shade display mode)

Is there also an option available to print a header or footer or do I have to script the text to my view camera plane and show it ? (or should i have to create a layout page to show the result)

Below the script I used.

import Rhino
import scriptcontext as sc
import System.Drawing
#import rhinoscriptsyntax as rs

def createSinglePDF(view):
    pdf = Rhino.FileIO.FilePdf.Create()
    dpi = 300
    size = System.Drawing.Size(11*dpi,8.5*dpi)
    
    settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
    pdf.AddPage(settings)
    filename = 'c:/pdf_output/'+'ViewCaprture'+'.pdf'
    pdf.Write(filename)

Views=sc.doc.Views
v=sc.doc.Views.ActiveView
createSinglePDF(v)
Hi,

I try to get the pdf working but I struggle with the pdf.DrawBitmap row.
I got and reply message: Index was out of range.

How can I fix this?

import Rhino
import scriptcontext as sc
import System.Drawing

def createSinglePDF(view):
    
    pdf = Rhino.FileIO.FilePdf.Create()
    dpi = 300
    size = System.Drawing.Size(11*dpi,8.5*dpi)
    settings = Rhino.Display.ViewCaptureSettings(view, size, dpi)
    settings.OutputColor = Rhino.Display.ViewCaptureSettings.ColorMode.DisplayColor
    capture = Rhino.Display.ViewCapture.CaptureToBitmap(settings)
    pdf.AddPage(settings)
    pdf.DrawBitmap(0, capture, 0, 0, 11*dpi, 8.5*dpi, 0)

    filename = 'c:/pdf_output/'+'ViewCapture'+'.pdf'
    pdf.Write(filename)

if __name__=="__main__":
    Views=sc.doc.Views
    v=sc.doc.Views.ActiveView
    createSinglePDF(v)