You can use the following method to convert PDF pages to images:
public async static void RenderPDFPagesAsync(String pdf)
{
StorageFolder tempFolder = ApplicationData.Current.LocalFolder;
StorageFile file = await tempFolder.GetFileAsync(pdf);
PDFDoc doc = new PDFDoc();
try
{
using (var stream = await file.OpenReadAsync())
{
if (doc.Open(stream, "") == PDF_ERROR.err_ok)
{
double previousPageHeight = 0, previousPageWidth = 0;
PDFBmp m_dib = null;
foreach (var index in Enumerable.Range(0, (int)doc.PageCount))
{
PDFPage page = doc.GetPage(index);
try
{
var cFileName = index.ToString() + ".jpg";
page.RenderPrepare();
var pageHeight = doc.GetPageHeight(index);
var pageWidth = doc.GetPageWidth(index);
float scale = (float)1.0;
pageHeight = pageHeight * scale;
pageWidth = pageWidth * scale;
if (previousPageHeight != pageHeight || previousPageWidth != pageWidth || m_dib == null)
{
m_dib = new PDFBmp((int)pageWidth, (int)pageHeight);
previousPageHeight = pageHeight;
previousPageWidth = pageWidth;
}
m_dib.Reset(0xFFFFFF);
PDFMatrix mat = new PDFMatrix(scale, -scale, 0, pageHeight);
page.RenderToBmp(m_dib, mat, true, PDF_RENDER_MODE.mode_normal);
m_dib.SaveJPG(tempFolder.Path + "\\" + cFileName, 90);
}
catch (Exception e) { }
finally
{
page.Close();
}
}
}
}
doc.Close();
}
catch (Exception ex) { }
}
RadaeePDF SDK for Windows 10
Created : 2017-10-24 09:38:26, Last Modified : 2017-10-24 09:40:48