vb.net - printing scrollable panel with image inside in vb -
good day everyone. have problem in printing image in scrollable panel. can me this?
i wanted resize images first (so can fit 8.5 11" paper) before showing in print preview printing
in case, have form(form1) panel (dock=fill) , wanted print images (2 images) inside it. but, trigger of printing of image in next form
in btnnext(form1) form2.show() me.hide()
and printing code in form2. new in vb , don't have idea printing scrollable panel. tried different codes in other forums didn't print whole image screenshot of form. response appreciated., thank much
public class form2 private withevents pd new printing.printdocument private sub printdocument1_printpage(byval sender system.object, byval e system.drawing.printing.printpageeventargs) handles printdocument1.printpage using bmp new bitmap(form1.pb1.width, form1.pb1.height) form1.panel1.drawtobitmap(bmp, new rectangle(0, 0, form1.pb1.width, form1.pb1.height)) e.graphics.drawimage(bmp, e.marginbounds) end using end sub private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click printdocument1.print() end sub end class
- ^it prints can see in screen. not whole panel..
basically, keep same, instead of printing whole first image on whole page, , print second image ratio of location , size relative marginbounds
private sub printdocument1_printpage(byval sender system.object, byval e system.drawing.printing.printpageeventargs) handles printdocument1.printpage using bmp new bitmap(form1.pb1.width, form1.pb1.height) form1.pb1.drawtobitmap(bmp, new rectangle(0, 0, form1.pb1.width, form1.pb1.height)) 'print pb1 fill whole page e.graphics.drawimage(bmp, e.marginbounds) end using using bmp2 new bitmap(form1.pb2.width, form1.pb2.height) form1.pb2.drawtobitmap(bmp2, new rectangle(0, 0, form1.pb2.width, form1.pb2.height)) dim x double = form1.pb2.location.x - form1.pb1.location.x x = x * e.marginbounds.width / form1.pb1.width x = x + e.marginbounds.x dim y double = form1.pb2.location.y - form1.pb1.location.y y = y * e.marginbounds.height / form1.pb1.height y = y + e.marginbounds.y dim width double = form1.pb2.width width = width * e.marginbounds.width / form1.pb1.width dim height double = form1.pb2.height height = height * e.marginbounds.height / form1.pb1.height e.graphics.drawimage(bmp2, new rectangle(x, y, width, height)) end using end sub
Comments
Post a Comment