| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| [MigraDoc] AddImage is rendering bad quality https://forum.pdfsharp.net/viewtopic.php?f=2&t=2486 |
Page 1 of 1 |
| Author: | FEN [ Tue Jun 18, 2013 9:48 am ] | |||
| Post subject: | [MigraDoc] AddImage is rendering bad quality | |||
Hi, i'm using MigraDoc to generate Product data sheets as PDF. When i add an Image with paragraph.AddImage(Stream stream), this returns an Image with massive jpeg artefacts. I'm using neither rescaling nor resizing. Is this function AddImage modifying the stream before adding to image, and if so, is there any way to set / change the quality? Searching for any threads solving my issue returned with no result. Thanks in advance, FEN (width, height and stream are properties of the image object) Code: Row rowImage = table.AddRow(); rowImage.Height = XUnit.FromCentimeter(9.6).Point; Paragraph paragraphImage = new Paragraph(); Image img = paragraphImage.AddImage(stream); if (img != null) { img.Width = width; //px img.Height = height; //px } rowImage[0].Add(paragraphImage); Original picture and screenshot of the generated PDF are attached. (Why it is not allowed to attach pdf documents?)
|
||||
| Author: | Thomas Hoevel [ Tue Jun 18, 2013 11:27 am ] |
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality |
Hi! FEN wrote: Is this function AddImage modifying the stream before adding to image, and if so, is there any way to set / change the quality? MigraDoc stores all images in the PDF file as they are.What you see is the quality of your image, but scaled by 3x or 4x or so - and smoothed by Adobe Reader. A 20 kiB JPEG will never look good when viewed full screen. You can try "image.Interpolate = false;" for the image to disable smoothing by Adobe Reader. See also: viewtopic.php?p=2471#p2471 |
|
| Author: | FEN [ Wed Jun 19, 2013 3:24 pm ] | ||
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality | ||
Hi Thomas, i attached another screenshot with a view of the original picture size on website and pdf. As you can see, the quality of the image in pdf is worse than the image on website, because of jpeg artefacts. I wonder about the artefacts, because you said, MigraDoc stores all images in the PDF files as they are.
|
|||
| Author: | Thomas Hoevel [ Wed Jun 19, 2013 3:35 pm ] |
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality |
Hi! FEN wrote: When i add an Image with paragraph.AddImage(Stream stream), this returns an Image with massive jpeg artefacts. The original MigraDoc only allows adding images from a filename, not from a stream.You are using a modified version of MigraDoc. Images from a stream may be recompressed - and the dithered images lead to massive artefacts. |
|
| Author: | Thomas Hoevel [ Thu Jun 20, 2013 1:09 pm ] |
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality |
FEN wrote: When i add an Image with paragraph.AddImage(Stream stream), this returns an Image with massive jpeg artefacts. To avoid recompression the implementation of "paragraph.AddImage(Stream stream)" must store the stream internally in order to have the original JPEG data copied to the PDF.Or simply save the stream to a temporary file and pass the filename to AddImage. |
|
| Author: | FEN [ Fri Jun 21, 2013 8:13 am ] |
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality |
Hi Thomas, thanks for your helpful answer. |
|
| Author: | G Fichter [ Wed Sep 18, 2013 3:17 pm ] |
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality |
Hi Thomas, Could you explain further "Images from a stream may be recompressed"? Like the original poster, I want to use a Stream input for an image, but Migradoc doesn't allow this. I could use a temp file, but it is an extra step since my graphic is created and painted in the application. I would like to understand why Migradoc is written without AddImage(Stream stream), and what the risk is for me to add an extension. Thank you, Greg |
|
| Author: | Thomas Hoevel [ Wed Sep 18, 2013 3:54 pm ] |
| Post subject: | Re: [MigraDoc] AddImage is rendering bad quality |
G Fichter wrote: I would like to understand why Migradoc is written without AddImage(Stream stream), and what the risk is for me to add an extension. MigraDoc was designed to persist documents in text files (MGDDL). Filenames will persist, streams will not.You can use streams if you don't need persistence. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|