PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
PDF Page to image https://forum.pdfsharp.net/viewtopic.php?f=2&t=1716 |
Page 1 of 1 |
Author: | Ghost20 [ Sat Jul 09, 2011 11:35 am ] |
Post subject: | PDF Page to image |
Hello. how to save the pdf page to image? I have this code Code: using PdfSharp;
using PdfSharp.Pdf; using PdfSharp.Pdf.IO; using PdfSharp.Drawing; using PdfSharp.Drawing.Pdf; using MigraDoc.Rendering; ............... PdfDocument pdfDocument = PdfReader.Open(pdfDocName); int dpi = 150; int width = (int)pdfDocument.Pages[0].Width.Inch * dpi; int height = (int)pdfDocument.Pages[0].Height.Inch * dpi; MigraDoc.DocumentObjectModel.Document document = new MigraDoc.DocumentObjectModel.Document(); document.AddSection(); MigraDoc.Rendering.DocumentRenderer documentRenderer = new DocumentRenderer(document); MigraDoc.Rendering.PdfDocumentRenderer pdfDocumentRender = new PdfDocumentRenderer(); pdfDocumentRender.PdfDocument = pdfDocument; pdfDocumentRender.DocumentRenderer = documentRenderer; Image image = new Bitmap(width, height); Graphics graphics = Graphics.FromImage(image); XGraphics xGraphics = XGraphics.FromGraphics(graphics, new XSize(width, height)); documentRenderer.RenderPage(xGraphics, 0);//in this line error image.Save("1.png", ImageFormat.Png); pdfDocument.Close(); |
Author: | Ghost20 [ Sat Jul 09, 2011 9:53 pm ] |
Post subject: | Re: PDF Page to image |
I modurator from Russian forum, and will never admit topic without an answer. Probably a bad forum. Moderators will remove, but those who see will understand. |
Author: | () => true [ Sun Jul 10, 2011 7:08 am ] |
Post subject: | Re: PDF Page to image |
Ghost20 wrote: I modurator from Russian forum, and will never admit topic without an answer. Probably a bad forum. Moderators will remove, but those who see will understand. Well, if you ask questions on a Saturday morning be prepared to wait till Monday to get answers. Provide all relevant information with your question or you'll get questions in return. See here: viewtopic.php?f=2&t=832 "in this line error" doesn't help me. I'd have to create a project with your source code to get the exact error message. Why don't you include the exact error message in your post (outside the source code)? PDFsharp wasn't designed to create images and AFAIK you attempt something that cannot be done with PDFsharp. The FAQ tell you to "invoke GhostScript to create images from PDF pages". |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |