Harshil_Patel_5326c0

I have placed many objects into the form ,like circle, square, images, etc etc directly on the forms background.

Now i want to know how to take printout of them directly into printer or PDF in particular



Re: Visual Basic Language Print graphics that are on the form into PDF

Joshua Morgan

Here is what I think you are looking for:

http://www.knowdotnet.com/articles/printform.html






Re: Visual Basic Language Print graphics that are on the form into PDF

ShadowMan

Thanks a lot m8.Its enough fo me to get started. I actually wanted to only print Drawing objects like cireles, etc etc that are on the forms, and not the controls :P but i guess that i can do it by creating the drawing on a different form.






Re: Visual Basic Language Print graphics that are on the form into PDF

SJWhiteley

No, you don't need to. You can simply draw your circles (etc.) on the printDocument graphics object instead of the form itself. You have full control over what gets printed and where.

You can encapsulate your drawing code in a routine which you can call from the PaintEvent for the form (passing the Forms graphics object), or from the PrintPage event (passing the page Graphics object). You may want to pass a boolean parameter also, indicating that the target graphics object is the printer or a form, so you know what you are drawing to. This eliminates duplication of code.






Re: Visual Basic Language Print graphics that are on the form into PDF

ShadowMan

Hey bro, but i want to change the properties of the objects that i put on the form.

Like put many circles on the form, and then i want to BUCKET fill each circles withdifferent colors... inshort a small MSPAINT type of APP. But i want to keep those circles as objects so that i can drag and drop them, select them, apply some different properties, like rotate, etcetc, so i will need those objects to be on the form first i guess..

there can be many objects on the form, it should fit on a PDF file of a page size of a4, so i donknow how to zoom-in or zoom out the contents of the drawing page into the pdf, using that print duocument....





Re: Visual Basic Language Print graphics that are on the form into PDF

SJWhiteley

I don't see how that changes things. They don't need to exist on the form to print them. Are you using the paint event to draw these objects How are you drawing them




Re: Visual Basic Language Print graphics that are on the form into PDF

ShadowMan

I am drawing those objects dynamically on the form from the mouse, like a mspaint application..




Re: Visual Basic Language Print graphics that are on the form into PDF

SJWhiteley

When I say, 'how', I mean how are you coding it Specifically, you are doing all your drawing in the paint event, aren't you






Re: Visual Basic Language Print graphics that are on the form into PDF

ShadowMan

I am drawing the objects in the mouse events, like mouseDown, MouseDown, etc etc through coding.
and not in the paint event.






Re: Visual Basic Language Print graphics that are on the form into PDF

SJWhiteley

Ah, I see. What happens when you minimize the form, and restore it How are you redrawing all the graphics

Ordinarily, you would perform all drawing in the Paint event for the control. Doing it any other way causes headaches. When your mouse darg has been completed, you can invalidate a specific region of the form, to cause that region to be redrawn in the paint event. You can keep all your drawing code in one place.






Re: Visual Basic Language Print graphics that are on the form into PDF

ShadowMan

I am a new learner to these things, so what i have figured out is due to the missing autoredraw property in .net, i am drawing the things to the bitmap, and in paint event, putting that bitmap onto the form. I cant put the drawing code in the paint event, cause i will be drawing the graphics items on the form dynamically in runtime. when i draw on the form, it will getinto the bitmap, which will be repainted by the Paint event on invalidateRect ..

i hope you understand now.... i am too bad in explaining things. may be that is creating trouble for you to understand. I am newbie, ill get going well.. with all the positive and kind support from you m8ts.