PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Nov 10, 2024 7:46 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Nov 24, 2018 6:50 pm 
Offline

Joined: Wed Nov 21, 2018 5:48 pm
Posts: 13
How can I add add an image with MigraDoc that is scaled (with aspect ratio) to fit within the margins of the page? Can I add it from a stream, after I manipulate the image myself? I don't want to write it to a file, just to use section.AddImage() with a file name. I believe i saw some "enhanced packages" that uses streams for images, but I'd rather use the "official" release. I have 1.50.4845-RC2a. Nice library by the way.


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 25, 2018 10:22 am 
Offline
PDFsharp Guru
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 1007
Location: CCAA
BrianTheK wrote:
How can I add add an image with MigraDoc that is scaled (with aspect ratio) to fit within the margins of the page?
Do some simple maths, then draw the image with the suitable size. You just have to find whether height or width is the limiting aspect.

BrianTheK wrote:
Can I add it from a stream, after I manipulate the image myself?
You can use files from BASE64-encoded strings, but there is no need to manipulate the image file if you just want to draw an image with a specific size.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Sun Nov 25, 2018 9:38 pm 
Offline

Joined: Wed Nov 21, 2018 5:48 pm
Posts: 13
I found out that Section.AddImage() returns a MigraDoc.DocumentObjectModel.Shapes.Image object and that I can do
Image.LockAspectRatio = true;
Image.Width = 300; // points

To set the size of the image.


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 21 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