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)
|
I have a PDF document which gets rendered very strange. I think it is a Problem of contrast and brightness. I use the following Code to get the Image. Code:
using (MemoryStream bitmapStream = new MemoryStream())
{
lock (lockObject)
{
using (var bitmap = new Bitmap(targetWidth, targetHeight))
{
using (var g = Graphics.FromImage(bitmap))
{
g.FillRectangle(new SolidBrush(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);
return bitmapStream.ToArray();
}
}
}
Attached is the PDF document  document.pdf (894kb) downloaded 7 time(s)., the output image of Adobe Reader  output_acrobat.png (1,035kb) downloaded 8 time(s). and the output of the Code above  output_pdfium.png (680kb) downloaded 7 time(s).. Do you have any ideas how to fix it?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
The code below produce normal output image. I do not know how you could get other one. Can you provide the full code? Code:
using (var doc = PdfDocument.Load(@"d:\0\4\document.pdf"))
{
using (var page = doc.Pages[0])
{
int targetWidth = (int)(page.Width / 72.0f * 96.0f);
int targetHeight = (int)(page.Height / 72.0f * 96.0f);
using (var bitmap = new Bitmap(targetWidth, targetHeight))
{
using (var g = Graphics.FromImage(bitmap))
{
g.FillRectangle(new SolidBrush(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(@"d:\0\4\output.png", System.Drawing.Imaging.ImageFormat.Png);
}
}
}
|
|
|
|
|
|
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)
|
Sorry, my mistake. It is an additional applied DirectX shader.
-> closed
|
|
|
|
|
|
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