简体   繁体   English

如何将Powerpoint演示文稿的Blob数据转换为UI中的图像滑块

[英]how to convert blob data of a power point presentation into a image slider in the UI

Problem: I have a function that uploads .pptx files into the database as blob. 问题:我有一个将.pptx文件作为blob上传到数据库的功能。 Trying to develop a function where i need to read the blob data, convert them into a power point presentation (.pptx) object and then get every individual slide as independent images in the UI (asp.net) so that the user can slide images one after another. 尝试开发一个功能,在该功能中我需要读取Blob数据,将其转换为Powerpoint演示文稿(.pptx)对象,然后将每个单独的幻灯片作为独立的图像获取到UI(asp.net)中,以便用户可以滑动图像相继。

Current status: i have the blob data converted/deflated into a base64 string. 当前状态:我已将Blob数据转换/定义为base64字符串。 How can i convert that into a .pptx file object and then get them in the UI as individual slide images. 我如何将其转换为.pptx文件对象,然后将它们作为单独的幻灯片图像在UI中获得。

Current status: i have the blob data converted/deflated into a base64 string. 当前状态:我已将Blob数据转换/定义为base64字符串。 How can i convert that into a .pptx file object and then get them in the UI as individual slide images. 我如何将其转换为.pptx文件对象,然后将它们作为单独的幻灯片图像在UI中获得。

PS: I do not want the files to be downloaded to local machine. PS:我不希望将文件下载到本地计算机。

Is there any way that this can be achieved. 有什么办法可以做到这一点。 Currently performance of the function is not considered much, just needed this to work as expected 当前对该功能的性能考虑不多,只需要按预期工作即可

Here's what i did: Converted the Blob data to a memory stream and then using the file stream i wrote the data into a file and stored it in the webserver. 我所做的就是:将Blob数据转换为内存流,然后使用文件流将数据写入文件,并将其存储在Web服务器中。 Later extracted the specific file and converted each pptx slide into image and then those images were used in the slideshow. 后来提取了特定文件,并将每个pptx幻灯片转换为图像,然后将这些图像用于幻灯片放映。

Converting the blob data to file (bData is the byte array of the blob data) 将Blob数据转换为文件 (bData是Blob数据的字节数组)

        Using CompressedMemoryStream As New MemoryStream(bData),
                   DecompressedMemoryStream As New MemoryStream(),
                   DecompressionStream As New Compression.DeflateStream(CompressedMemoryStream, Compression.CompressionMode.Decompress)
            DecompressionStream.CopyTo(DecompressedMemoryStream)
            Dim byteData = DecompressedMemoryStream.ToArray()
            Dim fileStream = New FileStream(filePath, FileMode.CreateNew, FileAccess.Write)
            fileStream.Write(byteData, 0, byteData.Length)
            fileStream.Close()
        End Using

Converted the generated file into multiple images for slideshow 将生成的文件转换成多个图像以进行幻灯片显示

        Dim pptapplication As New Microsoft.Office.Interop.PowerPoint.Application
        Dim prsPres As Presentation = pptapplication.Presentations.Open(filePath, MsoTriState.msoCTrue, MsoTriState.msoTriStateMixed, MsoTriState.msoFalse)
        Dim slidesCount = prsPres.Slides.Count()
        If Not isFileExists Then
            For i As Integer = 1 To slidesCount
                prsPres.Slides(i).Export(dir + "\" + "slide" + i.ToString() + ".png", "png", 960, 720)
            Next
        End If
        prsPres.Close()
        pptapplication.Quit()

If anyone can suggest a way to convert the blob data directly into image files instead of converting the blob data into original file and then to images, that will be really helpful. 如果任何人都可以提出一种将Blob数据直接转换为图像文件而不是将Blob数据转换为原始文件然后转换为图像的方法,那将非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM