PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Sep 06, 2024 11:20 pm

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
 Post subject: image in A4
PostPosted: Mon Jan 13, 2014 3:05 pm 
Offline

Joined: Mon Jan 13, 2014 3:00 pm
Posts: 1
i am using this code to images to pdf

Code:
 static void Main(string[] args)
        {
              DirectoryInfo di = new DirectoryInfo(@"C:\Users\masoodr\Desktop\Pages");
              FileInfo[] files = di.GetFiles();
            string filename = String.Format("{0}_tempfile.pdf", Guid.NewGuid().ToString("D").ToUpper());
            PdfDocument s_document = new PdfDocument();
            //PdfPage p = s_document.AddPage();
            for (int i = 0; i < files.Count(); i++)
            {
                DrawPage(s_document.AddPage(), files[i].FullName);
            }
           

            // Save the s_document...
            s_document.Save(filename);
            // ...and start a viewer
            Process.Start(filename);
        }
        public static void DrawPage(PdfPage page,string fileName)
        {
            XGraphics gfx = XGraphics.FromPdfPage(page);
            XImage image = XImage.FromFile(fileName);
            gfx.DrawImage(image, 0, 0);
           
        }


but for some reason the images are so enlarged they dont fit in. image should fit in as an A4 size rectangle. so what can i do ?


Top
 Profile  
Reply with quote  
 Post subject: Re: image in A4
PostPosted: Mon Jan 13, 2014 3:20 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3109
Location: Cologne, Germany
Hi!

Use DrawImage() with 5 parameters and specify how large the image shall be drawn.

See also:
viewtopic.php?p=7533#p7533

_________________
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: Google [Bot] and 30 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