从singeles文档.Net创建一个文档

问题描述 投票:0回答:1

我正在尝试创建一个包含一些单个文档的文档。 我编写了一个从数据库文件中获取的函数,并将它们连接起来。 问题是该功能只显示第一个文件。 我想也许我们应该将文件与分页符分开。 有谁知道如何做到/解决问题?

    ds = BL.GetDocuments() 
    If Not ds Is Nothing Then
        Dim index As Integer = 0
        context.Response.Clear()

        For index = 0 To ds.Tables(0).Rows.Count - 1
            If Not IsDBNull(ds.Tables(0).Rows(index).Item(0)) Then
                bytes = CType(ds.Tables(0).Rows(index).Item(0), Byte())
            End If
            If index = 0 Then
                merged = New Byte(((bytes.Length)) - 1) {}
                bytes.CopyTo(merged, 0)
                saveArray = merged
            Else
                merged = New Byte(((bytes.Length + saveArray.Length)) - 1) {}
                saveArray.CopyTo(merged, 0)
                bytes.CopyTo(merged, saveArray.Length)
                saveArray = merged
            End If

        Next
        context.Response.BinaryWrite(merged)
        context.Response.ContentType = "image/png"
        HttpContext.Current.ApplicationInstance.CompleteRequest()

    End If
.net vb.net
1个回答
1
投票

通常,字节连接对你不起作用,因为大多数文档都以某种标题开头,例如,文档正文的大小(页数/高度和宽度),以及所有后面的数据,在该主体之外,是丢弃(充其量 - 某些程序可能无法打开或崩溃)。从您的代码中,我看到您正在尝试合并PNG图像。您需要做的是将图像解压缩为纯位图,然后从中创建单个位图,然后将其转换回PNG。请注意压缩参数,否则可能会失去一些质量。

© www.soinside.com 2019 - 2024. All rights reserved.