| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Sharpen the PDF document https://forum.pdfsharp.net/viewtopic.php?f=2&t=2506 |
Page 1 of 1 |
| Author: | tuviar [ Mon Jul 08, 2013 1:48 pm ] |
| Post subject: | Sharpen the PDF document |
Hi, I am using the PDFSharp library to create PDF file from WinForm .net application. I try to caputre the form with the following code: Code: private static void createPdf() { PdfDocument document = new PdfDocument(); PdfPage page = initPage(document); XGraphics gfx = XGraphics.FromPdfPage(page); XImage image = initImage(); gfx.DrawImage(image, 0, 0, page.Width, page.Height); string fileName = "z.pdf"; document.Save(fileName); Process.Start(fileName); } private static PdfPage initPage(PdfDocument document) { PdfPage page = document.AddPage(); page.Width = XUnit.FromMillimeter(m_Form.Width); page.Height = XUnit.FromMillimeter(m_Form.Height); return page; } private static XImage initImage() { BitmapImage screenCaptureInBitmapImage = getScreenCaptureInBitmapImage(); XImage image = XImage.FromBitmapSource(screenCaptureInBitmapImage); return image; } private static BitmapImage getScreenCaptureInBitmapImage() { Bitmap screenCapture = copyFormScreenToClipboard(); BitmapImage screenCaptureInBitmapImage = new BitmapImage(); screenCapture.SetResolution(96.0F*2, 96.0F*2); using (MemoryStream memStream2 = new MemoryStream()) { screenCapture.Save(memStream2, System.Drawing.Imaging.ImageFormat.Bmp); memStream2.Position = 0; screenCaptureInBitmapImage.BeginInit(); screenCaptureInBitmapImage.CacheOption = BitmapCacheOption.OnLoad; screenCaptureInBitmapImage.UriSource = null; screenCaptureInBitmapImage.StreamSource = memStream2; screenCaptureInBitmapImage.EndInit(); } return screenCaptureInBitmapImage; } The issue is that the image captured in the function of getScreenCaptureInBitmapImage is blurred. i tried to change the DPI value in the function of screenCapture.SetResolution(96.0F*2, 96.0F*2); but it didnt help me . Does someone has any advise? Thanks - Tuvia |
|
| Author: | Thomas Hoevel [ Mon Jul 08, 2013 2:37 pm ] |
| Post subject: | Re: Sharpen the PDF document |
Hi! If the blurriness comes from Adobe Reader's image optimization, then you may be able to turn that off by using "image.Interpolate = false;" See also: viewtopic.php?p=2679#p2679 96 DPI is a low resolution for images in PDF files. Have you tried 300 DPI? A screen capture will never be as sharp as a text added to a PDF. It's double work, but for best results re-create that form for PDF using MigraDoc. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|