title: How to make Print View of invoice in Joomla VirtueMart publicly viewable?
body: <p>I wanted a function to VM 1.1.8 in Joomla 1.5.22, to allow emailing of pdf invoice to customers who had their purchases confirmed. I've tried various plugins, non works the way I wanted. Thus I'm coding it myself.</p>
  
  <p>To reduce dependency, I've chosen to use <a href="https://pdfcrowd.com/" rel="nofollow">pdfcrowd.com</a> to do the html to pdf conversion, as recommended by some stackoverflowers here. However, I'm now facing one problem where the page to be converted must be publicly view-able in order for pdfcrowd to see the output or else the pdf file will ends up with just the admin login page. I'm been googling around, but not getting anything near, maybe I'm using the wrong search terms.</p>
  
  <p>I've also tried to make an independent php page to display a public invoice, but it was too much hassle to setup everything to make it works without poking into joomla's internals.</p>
  
  <p>The page that I'm trying to reproduce is </p>
  
  <pre><code>administrator/index.php?page=order.order_printdetails&amp;order_id=######&amp;no_menu=1&amp;pop=1&amp;tmpl=component&amp;option=com_virtuemart
  </code></pre>
  
  <p>which is <code>/administrator/components/com_virtuemart/html/order.order_printdetails.php</code></p>
  
  <p>Btw, I'll be implementing one time token check for the invoice view page, so that it can only be use within a short time frame for conversion. Converted invoice will be stored and reused later if needed.</p>
  
  <p>Please advise. Thank you.</p>
  
  <p>EDIT: Thanks to LAS_VEGAS for pointing to cURL. His code works for public page. To access logged in page, I just need to add code to pass the cookie over.</p>
  
  <pre><code>&lt;?php
  // no direct access
  defined('_JEXEC') or die;
  
  //Store cookie in format compatible with cURL
  $cookie = "";
  foreach($_COOKIE as $key =&gt; $value) {
      $cookie .= $key . "=" . $value . "; ";
  }
  $ch = curl_init();
  $fp = fopen("example_page.html", "w");
  
  curl_setopt($ch, CURLOPT_URL, "http://www.example.com/administrator/index.php?page=order.order_printdetails&amp;order_id=######&amp;no_menu=1&amp;pop=1&amp;tmpl=component&amp;option=com_virtuemart");
  curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  curl_setopt($ch, CURLOPT_FILE, $fp);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  
  curl_exec($ch);
  curl_close($ch);
  fclose($fp);
  ?&gt;
  </code></pre>