Thansk, I ended up using a solution along the lines of the 2nd example in the PDFPrint sample (http://www.pdftron.com/pdfnet/samplecode/PDFPrint.vb). I had to tell the printer what size paper to use. We then generated the labels so that there was 1 per page in the top-left corner, then cropped the pdf page to the correct size. Sample code:
’ Create objects needed
Dim printDoc As PrintDocument = New PrintDocument
Dim doc As PDFDoc
’ Define label size
Dim width as integer = 4.1
Dim height as integer = 2
SetPaperSize(width, height)
’ PDF’s are generated as 8.5 x 11 pages with 1 label per page in the top left corner
’ Crop the pdf to label size
ResizePDF(width, height)
’ Set paper size used by the printer in inches
Private Sub SetPaperSize(ByVal width As Double, ByVal height As Double)
Dim size As New Drawing.Printing.PaperSize(“Custom Size”, width * 100, height * 100)
printDoc.DefaultPageSettings.PaperSize = size
printDoc.PrinterSettings.DefaultPageSettings.PaperSize = size
End Sub
'Change the size of the pages in the PDF document
Private Sub ResizePDF(ByVal width as Double, ByVal height As Double)
'We only need to change the 1st page as all pages in a pdf have to be the same size
Dim page As Page = myPDFDoc.GetPage(1)
'Label dimensions in inches, converted to pdf units
Dim pdfHeight As Double = height * 72
Dim pdfWidth As Double = width * 72
'Get the box used for printing. Note that location (0, 0) on pdf documents is the bottom left corner.
'We want to create the new media box in the top right corner instead which requires some math
Dim box As Rect = page.GetMediaBox
box.x1 = 0
box.y1 = box.Height - pdfHeight
box.x2 = box.x1 + pdfWidth
box.y2 = box.y2 + pdfHeight
'Apply the conversion. All pages in memory are now the specified size
box.Update()
End Sub
The PrintPage procedure was pretty much identical to what was in the Sample page.