Converting the PDF to a bitmap image corrupted the text content of the PDF.
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);