logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
ju1989  
#1 Posted : Tuesday, December 11, 2018 1:11:45 AM(UTC)
ju1989

Rank: Member

Groups: Registered
Joined: 6/1/2016(UTC)
Posts: 28
Germany
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
Paul Rayman  
#2 Posted : Tuesday, December 11, 2018 2:53:12 AM(UTC)
Paul Rayman

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

ju1989  
#3 Posted : Tuesday, December 11, 2018 4:42:48 AM(UTC)
ju1989

Rank: Member

Groups: Registered
Joined: 6/1/2016(UTC)
Posts: 28
Germany
Location: Hessen

Thanks: 2 times
Was thanked: 1 time(s) in 1 post(s)
Thanks for the quick Reply. It works great.
Users browsing this topic
Guest
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.