PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 15, 2024 9:27 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Apr 22, 2011 4:57 am 
Offline

Joined: Fri Apr 22, 2011 4:45 am
Posts: 1
Hello,

I have one large image of 1024x3700 (i have attached the sample).
Now i want to convert this image in the PDF having paper size as A4.
I have tried it like below way to implement this

PdfDocument doc = new PdfDocument();
PdfPage pg = new PdfPage();
pg.Size = PageSize.A4;
doc.Pages.Add(pg);
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
XImage img = XImage.FromFile(Server.MapPath("~") + "/" + imagename);
xgr.DrawImage(img, 0, 0);
doc.Save(Server.MapPath("") + "/test.pdf");
doc.Close();

Now as the image height is large it should go to the next page and i am unable to do it. I know that i can specify the y position in "DrawImage" function but for which value should i set it for the second page?

And one more thing, i want to scale the image also to paper width, i dont know what should i have to do for this. Right now above code removes some of the right portion of image.
Any help will be much appreciated.


Attachments:
File comment: sample image
test.png
test.png [ 81.05 KiB | Viewed 3956 times ]
Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 26, 2011 11:44 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3101
Location: Cologne, Germany
When drawing an image, you can specify location and dimension.
Calculate the width to fit the page, then calculate the height keeping the aspect ratio.
You can draw the same image on multiple pages, using different positions. Clipping is not yet implemented.
For pages 2ff, the position will be outside the page in order to show the corresponding "part" of the image.

_________________
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 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