Print portion of image inside Annotation with Margins

Discussions about document printing in GdPicture.NET using GdPictureImaging.
Post Reply
dblwizard
Posts: 1
Joined: Tue Aug 06, 2013 9:09 pm

Print portion of image inside Annotation with Margins

Post by dblwizard » Tue Aug 06, 2013 9:36 pm

Howdy,

I'm building an application that displays an image and then overlays an AnnotationRectangle on the image that the user can drag around the image. Think of this as a "window" on the picture. Once the user gets the "window" where they want it they then print, printing only the portion of the image that is in the window. I also need to control where on the paper the image prints.

I've got code to print the portion of the image partially working but not completely. My calculations must be a little off as the printing starts farther to the right of the original image than the window is sitting.

I can't find anyway to control the starting location of the image on the printer. My guess is I'm going to have to use the .net System.Drawing.Printing.PrintDocument and System.Drawing.Image objects but I don't see how to get an Image object from the GdPicture library.

//_image is class variable of type GdPictureImaging
//_imageID is an int of the current image.
private void btnPrint_Click(object sender, EventArgs e)
{
int left = 0;
int top = 0;
int height = 0;
int width = 0;

GdPictureStatus status = new GdPictureStatus();
float xRes = _image.GetHorizontalResolution(_imageID);
float yRes = _image.GetVerticalResolution(_imageID);

//Annotation Left & Top property are to the center of the Annotation so I'm subtracting
//half of the size of the Annotation.
left = (int)((_highlighter.Left - (_highlighter.Width /2)) * xRes);
top = (int)((_highlighter.Top - (_highlighter.Height /2)) * yRes);
width = (int)(_highlighter.Width * xRes);
height = (int)(_highlighter.Height * yRes);
status = _image.Crop(_imageID, left, top, width, height);

if (status == GdPictureStatus.OK)
{
_image.Print(_imageID);
}
else
{
MessageBox.Show("Error cropping image. Status:" + status.ToString());
}
}

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: Print portion of image inside Annotation with Margins

Post by Gabriela » Mon May 06, 2019 11:49 am

Hello,

Are you still experience such issues with GdPicture14? The toolkit now contains many improved and optimized new features. If you can replicate your issues with the current release (https://www.gdpicture.com/download-gdpicture/), please send us a current code snippet, related documents and show us the issue in more details, so we can assist you further.
Thank you.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest