Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Feb 24, 2015 9:10 am

Hi,

When I use page.canvas.drawimage(image,posX,posY,width, height) into my program, I have an image with a small border.
The image haven't border of course 8)

Is it possible to remove this border?

Thanks to your help,

Philippe

pluka
 
Posts: 5
Joined: Wed Jan 28, 2015 1:08 pm

Tue Feb 24, 2015 9:58 am

Hello pluka,

Thanks for your inquiry.

To help us reproduce this problem, can you provide us your sample image and your code snippets? Thank you.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Tue Feb 24, 2015 11:55 am

This is the code:

PdfImage imgSquare;

//open document
document = new PdfDocument();

page = document.Pages.Add(PdfPageSize.A4, new PdfMargins(0f));

// red rectangle
PdfSolidBrush brush3 = new PdfSolidBrush(Color.FromArgb(255, 227, 37, 38));

RectangleF rect1 = new RectangleF(0, 0, 500, 300);
page.Canvas.DrawRectangle(brush3, rect1);


imgSquare = PdfImage.FromFile(path + @"\YellowSquare.png");

float scaleF = 2f;

// yellow square
float width = imgSquare.Width * scaleF;
float height = imgSquare.Height * scaleF;

page.Canvas.DrawImage(imgSquare, 10, 10, width, height);

page.Canvas.Restore(state);

//save document
document.SaveToFile(@"c:\temp\test.pdf");

//close document
document.Close();

And see the image in attachment

Regards,

Philippe

pluka
 
Posts: 5
Joined: Wed Jan 28, 2015 1:08 pm

Wed Feb 25, 2015 2:15 am

Hello pluka,

Thanks for sharing your code snippets and sample image.

Please try following code to draw the image so that you can get rid of the white border:
Code: Select all
page.Canvas.DrawImage(imgSquare, 0, 0, width, height);
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Fri Feb 27, 2015 11:09 am

Hi,

Thanks for your solution. Its ok now.

Regards,

Philippe

pluka
 
Posts: 5
Joined: Wed Jan 28, 2015 1:08 pm

Sat Feb 28, 2015 1:01 am

Hello pluka,

Please feel free to contact us if you have any questions.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.PDF