ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Open a existent pdf file using CI

February 11, 2009 1:04pm

Subscribe [3]
  • #1 / Feb 11, 2009 1:04pm

    Thiago Luiz

    23 posts

    Hi, my name is Thiago and I’m from Brazil. I’m trying to open a existent pdf file into a browser using CI but I had no success. Someone can help me?

  • #2 / Feb 11, 2009 3:01pm

    jalalski

    113 posts

    It’s just an ordinary ‘a href=...’. I don’t think CI has anything to do with the opening, that is dependent on how the browser is setup to handle links of that type.
    But maybe you can explain in a little more detail what you are trying to accomplish?

  • #3 / Feb 11, 2009 3:16pm

    hostcord

    21 posts

    Make sure in your htaccess file that the directory or file is excluded from being routed through codeigniters routing. Edit your htaccess file.

  • #4 / Feb 11, 2009 3:36pm

    Thiago Luiz

    23 posts

    I am trying to open a view of the IC and putting href not just open the pdf file. I tried to upload through the controller, but without success.

    This is an excerpt of the code view:


    <table width=“588” height=“313” border=“0” align=“center” cellpadding=“0” cellspacing=“0”>
        <tr>
          <td height=“215”>
         
            _         - Some Text Here_         <font color=”#ff0000”>  </font>_                  
         
          </td>     
        </tr>
    </table>


    And once again, I tried to construct a function trough and into this function, I tried to load pdf file but no success.

  • #5 / Feb 11, 2009 8:49pm

    Adi Setiawan

    10 posts

    just like hostcord said, you may exclude path to pdf file for being route by CI in .htaccess

    RewriteCond $1 !^(index\.php|pathtopdf)

  • #6 / Feb 12, 2009 8:24am

    Thiago Luiz

    23 posts

    Adi, I tried to do what you and hostcord said but I have no success.
    Something that I tried was call a function of controller in href into the view and in the controller call $this->load->view(‘subfolder/file.pdf’);

    but this way appeared a error like this:

    Warning: Unexpected character in input: ‘’ (ASCII=1) state=1 in C:\ complete path on line 394

    Parse error: syntax error, unexpected ‘:’ in C:\ complete path on line 394

    I don’t understand this error because, the pdf file is like any pdf file that can be found on internet

  • #7 / Feb 12, 2009 9:25am

    Adi Setiawan

    10 posts

    not sure what you want, why you load pdf file as view file? could you explain what exactly do you want?
    if you want to force user to download pdf file, you can use download helper

    $this->load->helper('download');
    $data = file_get_contents("subfolder/file.pdf");
    $name = 'file.pdf';
    force_download($name, $data);
  • #8 / Feb 12, 2009 9:41am

    Thiago Luiz

    23 posts

    let me explain a little in details:
    I have a menu where the stories are posted and some news may be a pdf file that is in a subdirectory.
    Then I want to create a link to open the pdf file in web page using the CI.

  • #9 / Feb 12, 2009 9:52am

    Adi Setiawan

    10 posts

    then it’s just as easy as create html link news in pdf

  • #10 / Feb 12, 2009 11:01am

    Thiago Luiz

    23 posts

    this is the exact problem, this does not work

  • #11 / Feb 12, 2009 11:04am

    Adi Setiawan

    10 posts

    any error message ? try to open http://yourdomain.cnom/path/to/file.pdf in your browser

  • #12 / Feb 12, 2009 11:09am

    Thiago Luiz

    23 posts

    I’m using the Vertrigo, doing what you said http://yourdomain.cnom/path/to/file.pdf in my browser, the request goes to the index.php of Vertrigo Serv.

  • #13 / Feb 12, 2009 11:43am

    Thiago Luiz

    23 posts

    no message errors, just browser not found the page requested

  • #14 / Feb 12, 2009 1:38pm

    Thiago Luiz

    23 posts

    Solved the problem. I put the subfolder where the pdf file on the same level of the CI system folder and again tried to use that Adi Setiawan said:

    $ this-> load-> helper ( ‘download’);
    $ data = file_get_contents ( “subfolder / file.pdf”);
    $ name = ‘file.pdf’;
    force_download ($ name, $ date);

    And it worked, now I can load through a view open a pdf file.

  • #15 / Feb 12, 2009 1:40pm

    Thiago Luiz

    23 posts

    Thanks Adi, hostcord and jalalski.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases