How do I 'Scale to Fit' the page on paper and how to use Use the Printable Area?

58 views
Skip to first unread message

Support

unread,
Feb 21, 2007, 2:32:05 PM2/21/07
to PDFTron PDFNet SDK
Q: How do I 'Scale to Fit' the page on paper and how to use Use the
Printable Area?

----
A:

You can use PDFNet SDK to print at any scale factor. If you are using
pdfdraw.DrawInRect() method you can provide a smaller rectangle and
PDFNet will print the page inside this region.

If you are developing under .NET you can use
'ev.PageSettings.HardMarginX' and 'ev.PageSettings.HardMarginY' to
adjust the page region in which you want to print.

For example, you could modify 'PDFPrint' sample to take into account
the HardMargin:

' Using VB.NET
Dim rectPage As Rectangle = ev.PageBounds 'print without margins
Dim gr As System.Drawing.Graphics = ev.Graphics gr.PageUnit =
GraphicsUnit.Inch

Dim left As Double = (rectPage.Left - ev.PageSettings.HardMarginX) /
100.0
Dim right As Double = (rectPage.Right - ev.PageSettings.HardMarginX) /
100.0
Dim top As Double = (rectPage.Top - ev.PageSettings.HardMarginY) /
100.0
Dim bottom As Double = (rectPage.Bottom -
ev.PageSettings.HardMarginY) / 100.0
Dim rect As PDFTRON.PDF.Rect = New Rect(left * 72, bottom * 72, right
* 72, top * 72)

Try
pdfDraw.SetDPI(dpi)
page = printItr(PnlActive).Current
pdfDraw.DrawInRect(page, gr, rect)
Catch ex As Exception
MessageBox.Show("Printing Error: " + ex.ToString)
End Try

If you are developing with C/C++ you could use GetDeviceCaps() Win32
function to obtain hard margin and other printer properties.

Reply all
Reply to author
Forward
0 new messages