none
PDF to Base64 RRS feed

  • Question

  • Hello,

    Made a lot of searches but do not find anything

    How can I convert a PDF file to a Base64 string using only Access VBA

    Thanks

    Eric.

    Wednesday, December 27, 2017 10:21 AM

Answers

All replies

  • Hello grommerch,

    You could load the PDF into a byte array and then encode the byte array to base64 string.

    Please try to refer to below code.

    Remember add reference to  Microsoft XML v6.0

    Sub TestConvert()
        Dim bytes
        Dim B64String
        With CreateObject("ADODB.Stream")
        .Open
        .Type = ADODB.adTypeBinary
        .LoadFromFile "C:\Users\Admin\Desktop\Test.pdf"
        bytes = .Read
        .Close
        End With
        B64String = EncodeBase64(bytes)        
    End Sub
    
    Private Function EncodeBase64(bytes) As String
        Dim objXML As MSXML2.DOMDocument60
        Dim objNode As MSXML2.IXMLDOMElement
    
        Set objXML = New MSXML2.DOMDocument60
        Set objNode = objXML.createElement("b64")
    
        objNode.DataType = "bin.base64"
        objNode.nodeTypedValue = bytes
        EncodeBase64 = objNode.Text
    
        Set objNode = Nothing
        Set objXML = Nothing
    End Function

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 28, 2017 4:58 AM
  • Hello Terry,

    Thanks for help

    Your code convert a pdf file to a base64 string but when I try to decode using an online tool, I do not see my pdf but a lot of strange character and some info about the encoded pdf file.

    I paste here the encoded file

    ________________________________________________________________

    Y2YoO2ACiaHJpU5maLbE0KSp0ZjM0MwMLRqzxmpU4mpJlVemc5cvSKq8aQo3ZGbqqrzS9GeQ
    obLqgzs+4WNkR9qgryYU5MdEFKp1B6JQZVm9QNWDXPwxuOrOVcsTjHzYtE2yBm3KLPE46Oz1
    jrPY670n6JH1IcFzBTLkTDqnd2t8uCOfSYQfrHzeGvdhwW94vQqgnxtHDPQrdyFvBAR5vTdQ
    I/xXoaMz0fB6ZymUVvgrOb42kXGw1ysC9Mon75bNhw+bytOMlFaYZD5sqmJ3r1ekFYwePmza
    ZuXDpvJcY3i9CiqDhu8qvN5ZyQrMkvZQRR+8qSZbY25g1bGedYzszgvIy5zZ0AjE7H7KHD6y
    MqDp/I9VEGLvkPR/70uKNPeYDeewFECLFHoz31lsSKUlP3ny6ujslXn7VP3BR9KVv0P8JfdY
    JbOJixBwZ/dYWVrMUjSLnBOhtqV5443liB6kALxX2qKVr0KaLc0bZ6MZoMglekk6NKckI40W
    8KWxMLsXrqNEOWw/SDkwu5/5qImI9gPy7H6uxjOIueAIvwDtIA9eki89r612P1vBZrByxslp
    nUqEvy+1+VxA6NhBR+MZxLzzWKRN/mrlEjfXtokOAStn3Jx2qETi+tYGiQyWVcsziEkD1l+H
    0Ol5viC10lpfEP4Ql6zvCz4wYn/1WdOwaevpDFJXFhiH1g36jS3J8p6drPIZnNbI4AiALaSD
    a/K8KlFS/8WH1rUKGv0OrUhPWmZuc2M5QKrAytyVDZ1yUzrD6Bze9VD+PG3xDEGFhAtkHnjs
    JtrJPGCMo/mK0uGrCfOOtTSUbBLE3LQhpoAy0mbFpMM/KgTq84f26UToYVLOSubm0BLWoqPu
    ykwcMVeu3dysB4fWDSxkxPKWgci4c4m0A7no8Ly8BEs0rlI5rfFXnU3iovUcebEWBNMp+8g4
    uZBDAPoqMA6tG9yeFWOG0g+/Uvj2wWU9SXU/VvSXHF4Js7Ak0A43HNV07GPlU5KL3I7InCH2
    3RW6TlcclpW3g1k6dNjyJY88utXSGuficWx1Vh4Z1NAwvbJ/siik7C2E/IzVcGxQKhicxvQ3
    GJkfE+IIKumQooKZMq5MySeEeFv9gnxuas20EL4mzQvXolmaAmjVSAvh9w1aZB1cCFWgjynP
    tCyqmeNLcmjWSAvhq5NDszrZJQUYAXhvXr4KiY/k0KzB9mCwIsysJHyycfHy+VppIXzJyeiY
    EqzFSsJHRtdMC+FrVk57mOS0EC5ydid2USiBgZgSrJ0WwgXGOLVpIVwB1HzTQvha5K+vlRbC
    hdVoKj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0PSdhcHBsaWNh
    dGlvbi9wZGYnPjxkYzp0aXRsZT48cmRmOkFsdD48cmRmOmxpIHhtbDpsYW5nPSd4LWRlZmF1
    bHQnPjIwMTcxMTI0MTQxMzEwPC9yZGY6bGk+PC9yZGY6QWx0PjwvZGM6dGl0bGU+PGRjOmNy
    ZWF0b3I+PHJkZjpTZXE+PHJkZjpsaT4wOTwvcmRmOmxpPjwvcmRmOlNlcT48L2RjOmNyZWF0
    b3I+PGRjOmRlc2NyaXB0aW9uPjxyZGY6U2VxPjxyZGY6bGk+KCk8L3JkZjpsaT48L3JkZjpT
    ZXE+PC9kYzpkZXNjcmlwdGlvbj48L3JkZjpEZXNjcmlwdGlvbj4KPC9yZGY6UkRGPgo8L3g6
    eG1wbWV0YT4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
    ICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAg
    ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAo8P3hwYWNr
    ZXQgZW5kPSd3Jz8+CmVuZHN0cmVhbQplbmRvYmoKMiAwIG9iago8PC9Qcm9kdWNlcihHUEwg
    R2hvc3RzY3JpcHQgOS4xMCkKL0NyZWF0aW9uRGF0ZShEOjIwMTcxMTI0MTQxMzA5KzAxJzAw
    JykKL01vZERhdGUoRDoyMDE3MTEyNDE0MTMwOSswMScwMCcpCi9BdXRob3IoXDM3NlwzNzdc
    MDAwMFwwMDA5KQovQ3JlYXRvcihcMzc2XDM3N1wwMDBQXDAwMERcMDAwRlwwMDBDXDAwMHJc
    MDAwZVwwMDBhXDAwMHRcMDAwb1wwMDByXDAwMCBcMDAwVlwwMDBlXDAwMHJcMDAwc1wwMDBp
    XDAwMG9cMDAwblwwMDAgXDAwMDFcMDAwLlwwMDA3XDAwMC5cMDAwMykKL0tleXdvcmRzKCkK
    L1N1YmplY3QoKQovVGl0bGUoXDM3NlwzNzdcMDAwMlwwMDAwXDAwMDFcMDAwN1wwMDAxXDAw
    MDFcMDAwMlwwMDA0XDAwMDFcMDAwNFwwMDAxXDAwMDNcMDAwMVwwMDAwKT4+ZW5kb2JqCnhy
    ZWYKMCA4CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDI3MjU0OSAwMDAwMCBuIAowMDAwMjc0
    MjQyIDAwMDAwIG4gCjAwMDAyNzI0OTAgMDAwMDAgbiAKMDAwMDI3MjM3NiAwMDAwMCBuIAow
    MDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAyNzIzNTQgMDAwMDAgbiAKMDAwMDI3MjYxMyAwMDAw
    MCBuIAp0cmFpbGVyCjw8IC9TaXplIDggL1Jvb3QgMSAwIFIgL0luZm8gMiAwIFIKL0lEIFs8
    NDNBMzY5MzMzODE4RTMyQjkxNUQ2OTU3QUMwNzJGMzA+PDQzQTM2OTMzMzgxOEUzMkI5MTVE
    Njk1N0FDMDcyRjMwPl0KPj4Kc3RhcnR4cmVmCjI3NDY0MgolJUVPRgo=
    ________________________________________________________________________________

    Do you see somthing wrong

    Thanks again

    Eric

    Thursday, December 28, 2017 11:50 AM
  • Hello grommerch,

    Microsoft does not support such online decode tool. If you want to check if the base64 string is right, please update code like below. It will convert a test pdf to a base64 string and then encoding it and write it to a new pdf. Please check if the converted pdf is the same as original test pdf.

    Sub TestConvert()
        Dim bytes
        Dim B64String
        With CreateObject("ADODB.Stream")
        .Open
        .Type = ADODB.adTypeBinary
        .LoadFromFile "C:\Users\v-guaxu\Desktop\Test.pdf"
        bytes = .Read
        .Close
        End With
        B64String = EncodeBase64(bytes)
        
        
        Dim str As String
        str = B64String
        Dim Base64Byte() As Byte
        Base64Byte = decodeBase64(str)
    
        With CreateObject("ADODB.Stream")
        .Open
        .Type = adTypeBinary
        .Write Base64Byte
        .SaveToFile "C:\Users\v-guaxu\Desktop\Converted.pdf"
        .Close
        End With
        
    End Sub
    
    Private Function EncodeBase64(bytes) As String
        Dim objXML As MSXML2.DOMDocument60
        Dim objNode As MSXML2.IXMLDOMElement
    
        Set objXML = New MSXML2.DOMDocument60
        Set objNode = objXML.createElement("b64")
    
        objNode.DataType = "bin.base64"
        objNode.nodeTypedValue = bytes
        EncodeBase64 = objNode.Text
    
        Set objNode = Nothing
        Set objXML = Nothing
    End Function
    
    Private Function decodeBase64(ByVal strData As String) As Byte()
        Dim objXML As MSXML2.DOMDocument60
        Dim objNode As MSXML2.IXMLDOMElement
        
        Set objXML = New MSXML2.DOMDocument60
        Set objNode = objXML.createElement("b64")
        objNode.DataType = "bin.base64"
        objNode.Text = strData
        decodeBase64 = objNode.nodeTypedValue
        
        Set objNode = Nothing
        Set objXML = Nothing
    End Function

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 29, 2017 1:52 AM
  • It works great

    Thanks a lot

    Happy new year

    Eric

    • Marked as answer by grommerch Friday, December 29, 2017 10:49 AM
    Friday, December 29, 2017 10:49 AM