0

In an asp.net web application, I am using the below code to read PDF file from the shared path and show it in a table td tag using an iframe. This way it shows pdf like a thumbnail/ Preview. This is working for small pdf file sizes. But the iframe is showing empty for the pdf file size > 25mb( approx).

ImpersonationHelper.Impersonate(ConfigurationManager.AppSettings["Domain"], ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"], delegate
{
    FileBuffer = System.IO.File.ReadAllBytes(filepath);

    if (FileBuffer != null)
    {
        if (filepathnew.Contains("pdf"))
        {
            string base64String = Convert.ToBase64String(FileBuffer, 0, FileBuffer.Length);
            pdfUrl = "data:application/pdf;base64," + base64String;
        }
    }
});

string pdfSource = String.Empty;
pdfSource = "<iframe src=" + pdfUrl + " visible='false' style='overflow:hidden' width='400' height='400' scrolling='no' type='application/pdf' id='pdfPreview'></iframe>";

StringBuilder table = new StringBuilder();
table.Append("<td >" + pdfSource1 + "</td>");
Saeid Amini
  • 1,313
  • 5
  • 16
  • 26
Srik A
  • 63
  • 1
  • 5
  • Your really in a world where you need to create images of the pdfs. The same question in php has been posed. https://stackoverflow.com/questions/467793/how-do-i-convert-a-pdf-document-to-a-preview-image-in-php All roads seem to point towards ghostscript and then some image manipulation. – Richard Housham Jul 12 '19 at 15:06
  • https://github.com/jhabjan/Ghostscript.NET https://github.com/dlemstra/Magick.NET – Richard Housham Jul 12 '19 at 15:07

0 Answers0