Skip to content

Instantly share code, notes, and snippets.

@sergio9508
Created September 25, 2023 22:21
Show Gist options
  • Save sergio9508/cc22f508b094271ab259161a365a13db to your computer and use it in GitHub Desktop.
Save sergio9508/cc22f508b094271ab259161a365a13db to your computer and use it in GitHub Desktop.
Convert PDF base 64 to image base64
static List<string> ConvertPdfToImages(string documento)
{
var images = Conversion.ToImages(documento, null, 150);
var result = new List<string>();
foreach (var image in images)
{
SKImage imagen = SKImage.FromPixels(image.PeekPixels());
SKData encoded = imagen.Encode();
Stream stream = encoded.AsStream();
stream.Position = 0;
using MemoryStream ms = new MemoryStream();
stream.CopyTo(ms);
var base64 = ms.ToArray();
result.Add(Convert.ToBase64String(base64));
}
return result;
}
@sergio9508
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment