PHP pulling embed pdf from xml file

Discussion in 'PHP' started by mthacker, Feb 5, 2008.

  1. #1
    I am working on a project to pull credit reports into our web application using php and xml posting. I have successfully connected, sent and received data and written that data into an xml file. My issue is that the data is within the cdata tag and needs to also be 64bit decoded to produce the pdf file. Anyone have any idea on how I could do this. I'm on php 4.4.4 so some of the newer methods aren't available to me. Any help is much appreciated.
     
    mthacker, Feb 5, 2008 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you might need to look at the base64_decode() function, when writing the database to a file, you might need to use the binary flag when you use fopen as well. without more information there isn't much more i can help you with.
     
    powerspike, Feb 5, 2008 IP
  3. mthacker

    mthacker Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I just can't seem to get the data out of the cdata tag, here's the tag

    <![CDATA[JVBERi0xLjMKJeTjz9IKMSAwIG9iago8PC9UeXBlIC9QYWdlcyAKL0NvdW50IDYgCi9LaWRzIFs0IDAgUiAKMTEgMCBSIAoxNSAwIFIgCjE5AgUiAKMjMgMCBSIAoyNyAwIFIgCl0KPj5l.......NkQ1NjE3MDk1MjFBPjw5QzBDQzM3ODNCRDU0MUFDNDQyOUEzQkNBOTBDRTNENT5dCj4+CnN0YXJ0eHJlZgoxMTYzMgolJUVPRgo=]]>


    how would I pull the data out of the tag into a variable so I can then use the base64_decode() method to get the pdf data out and displayed. Any suggestions?
     
    mthacker, Feb 5, 2008 IP
  4. mthacker

    mthacker Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I'm trying the following to get the cdata values

    preg_match_all("/<![CDATA[(.+)]]>/", $data, $string);
    print_r($string);

    but I'm getting nothing in the value $string, also tried

    preg_match_all("/<![CDATA[(.*?)]]>/", $data, $string);
    print_r($string);
     
    mthacker, Feb 6, 2008 IP
  5. mthacker

    mthacker Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    The data within the cdata tag in the xml file is on multiple lines with line breaks on many lines

    my code is the following

    $TheData = preg_match_all("/<!\[CDATA\[(.+)\]\]>/s", $data, $string);
    print_r($string);

    I get the data but each line in the xml file is on a different line in the variable which causes the pdf to not be created properly due to the line spacing. How can I get the data to stay on one continuous line in the variable?
     
    mthacker, Feb 7, 2008 IP