Read a stored PDF from memory stream

后端 未结 1 1998
挽巷
挽巷 2021-01-18 22:56

I\'m working on a database project using C# and SQLServer 2012. In one of my forms I have a PDF file with some other information that is stored in a table. This is working s

相关标签:
1条回答
  • 2021-01-18 23:32

    This answer should give you some options: How to render pdfs using C#


    In the past I have used Googles open source PDF rendering project - PDFium

    There is a C# nuget package called PdfiumViewer which gives a C# wrapper around PDFium and allows PDFs to be displayed and printed.

    It works directly with Streams so doesn't require any data to be written to disk

    This is my example from a WinForms app

        public void LoadPdf(byte[] pdfBytes)
        {
            var stream = new MemoryStream(pdfBytes);
            LoadPdf(stream)
        }
    
        public void LoadPdf(Stream stream)
        {
            // Create PDF Document
            var pdfDocument = PdfDocument.Load(stream);
    
            // Load PDF Document into WinForms Control
            pdfRenderer.Load(_pdfDocument);
        }
    
    0 讨论(0)
提交回复
热议问题