is there a way to create an image based from pdf using rectangle?
im using syncfusion pdfviewer(using the Unlimited Flat-Fee License). and this is how i create an image from pdf using c#
private void ScreenCapture(string fileName, int x, int y, int width, int height)
{
try
{
if (x != 0 && y != 0 && width != 0 && height != 0)
{
Rectangle rect = new Rectangle(x, y, width, height);
Bitmap bmp = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(rect.Left, rect.Top, 0, 0, bmp.Size, CopyPixelOperation.SourceCopy);
bmp.Save(fileName, ImageFormat.Jpeg);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
MessageBox.Show(ex.StackTrace);
}
finally
{
}
}
and this is my additional code
on declaration
Point startPoint;
on mouse down
Control control = (Control)sender;
startPoint = control.PointToScreen(new Point(e.X, e.Y));
on my mouse up
Point endPoint = ((Control)sender).PointToScreen(new Point(e.X, e.Y));
int width = endPoint.X - startPoint.X;
int height = endPoint.Y - startPoint.Y;
theRectangle = new Rectangle(startPoint.X ,
startPoint.Y, width, height );
the problem with my code is im capturing my screen. so when i resized my program. it will capture the screen and will result to wrong image
so is there a way to get or convert the pdf page that has a rectangle into image using c#? thank you
update:
im sorry if my question is not clear.
example. i draw a rectangle to the pdf using pdfviewer of syncfusion
the output will be something like this
https://drive.google.com/open?id=0B45rDxvaXzsmcTZIVVVSUU9Zc0E
https://drive.google.com/open?id=0B45rDxvaXzsmc1cxNTV4UUdOMUE
https://drive.google.com/open?id=0B45rDxvaXzsmSWtDRWhXYkpDT2c
https://drive.google.com/open?id=0B45rDxvaXzsmS214WmJnN3BvcUk
im verry sorry if my question is not clear
See Question&Answers more detail:os