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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
ju1989  
#1 Posted : Thursday, February 15, 2018 6:05:22 AM(UTC)
Quote
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,

I have an issue by rendering pages.
If I compare the image rendered by the Code below with the page presented by Adobe Acrobat Reader, there is a huge gap. In Adobe Arcobat Reader the font is slimmer than in the rendered Image.

Attached is a sample document, a screenshot from the document opened in Adobe Arcobat Reader and the rendered image.


Code:

using (MemoryStream bitmapStream = new MemoryStream())
{
	using (var bitmap = new Bitmap(targetWidth, targetHeight))
	{
		using (var g = Graphics.FromImage(bitmap))
		{
			g.FillRectangle(new 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);
				g.DrawImageUnscaled(pdfBitmap.Image, 0, 0);
			}
		}
		bitmap.Save(bitmapStream, ImageFormat.Bmp);
		return bitmapStream.ToArray();
	}
}


Do you have any information how I can fix it?

Best regards



Rendered_Image.bmp (3,305kb) downloaded 35 time(s). Document.pdf (106kb) downloaded 26 time(s). Screenshot_Adobe.bmp (2,204kb) downloaded 30 time(s).
Paul Rayman  
#2 Posted : Thursday, February 15, 2018 6:54:57 AM(UTC)
Quote
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)
Your images has different size.
If you scale the Adobe screenshot to size of rendered image, then you will see that there is no any differences.

By the way, how are you calculating targetWidth and targetHeight?
If you want to get actual size of the page (to compare it with actual size from AdobeReader) you should use the following formula

targetWidth = page.Width / 72.0 * dpi.X;
targetHeight = page.Height / 72.0 * dpi.Y;

where dpi is a current dpi of your desktop.
ju1989  
#3 Posted : Thursday, February 15, 2018 11:49:08 PM(UTC)
Quote
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)
I think the Problem isn't scaling or the size. The difference is if I have a Image PDF (like a scanned document) than there is no difference to Adobe Acrobat Reader. There is only the difference when we have a vector PDF (like created with word).

The Size is calculated like you said.

Quote:
targetWidth = page.Width / 72.0 * dpi.X;
targetHeight = page.Height / 72.0 * dpi.Y;


I only add some scaling between 0.5 and 4.0 in steps of 0.1.

I compare the output of the rendered Image with Adobe Acrobat with same page size (scale).
ju1989  
#4 Posted : Thursday, March 8, 2018 2:35:30 AM(UTC)
Quote
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)
any further ideas?
Quick Reply Show Quick Reply
Users browsing this topic
Guest
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.