Open decoded base64 pdf in browser

Discussion in 'ASP General' started by Mangler, Jan 11, 2010.

  1. Mangler

    Mangler Guest

    I am using the USPS Electronic Return Merchandise API to print labels
    on the web and am at the last point to get this to work, obviously Im
    stuck now.

    The response from the USPS server is an encoded base64 string that you
    need to decode before being able to use things, I was able to decode
    it no problems. Used a component from XStandard to do so.

    I am unsure what to do from here to get the decoded string to open the
    pdf file in the browser.

    I have been able to get a csv file in the past to open like I want the
    pdf but it is not working, the decoded string shows on the page and
    not an actual pdf file.

    Here is my code :

    <%
    Dim objBase64, strImage
    Const otSafeArray = 0
    Const otString = 2
    strImage = "ENCODED_STRING"
    Set objBase64 = Server.CreateObject("XStandard.Base64")
    Response.ContentType = "application/pdf"
    Response.AddHeader "content-disposition", "attachment;
    filename=test.pdf"
    Response.BinaryWrite objBase64.Decode(strImage, otSafeArray)
    Set objBase64 = Nothing
    %>


    what am I doing wrong?
    Mangler, Jan 11, 2010
    #1
    1. Advertising

  2. Mangler

    Evertjan. Guest

    Mangler wrote on 11 jan 2010 in microsoft.public.inetserver.asp.general:

    > I am using the USPS Electronic Return Merchandise API to print labels
    > on the web and am at the last point to get this to work, obviously Im
    > stuck now.
    >
    > The response from the USPS server is an encoded base64 string that you
    > need to decode before being able to use things, I was able to decode
    > it no problems. Used a component from XStandard to do so.
    >
    > I am unsure what to do from here to get the decoded string to open the
    > pdf file in the browser.
    >
    > I have been able to get a csv file in the past to open like I want the
    > pdf but it is not working, the decoded string shows on the page and
    > not an actual pdf file.
    >
    > Here is my code :
    >
    > <%
    > Dim objBase64, strImage
    > Const otSafeArray = 0
    > Const otString = 2
    > strImage = "ENCODED_STRING"
    > Set objBase64 = Server.CreateObject("XStandard.Base64")
    > Response.ContentType = "application/pdf"
    > Response.AddHeader "content-disposition", "attachment;
    > filename=test.pdf"
    > Response.BinaryWrite objBase64.Decode(strImage, otSafeArray)
    > Set objBase64 = Nothing
    > %>
    >
    >
    > what am I doing wrong?
    >


    Will this help?

    <http://geekswithblogs.net/Lance/archive/2007/07/18/Shipping-APIs-
    FedEx.aspx>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Jan 11, 2010
    #2
    1. Advertising

  3. Mangler

    Mangler Guest

    On Jan 11, 5:00 pm, "Evertjan." <> wrote:
    > Mangler wrote on 11 jan 2010 in microsoft.public.inetserver.asp.general:
    >
    >
    >
    >
    >
    > > I am using the USPS Electronic Return Merchandise API to print labels
    > > on the web and am at the last point to get this to work, obviously Im
    > > stuck now.

    >
    > > The response from the USPS server is an encoded base64 string that you
    > > need to decode before being able to use things, I was able to decode
    > > it no problems.  Used a component from XStandard to do so.

    >
    > > I am unsure what to do from here to get the decoded string to open the
    > > pdf file in the browser.

    >
    > > I have been able to get a csv file in the past to open like I want the
    > > pdf but it is not working, the decoded string shows on the page and
    > > not an actual pdf file.

    >
    > > Here is my code :

    >
    > > <%
    > > Dim objBase64, strImage
    > > Const otSafeArray = 0
    > > Const otString = 2
    > > strImage = "ENCODED_STRING"
    > > Set objBase64 = Server.CreateObject("XStandard.Base64")
    > > Response.ContentType = "application/pdf"
    > > Response.AddHeader "content-disposition", "attachment;
    > > filename=test.pdf"
    > > Response.BinaryWrite objBase64.Decode(strImage, otSafeArray)
    > > Set objBase64 = Nothing
    > > %>

    >
    > > what am I doing wrong?

    >
    > Will this help?
    >
    > <http://geekswithblogs.net/Lance/archive/2007/07/18/Shipping-APIs-
    > FedEx.aspx>
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)- Hide quoted text -
    >
    > - Show quoted text -


    I have seen that but it did not help much.
    Mangler, Jan 11, 2010
    #3
  4. Mangler

    Bob Barrows Guest

    Mangler wrote:
    > I am using the USPS Electronic Return Merchandise API to print labels
    > on the web and am at the last point to get this to work, obviously Im
    > stuck now.
    >
    > The response from the USPS server is an encoded base64 string that you
    > need to decode before being able to use things, I was able to decode
    > it no problems. Used a component from XStandard to do so.
    >
    > I am unsure what to do from here to get the decoded string to open the
    > pdf file in the browser.
    >
    > I have been able to get a csv file in the past to open like I want the
    > pdf but it is not working, the decoded string shows on the page and
    > not an actual pdf file.
    >
    > Here is my code :
    >
    > <%
    > Dim objBase64, strImage
    > Const otSafeArray = 0
    > Const otString = 2
    > strImage = "ENCODED_STRING"
    > Set objBase64 = Server.CreateObject("XStandard.Base64")
    > Response.ContentType = "application/pdf"
    > Response.AddHeader "content-disposition", "attachment;
    > filename=test.pdf"
    > Response.BinaryWrite objBase64.Decode(strImage, otSafeArray)
    > Set objBase64 = Nothing
    > %>
    >
    >
    > what am I doing wrong?


    I'm not entirely sure, but I believe you need a component from Adobe to
    generate a pdf that can be streamed to a client.

    --
    HTH,
    Bob Barrows
    Bob Barrows, Jan 11, 2010
    #4
  5. Mangler

    Evertjan. Guest

    Bob Barrows wrote on 11 jan 2010 in
    microsoft.public.inetserver.asp.general:

    > I'm not entirely sure, but I believe you need a component from Adobe to
    > generate a pdf that can be streamed to a client.


    or Persits AspPdf:

    <http://www.asppdf.com/>



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Jan 12, 2010
    #5
  6. Mangler

    rob^_^ Guest

    Your sample code has syntax errors.

    Regards.

    "Mangler" <> wrote in message
    news:...
    > I am using the USPS Electronic Return Merchandise API to print labels
    > on the web and am at the last point to get this to work, obviously Im
    > stuck now.
    >
    > The response from the USPS server is an encoded base64 string that you
    > need to decode before being able to use things, I was able to decode
    > it no problems. Used a component from XStandard to do so.
    >
    > I am unsure what to do from here to get the decoded string to open the
    > pdf file in the browser.
    >
    > I have been able to get a csv file in the past to open like I want the
    > pdf but it is not working, the decoded string shows on the page and
    > not an actual pdf file.
    >
    > Here is my code :
    >
    > <%
    > Dim objBase64, strImage
    > Const otSafeArray = 0
    > Const otString = 2
    > strImage = "ENCODED_STRING"
    > Set objBase64 = Server.CreateObject("XStandard.Base64")
    > Response.ContentType = "application/pdf"
    > Response.AddHeader "content-disposition", "attachment;
    > filename=test.pdf"
    > Response.BinaryWrite objBase64.Decode(strImage, otSafeArray)
    > Set objBase64 = Nothing
    > %>
    >
    >
    > what am I doing wrong?
    rob^_^, Jan 16, 2010
    #6
  7. Mangler

    Bwig Zomberi Guest

    rob^_^ wrote:
    > Your sample code has syntax errors.


    Probably...

    >
    > Regards.
    >
    > "Mangler" <> wrote in message
    > news:...
    >> I have been able to get a csv file in the past to open like I want the
    >> pdf but it is not working, the decoded string shows on the page and
    >> not an actual pdf file.
    >>
    >> Here is my code :
    >>
    >> <%
    >> Dim objBase64, strImage
    >> Const otSafeArray = 0
    >> Const otString = 2
    >> strImage = "ENCODED_STRING"
    >> Set objBase64 = Server.CreateObject("XStandard.Base64")
    >> Response.ContentType = "application/pdf"
    >> Response.AddHeader "content-disposition", "attachment;
    >> filename=test.pdf"
    >> Response.BinaryWrite objBase64.Decode(strImage, otSafeArray)
    >> Set objBase64 = Nothing
    >> %>
    >>
    >>
    >> what am I doing wrong?

    >


    Try clearing and buffering the response stream.

    Response.Clear
    Response.BufferOutput = true
    Response.ContentType = "application/pdf"

    --
    Bwig Zomberi
    Bwig Zomberi, Jan 20, 2010
    #7
  8. Mangler

    Bwig Zomberi Guest

    Bwig Zomberi wrote:
    > Try clearing and buffering the response stream.
    >
    > Response.Clear
    > Response.BufferOutput = true
    > Response.ContentType = "application/pdf"
    >


    I copied it from ASP.net. Hence the correction:

    Response.Buffer = True
    Bwig Zomberi, Jan 20, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. T Conti

    Error decoded 8 bit characters.

    T Conti, Apr 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    378
    Joerg Jooss
    Apr 11, 2004
  2. Ben Amada

    URL encoded text automatically decoded?

    Ben Amada, Oct 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    1,131
    Mr Newbie
    Oct 4, 2005
  3. pekka niiranen

    Is this a bug? BOM decoded with UTF8

    pekka niiranen, Feb 10, 2005, in forum: Python
    Replies:
    10
    Views:
    605
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Feb 12, 2005
  4. Roland Rickborn

    wxPython: Icon aus base64 decoded Image

    Roland Rickborn, Dec 11, 2006, in forum: Python
    Replies:
    1
    Views:
    462
    Bjoern Schliessmann
    Dec 11, 2006
  5. Jacob Andersen

    Validator's ErrorMessage is decoded

    Jacob Andersen, Jun 24, 2010, in forum: ASP .Net
    Replies:
    3
    Views:
    1,013
    Sarath Babu S
    Jul 8, 2010
Loading...

Share This Page