I print shortcuts through a Dymo printer using vb.Net and standard .NET printing programs, but my application must support any type of label printer. Since the dymo driver has no fields available on the control panel, and the control panel is limited for most of my users, I set the page fields using the application.
I am replacing the fields in PrintDocument using those installed in the application, and this is normal, but I also have code to calculate the size and format of the text depending on the width of the print area. Can I never get the printable area for resizing? Do all the field settings by shunting the entire graphic down and to the right based on the top and left margins, the print area and VisibleClipBounds in the graphic never change? When this happens, the text simply flows to the right and bottom of the page, so it never obeys the right and bottom margins.
Is this normal behavior? Do I need to do more processing in the application to calculate the printable area based on my margins and the initial page size?
'Code to setup PrintDocument MyDocument.DefaultPageSettings.Margins = New Margins(Printers.LabelPrinter.MarginLeft / 0.254, Printers.LabelPrinter.MarginRight / 0.254, Printers.LabelPrinter.MarginTop / 0.254, Printers.LabelPrinter.MarginBottom / 0.254) MyDocument.OriginAtMargins = True 'Code that runs during the MyDocument.Print event width = e.Graphics.VisibleClipBounds.Width height = e.Graphics.VisibleClipBounds.Height 'Calculate best fit text size here and update graphics object
I decided. My routine just used a graphic object, not the full eventargs for the Print event.
The print event contains the MarginBounds property, which returns the size rectangle after the fields have been applied, and therefore works fine.
source share