1

我有一张从签名捕获中捕获的图像。sig cap 返回图像的 base64 字符串。

我想从 javascript 创建一个包含此图像的 rtf 文档字符串。

这是我所拥有的:

var datapair = $sigdiv.jSignature("getData");

哪个返回(缩短,因为要在 SO 上发布):

 ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABNMAAAE2CAYAAABLINTeAAAgAElEQVR4Xu3dCbQtVXkgYPMYRVBAxTi0PkQDmCCgxiESeaBtCK0IGqKJEUzAuUFNtF1Jx/CcVnezYhSMtigYwJjYTgyRaFqNF+chYdBoVEQejgFRURNh4UD/v55qy/Lce88595w6tau+Wutf9wxVe//72/XOved/NfzCLSwECBAgQIAAAQIE2hO4W3S1edTdrvFzn4grI/599NqB8XOPWjor66R2SLy/LeI/phjCA2Ldjy5w/arpW43G+oE1+lptvONsLo92rp8ib6sSIECAAAECCxD4hQW0qUkCQIECBAgQIAAAQIECBBoWUAxrWVw3REgQIAAAQIECBAgQIAAAQIECJQroJhW7tzJnAABAgQIECBAgAABAgQIECBAoGUBxbSWwXVHgAABAgQIECBAgAABAgQIECBQroBiWrlzJ3MCBAgQIECAAAECBAgQIECAAIGWBRTTWgbXHQECBAgQIECAAAECBAgQIECAQLkCimnlzp3MCRAgQIAAAQIECBAgQIAAAQIEWhZQTGsZXHcECBAgQIAAAQIECBAgQIAAAQLlCiimlTt3MidAgAABAgQIECBAgAABAgQIEGhZQDGtZXDdESBAgAABAgQIECBAgAABAgQIlCugmFbu3MmcAAECBAgQIECAAAECBAgQIECgZQHFtJbBdUeAAAECBAgQIECAAAECBAgQIFCugGJauXMncwIECBAgQIAAAQIECBAgQIAAgZYFFNNaBtcdAQIECBAgQIAAAQIECBAgQIBAuQKKaeXOncwJECBAgAABAgQIECBAgAABAgRaFlBMaxlcdwQIECBAgAABAgQIECBAgAABAuUKKKaVO3cyJ0CAAAECBAgQIECAAAECBAgQaFlAMa1lcN0RIECAAAECBAgQIECAAAECBAiUK6CYVu7cyZwAAQIECBAgQIAAAQIECBAgQKBlAcW0lsF1R4AAAQIECBAgQIAAAQIECBAgUK6AYlq5cydzAgQIECBAgAABAgQIECBAgACBlgX+H9F/EpGfbmFGAAAAAElFTkSuQmCC"]

然后我试图用以下字符串形成一个 rtf 文档。

string rtf = @"{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard ";
            rtf += picture;
            rtf += " }";
            return rtf;

图片在哪里(缩短,因为要在 SO 上发布):

var imageData = "iVBORw0KGgoAAAANSUhEUgAABNMAAAE2CAYAAABLINTeAAAgAElEQVR4Xu3dC9A1ZX0YcMOHYlEI0GhMk9EPiLU6NULEptUqL0irphb5IB0ZIxeVljEtl6ixM5kAH5dMR8dLwMY28cIltdgIcnHUdtTwUmsTdUCZxNRqlA9jvTSZfp/FCyKX/v961i7Led93z3nP2bPP7u/M/OfsOWd3n//ze5b3fOfPs7s/8QgPAgQIECBAgAABAgQIECBAgAABAgRaCfxEq7WsRIAAAQIECBAgQIAAAQIECBAgQIDAIxTTHAQECBAgQIAAAQIECBAgQIAAAQIEWgooprWEshoBAgQIECBAgAABAgQIECBAgAABxTTHAAECBAgQIECAAAECBAgQIECAAIGWAoppLaGsRoAAAQIECBAgQIAAAQIECBAgQEAxzTFAgAABAgQIECBAgAABAgQIECBAoKWAYlpLKKsRIECAAAECBAgQIECAAAECBAgQUExzDBAgQIAAAQIECBAgQIAAAQIECBBoKaCY1hLKagQIECBAgAABAgQIECBAgAABAgQU0xwDBAgQIECAAAECBAgQIECAAAECBFoKKKa1hLIaAQIECBAgQIAAAQIECBAgQIAAAcU0xwABoJjWMbjmCBAgQIAAAQIECBAgQIAAAQIEyhVQTCt37GROgAABAgQIECBAgAABAgQIECDQsYBiWsfgmiNAgAABAgQIECBAgAABAgQIEChXQDGt3LGTOQECBAgQIECAAAECBAgQIECAQMcCimkdg2uOAAECBAgQIECAAAECBAgQIECgXAHFtHLHTuYECBAgQIAAAQIECBAgQIAAAQIdCyimdQyuOQIECBAgQIAAAQIECBAgQIAAgXIFFNPKHTuZEyBAgAABAgQIECBAgAABAgQIdCygmNYxuOYIECBAgAABAgQIECBAgAABAgTKFVBMK3fsZE6AAAECBAgQIECAAAECBAgQINCxgGJax+CaI0CAAAECBAgQIECAAAECBAgQKFdAMa3csZM5AQIECBAgQIAAAQIECBAgQIBAxwKKaR2Da44AAQIECBAgQIAAAQIECBAgQKBcAcW0csdO5gQIECBAgAABAgQIECBAgAABAh0L/D9S+8lzAOsdUQAAAABJRU5ErkJggg==";
var picture = "{\pict\pngblip\picw1693\pich1693\picwgoal960\pichgoal960" + imagedata;

然后我将字符串分配给富文本框(我只是想证明 rtf 文件有效的示例 winforms 应用程序)。

this.richTextBox1.Rtf = rtf;

什么都没有显示 =(

4

1 回答 1

2

我发现您正在尝试做的事情有两个主要问题。首先,RTF 要求媒体进行十六进制编码,而不是 Base64。因此,首先将您的图像数据转换为十六进制字符串。然后您需要更改在 RTF 中创建图片的方式。一个微小的变化,但它应该有所作为。将您的 var 图片更改为:

var picture = "{\pict\picw1693\pich1693\picwgoal960\pichgoal960\pngblip" + imagedata;

\pngblip 是告诉 RTF 阅读器接下来是图片数据的内容。

于 2013-07-01T14:20:49.703 回答