PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Wed Dec 17, 2025 6:43 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Oct 21, 2012 4:56 pm 
Offline

Joined: Wed Jun 06, 2012 5:48 pm
Posts: 7
Hi

Say, my image width = 100 and height=500
I would like to draw the image in a rectangle where rectangle width = 100 but height = 300
if I use gfx.DrawImage(image, 0, 0, 100, 300); image is stretch in height.
So, Is there any way to crop the image of 100x500 by 100x300?

I have tried by below

XImage img = XImage.FromFile(imgPath);
XRect xSrcRect = new XRect(0,0, 100, 500);
XRect xCropRect = new XRect(0, 0, 100, 300);
gfx.DrawImage(img, xSrcRect, xCropRect, XGraphicsUnit.Point);

But no luck

Thanks
Shahdat


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 22, 2012 7:59 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3139
Location: Cologne, Germany
Hi!
PDFsharp does not currently crop images.
Please create a new memory bitmap (100x300 for your example) and copy the area you want to show.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 321 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group