We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PDF Image resolution changing when drawn on a PDF Header

I have an issue with drawing an image on a PDF header.  I am using .NET Core 3.1, Syncfusion.DocIO.Net.Core V 21.1.37,  Syncfusion.DocIORenderer.Net.Core V 21.1.35, Syncfusion.Pdf.Net.Core V 31.1.35The image I am trying to print on the page is 206x32 and gets printed much larger and in the wrong resolution. 

Here is the code i use to draw this image on the page

logopath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "inspection", "HeaderLogo.png");
var sr = File.OpenRead(logopath);
sr.Seek(0, SeekOrigin.Begin);
logo = new PdfBitmap(sr);
RectangleF bounds = new RectangleF(0, 0, pdfDocument.Pages[0].GetClientSize().Width, logo.Height < 50 ? 50 : logo.Height + 5);
            PdfPageTemplateElement header = new PdfPageTemplateElement(bounds);
            header.Graphics.DrawImage(logo, new PointF(0, 0), new SizeF(logo.Width, logo.Height));

This code does work on another application that I work with that is a Web application and API using AspNet.Mvc V 5.2.6. However they do use the same version of Syncfusion and the web applications implementation prints the image properly with the correct resolution. Is there a difference between the version of Syncfusion that is used for a MVC application that could effect the result?

The result we are looking for that the Web application is producing: 


3 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team April 18, 2023 01:57 PM UTC

We have checked the same scenario on our end with both the ASP .Net core web application and the MVC application and the results were the same. We have attached both samples for your reference. we request you try this on your end and let us know the result.

Asp .Net MVC Application: https://www.syncfusion.com/downloads/support/directtrac/general/ze/SyncfusionFieldTest1782624872

Asp .Net MVC core application: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ImportExport-2079097750

We request you share the modified sample and the steps to replicate the issue with us. So that we can assist you further on this.



ML Michael Lemaire replied to Irfana Jaffer Sadhik April 21, 2023 04:47 PM UTC

Thank you for your reply, but I am having difficulties starting the Asp .NET MVC core application that you provided as there are a few required documents that are not provided in the ZIP file. The Annotation.pdf, Annotations.json, ExportedFields.json, ExportedOutput.pdf and input.pdf documents.



IJ Irfana Jaffer Sadhik Syncfusion Team April 25, 2023 07:40 AM UTC

I have removed them from the project. You can ignore and delete those missing files since that is not related to our sample. We have attached the modified sample for your reference. Please try this on your end and let us know the result.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/ImportExport1116108676


Loader.
Up arrow icon