Syncfusion.PdfToImageConverter.Base.dll depends WindowsBase, Version=6.0.0.0
Warning MSB3277 Found conflicts between different versions of "WindowsBase" that could not be resolved.
There was a conflict between "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "WindowsBase, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
"WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "WindowsBase, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
References which depend on "WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.13\ref\net8.0\WindowsBase.dll].
Syncfusion.PdfToImageConverter.Base.dll provide
Stream Convert(int pageIndex, float dpiX, float dpiY, bool keepTransparency, bool isSkipAnnotations)
but Syncfusion.PdfToImageConverter.Portabl.dll don't
How to convert pdf to image? 300 dpi is required
thanks
When using PdfToImageConverter.Base, we can set the DPI values because PdfToImageConverter.Base internally utilizes the System.Drawing assembly for image creation. However, PdfToImageConverter.Portable uses SkiaSharp for image creation, and SkiaSharp does not support customizing the resolution of images based on DPI values. Therefore, it is not possible to use DPI values with PdfToImageConverter.Portable to create custom resolution images, making PdfToImageConverter.Base functions not recommended for the EJ2 platform. However, we will check the possibility of creating images with DPI values in PdfToImageConverter.Portable, and we will provide further details on February 21st, 2025.
After further analysis, we have determined that SkiaSharp does not support customizing the resolution of images based on DPI values. Therefore, using DPI values to create images is not possible in PdfToImageConverter.Portable. In PdfToImageConverter.Portable, PDF pages can be converted to images with specific attributes, such as zoom factor, tile dimensions (x and y), and tile matrix coordinates (x and y), by passing the corresponding values as parameters to the Convert API. To enhance image quality, you can use the ScaleFactor property, which can be set to values between 0.5 and 2. If we adjusting the ScaleFactor does not affect the DPI values of image but changes the image size accordingly. For more details, please refer to the code snippet and User Guide link below.
//Initialize PDF to Image converter. float zoomFactor = 1; int tileXCount = 1; int tileYCount = 1; int tileX = 0; int tileY = 0;
//Initialize PDF to Image converter. PdfToImageConverter imageConverter = new PdfToImageConverter();
//ScaleFactor value is set to 2, while the default value is 1.5f. imageConverter.ScaleFactor = 1.5f; //Load the PDF document as a stream FileStream inputStream = new FileStream("D:\\Input.pdf", FileMode.Open, FileAccess.ReadWrite); imageConverter.Load(inputStream); //Convert PDF to Image. Stream outputStream = imageConverter.Convert(0, zoomFactor, tileXCount, tileYCount, tileX, tileY); MemoryStream stream = outputStream as MemoryStream; byte[] bytes = stream.ToArray(); using (FileStream output = new FileStream("D:\\outputTilecounts2.png", FileMode.OpenOrCreate, FileAccess.ReadWrite)) { output.Write(bytes, 0, bytes.Length); } |
Additionally We have created a sample for the same and attached below for your reference.
UG Link :
Converting PDF pages into images in ASP.NET Core| Syncfusion®