Printing/plotting documents 'AsInDocument'


At my work we have a plotter that supports full colour prints on various paper rolls. We use it for doing A2 and A1 technical drawings and full size paper templates printed at 1:1.

A2 and A1 printing works fine through the API but with whatever variation of properties I try it seems to get some aspect confused. Either the scale or the paper size itself.

I tried it on our HP plotter and a cannon one. 

Printing is clearly a minefield of variation with drivers, hardware and pc setup but I was curious if anyone had made some success on this front? 

There's a few hacks I could try such as editing the DEVMODE, exporting and using a freshly opened application reading the new settings to print but that's a lot of work for something that in theory should be doable through Corels API.

I tried playing around with some code I found online and obvious use of the API (see below). While it generally seems to print to scale it really gets the paper size confused whatever I try.

All insights welcome as ideally I would just press one button a print the template as opposed to setting up a new paper profile every time.


Option Explicit
Sub PrintTemplate2()
ActiveDocument.Unit = cdrMillimeter
ActiveDocument.PrintSettings.Printer.PageSizeMatchingSupported = True
ActiveDocument.PrintSettings.PageMatchingMode = prnPageMatchSizeAndOrientation
ActiveDocument.PrintSettings.PageRange = "1"
ActiveDocument.PrintSettings.Layout.Placement = prnPlaceAsInDocument
'ActiveDocument.PrintSettings.Options.RasterizePage = False
End Sub

Sub PrintTemplate1()
Debug.Print ActiveDocument.PrintSettings.Printer.Name
ActiveDocument.PrintSettings.Printer.PageSizeMatchingSupported = True
ActiveDocument.PrintSettings.Layout.Placement = prnPlaceAsInDocument
ActiveDocument.PrintSettings.PageMatchingMode = prnPageMatchOrientation
Dim Width As Double, Height As Double
Dim Orient As PrnPaperOrientation
Dim dTemp As Double
Width = ActiveDocument.FromUnits(ActivePage.SizeWidth, cdrMillimeter)
Height = ActiveDocument.FromUnits(ActivePage.SizeHeight, cdrMillimeter)
If Width > Height Then
Orient = prnPaperLandscape
dTemp = Width
Width = Height
Height = dTemp
Orient = prnPaperPortrait
End If
ActiveDocument.PrintSettings.SetCustomPaperSize Width, Height, Orient
End Sub