PDF 格式在转换为 base 64 字符串后会失真

问题描述

我正在尝试将 pdf 作为附件发送到我的邮件中。 我使用的电子邮件服务允许我使用 base 64 编码的字符串作为附件内容。 我正在使用 pdf-creator-node npm 库来生成我的 pdf,它完美地创建了我的 pdf。 但是当我收到邮件时,pdf 格式被扭曲,即对齐和边框。 我的邮件服务使用以下 xml 结构。

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
    xmlns:soap12=\"http://schemas.xmlsoap.org/soap/envelope/\">
<soap12:Body>
    <SendEmail xmlns=\"http://tempuri.org/\">
        <to>'+ recipients +'</to>
        <cc></cc>
        <from>' + from + '</from>
        <subject>' + subject + '</subject>
        <body><![CDATA[' + body + ']]></body>
        <attachments>
            <Attachment>
                <FileName>' + filename + '</FileName>
                <MimeType>' + contentType + '</MimeType>
                <FileContent>contents</FileContent>
            </Attachment>
        </attachments>
    </SendEmail>
</soap12:Body>
</soap12:Envelope>

属性

  • fileName(String):附件的文件名。

  • mimeType(String,optional):附件的 MIME 类型(可选,在 如果不需要)。

  • fileContent(String):base64编码的字符串,代表文档 内容

谁能帮我解决这个问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)