Patagames Software Support Forum
»
Pdfium.Net SDK
»
Bug Report & Technical Support
»
Text clarity (sub pixel rendering) differs between pdfium WPF viewer and rendering code
Rank: Member
Groups: Registered
Joined: 6/1/2016(UTC) Posts: 28  Location: Hessen Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Hi, we found an issue with the latest pdfium version. By rendering images the output (text clarity) is diffrent to the output of the pdfium WPF viewer. The following image is rendered by the Code below.  render.PNG (17kb) downloaded 0 time(s).The following image is rendered by pdfium WPF Viewer.  wpfviewer.PNG (12kb) downloaded 0 time(s).Code:
internal static byte[] BildRendern(byte[] document, int targetWidth, int targetHeight)
{
var doc = PdfDocument.Load(document);
using (var page = doc.Pages[0])
{
using (MemoryStream bitmapStream = new MemoryStream())
{
using (var bitmap = new Bitmap(targetWidth, targetHeight))
{
using (var g = Graphics.FromImage(bitmap))
{
g.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.White), 0, 0, targetWidth, targetHeight);
using (var pdfBitmap = new PdfBitmap(targetWidth, targetHeight, true))
{
page.Render(pdfBitmap, 0, 0, targetWidth, targetHeight, PageRotate.Normal, RenderFlags.FPDF_ANNOT | RenderFlags.FPDF_LCD_TEXT);
g.DrawImageUnscaled(pdfBitmap.Image, 0, 0);
}
}
bitmap.Save(bitmapStream, ImageFormat.Bmp);
return bitmapStream.ToArray();
}
}
}
}
Do you have any idea how we can fix it or how to increase the text clarity? Best regards Julian
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi, The fist image is a text in Anti Aliasing mode Second image - Clear Type mode. To enable clear type mode you should 1. Render with FPDF_LCD_TEXT (already done) 2. Use nontransparent PdfBitmap like shown below Code:var pdfBitmap = new PdfBitmap(targetWidth, targetHeight, false));
pdfBitmap.FillRect(0, 0, targetWidth, targetHeight, Color.White);
page.Render(pdfBitmap, ... RenderFlags.FPDF_LCD_TEXT);
Edited by user Tuesday, December 11, 2018 2:54:49 AM(UTC)
| Reason: Not specified
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 6/1/2016(UTC) Posts: 28  Location: Hessen Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Thanks for the quick Reply. It works great.
|
|
|
|
|
|
Patagames Software Support Forum
»
Pdfium.Net SDK
»
Bug Report & Technical Support
»
Text clarity (sub pixel rendering) differs between pdfium WPF viewer and rendering code
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close