Converting the PDF to a bitmap image corrupted the text content of the PDF.

Vikram Devaraj 0 Reputation points
2024-03-04T19:42:32.9566667+00:00

I have a PDF document and using the below code logic, I am trying to convert the PDF page to an image. After converting the image, the text content in the PDF displayed as corrupted. 

PQ-376500-STR-FDN-KZV-00011-001.pdf

|Stream PdfStream = typeof(MainActivity).GetTypeInfo().Assembly.GetManifestResourceStream("PDFIssue.Assets.PQ-376500-STR-FDN-KZV-00011-001.pdf");
 var outputStream = OpenFileOutput("_sample.pdf",
FileCreationMode.Private);
 PdfStream?.CopyTo(outputStream);
 var fileStreamPath = GetFileStreamPath("_sample.pdf");
 PdfRenderer Renderer = new
PdfRenderer(ParcelFileDescriptor.Open(fileStreamPath,
ParcelFileMode.ReadOnly));
 PdfRenderer.Page pdfPage =
Renderer.OpenPage(0);
 
 Bitmap bitmap = Bitmap.CreateBitmap((int)(1500), (int)(1500),
Bitmap.Config.Argb8888);
 pdfPage.Render(bitmap, new Rect(0, 0, (int)(1500), (int)(1500)), null,
PdfRenderMode.ForDisplay);
           
 ImageView mainView =
FindViewById<ImageView>(Resource.Id.myImageView);
 mainView.SetImageBitmap(bitmap);

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,362 questions
Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,901 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,911 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,005 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
814 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.