PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Apr 26, 2024 1:20 am

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: Fri Mar 11, 2016 7:32 pm 
Offline

Joined: Fri Mar 11, 2016 7:24 pm
Posts: 2
Hello,
I'm trying to split my pdf page and convert each page into an image. However I only get a black empty image every time. Below is the code I was trying out.
Code:
            PdfDocument inputDocument = PdfReader.Open(filename, PdfDocumentOpenMode.Modify);
            var page = inputDocument.Pages[0];
            XGraphics gfx = XGraphics.FromPdfPage(page, XGraphicsPdfPageOptions.Replace);
            //var state = gfx.Save();
            //gfx.Restore(state);

            Image image = new Bitmap((int)gfx.Graphics.VisibleClipBounds.Width, (int)gfx.Graphics.VisibleClipBounds.Height, gfx.Graphics);
            image.Save("image.jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);

The commented 2 lines, I was not sure if I needed it. Any suggestions on how I can get this working would be great.
Thanks and appreciate a quick response.


Top
 Profile  
Reply with quote  
PostPosted: Sat Mar 12, 2016 8:20 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 916
Location: CCAA
Hi!
puvi044 wrote:
Thanks and appreciate a quick response.
A link to a quick answer from 2010:
http://stackoverflow.com/a/3015623/1015447

Reading the manual for "new Bitmap" would have led to an even quicker self-answer. :wink:

Save and Restore do not make any difference here.

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


Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 14, 2016 5:21 am 
Offline

Joined: Fri Mar 11, 2016 7:24 pm
Posts: 2
Thanks for the response, is there another software that I can use in tandem with PDFSharp so that I can split the document using PDFSharp, and use the other software to convert it to an 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: Bing [Bot] and 302 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