I'd like to export all pages of a PDF file to separate image files (one image file per page). Can I do this with the PDFViewer or PDF Framework? I don't need to view the PDF, just take a file and convert it to individual image file per page.
Thanks,
Mike
Hi Mike,
Kindly Refer the below UG documentation for your requirement. PDF Viewer allows to save each page into separate image files.
UG documentation - https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/how-to/export-as-image
NOTE: You can refer to the below link where you can convert a PDF document into images, using Syncfusion PDF Viewer.
Website link - https://boldpdftools.com/
Regards,
Visvesvar K V
Sorry for the late reply, got busy on other things. That example is for .net core, I'm using Blazor. I got the following to work in Blazor Server:
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(bFile);
for (int i = 0; i <loadedDocument.PageCount; i++)
{
PdfPageBase pageBase = loadedDocument.Pages[i];
var extractedImages = pageBase.ExtractImages();
if (extractedImages is not null && extractedImages.Count() > 0)
{
img.Add(ConvertImageToBytes(extractedImages[0]));
}
}
loadedDocument.Close(true);
But when I migrate it to Blazor WebAssembly I get any error on this line:
var extractedImages = pageBase.ExtractImages();
Error: System.Drawing is not supported on this platform.
How would I migrate some like what is above to WebAssembly?
Thanks,
Mike
Hi Michael,
We can extract the image from existing PDF document by using ExtractImages API. To extract the image from PDF document in .NET 6, we need to install the Syncfusion.Pdf.Imaging.NET package in your application. We have created a .NET 6 Blazor client sample for extracting the images an existing PDF document using the Syncfusion.Pdf.Imaging.NET package and attached the sample for your reference. Kindly please run the below sample on your end with your input document and let us know the result.
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp_Client-1843733915
NuGet link : https://www.nuget.org/packages/Syncfusion.Pdf.Imaging.Net
Please let us know if you need any further assistance in this.
Regards,
Gowthamraj K
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
So, the example you provided was just the same code I poste;) It works fine with Blazor Client, BUT NOT BLAZOR WEBASSEMBLY!
Is there any way to extract images from PDF pages on the client using WebAssembly? I currently worked around it by sending the PDF file off to a controller to do the processing. It works, but I'd rather do all the processing on the client instead of sending it off to the server then sending it back to the client.
Thanks,
Mike
Hi Michael Lambert
We are trying to
reproduce the reported issue with WASM sample on our end and we will update the
further details on September 14th 2022.
Meanwhile, we are request you to share the more issue details, input document,
error or exception details, simplified sample with us to check the issue on our
end. So that it will helpful for us.
Regards,
Gowthamraj K
Hi Michael Lambert,
We have created a .NET 6 Blazor Webassembly sample for extracting the images an existing PDF document using the Syncfusion.Pdf.Imaging.NET package, but it working properly. We have attached the sample and screenshot for your reference. Kindly please run the below sample on your end with your input document and let us know the result
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/WASMPDFViewer1872215153
Please find the screenshot below with extract image result,
|
Please let us know if you need any further assistance in this.
Regards,
Gowthamraj K