public byte[] ViewAsPdf(string filePath)
        {
            List <MemoryStream> pages = new List <MemoryStream>();
            var stringContent         = new StringBuilder();


            using (Viewer viewer = new Viewer(filePath))
            {
                var streamFactory = new MemoryFileStreamFactory();
                var options       = new PdfViewOptions(streamFactory);

                viewer.View(options);

                // Return or write stream
                var stream    = streamFactory.Stream;
                var byteArray = new byte[stream.Length];
                //var x = stream.Read(byteArray, 0, (int) stream.Length);
                byteArray = stream.ToArray();
                return(byteArray);
            }



            return(new byte[1]);
        }
Example #2
0
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
            {
                MemoryFileStreamFactory streamFactory = new MemoryFileStreamFactory();
                PdfViewOptions          options       = new PdfViewOptions(streamFactory);

                viewer.View(options);

                // Return or write stream
                MemoryStream stream = streamFactory.Stream;
            }

            Console.WriteLine("\nSource document rendered successfully.");
        }