I'm working on some code to put a unique watermark on the bottom each page of every downloaded PDF, e.g. firstname, lastname, email.
That part I can do. What I can't figure out is how to get the user's name etc. from the database within the file /catalog/model/account/download.php
Seriously, I'm stumped. My mind has turned to mush.
If anyone could point me in the right direction, or throw me a snippet of code, I'd be ever so grateful. Then maybe I can upload my contribution!
That part I can do. What I can't figure out is how to get the user's name etc. from the database within the file /catalog/model/account/download.php
Seriously, I'm stumped. My mind has turned to mush.
If anyone could point me in the right direction, or throw me a snippet of code, I'd be ever so grateful. Then maybe I can upload my contribution!
Hi, antijoe
I' think this idea its no so good, but anyway if this its very important for you, I' post an small exaple of using dompdf watermark
The easy way its to make an footer for each page and writ down you advertising text.
Regards,
Nicu
I' think this idea its no so good, but anyway if this its very important for you, I' post an small exaple of using dompdf watermark
Code: Select all
<html>
<head>
<style type="text/css">
.main {
width: 16cm;
height: 28cm;
margin: 0.2in auto;
background-image: url(http://your_domain/images/
watermark.png);
background-position: 50% 50%;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<div class="main">
Lorem ipsum dolor.
</div>
</body>
</html>
Regards,
Nicu
Sorry, my intention was not entirely clear!
If you are selling e-books you want some way of reducing the chance of copies being redistributed by marking them with a unique watermark or footer.
Because the original PDF is not generated on the fly I have used FPDF_PDFI to add a footer to each page. As the file is downloaded the footer is applied. That part is complete. I'm not familiar with the CVM method used by opencart so I'm having difficulty pulling out the correct details of the user who is downloading the file.
I suppose I only really need the firstname, lastname and email of the customer.
Any ideas anyone?
If you are selling e-books you want some way of reducing the chance of copies being redistributed by marking them with a unique watermark or footer.
Because the original PDF is not generated on the fly I have used FPDF_PDFI to add a footer to each page. As the file is downloaded the footer is applied. That part is complete. I'm not familiar with the CVM method used by opencart so I'm having difficulty pulling out the correct details of the user who is downloading the file.
I suppose I only really need the firstname, lastname and email of the customer.
Any ideas anyone?
In the hope that sharing may encourage some sharing... this is what I've come up with so far...
Grab http://chir.ag/projects/pdfb/pdfb_demo_compact.zip
and copy the fpdf_fpdi folder into
/catalog/controller/account/fpdf_fpdi
Thne change /public_html/testbed/catalog/controller/account/download.php to the file below...
Should all go to plan your PDFs will now be stamped with the message "This could be a name and MD5 hash in the footer!"
Of course this would be better if it was say, the user's name and email address. The SQL is a little beyond me. Anyone care to suggest a fix?
Grab http://chir.ag/projects/pdfb/pdfb_demo_compact.zip
and copy the fpdf_fpdi folder into
/catalog/controller/account/fpdf_fpdi
Thne change /public_html/testbed/catalog/controller/account/download.php to the file below...
Code: Select all
<?php
$path = $_ENV["DOCUMENT_ROOT"] . '/catalog/controller/account/fpdf_fpdi/font';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
$path = $_ENV["DOCUMENT_ROOT"] . '/catalog/controller/account/fpdf_fpdi';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require('fpdf_fpdi/fpdi.php');
class PDF extends FPDI
{
function Header()
{
//$this->Text(35, 35, "This could be a name and MD5 hash in the header!");
}
function Footer()
{
$this->Text(35, 800, "This could be a name and MD5 hash in the footer!");
}
}
class ControllerAccountDownload extends Controller {
public function getCustomer($customer_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int)$customer_id . "'");
return $query->row;
}
public function index() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->https('account/download');
$this->redirect($this->url->https('account/login'));
}
$this->language->load('account/download');
$this->document->title = $this->language->get('heading_title');
$this->document->breadcrumbs = array();
$this->document->breadcrumbs[] = array(
'href' => $this->url->http('common/home'),
'text' => $this->language->get('text_home'),
'separator' => FALSE
);
$this->document->breadcrumbs[] = array(
'href' => $this->url->http('account/account'),
'text' => $this->language->get('text_account'),
'separator' => $this->language->get('text_separator')
);
$this->document->breadcrumbs[] = array(
'href' => $this->url->http('account/download'),
'text' => $this->language->get('text_downloads'),
'separator' => $this->language->get('text_separator')
);
$this->load->model('account/download');
$download_total = $this->model_account_download->getTotalDownloads();
if ($download_total) {
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_order'] = $this->language->get('text_order');
$this->data['text_date_added'] = $this->language->get('text_date_added');
$this->data['text_name'] = $this->language->get('text_name');
$this->data['text_remaining'] = $this->language->get('text_remaining');
$this->data['text_size'] = $this->language->get('text_size');
$this->data['text_download'] = $this->language->get('text_download');
$this->data['button_continue'] = $this->language->get('button_continue');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$this->data['downloads'] = array();
$results = $this->model_account_download->getDownloads(($page - 1) * 10, 10);
foreach ($results as $result) {
if (file_exists(DIR_DOWNLOAD . $result['filename'])) {
$size = filesize(DIR_DOWNLOAD . $result['filename']);
$i = 0;
$suffix = array(
'B',
'KB',
'MB',
'GB',
'TB',
'PB',
'EB',
'ZB',
'YB'
);
while (($size / 1024) > 1) {
$size = $size / 1024;
$i++;
}
$this->data['downloads'][] = array(
'order_id' => $result['order_id'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'name' => $result['name'],
'remaining' => $result['remaining'],
'size' => round(substr($size, 0, strpos($size, '.') + 4), 2) . $suffix[$i],
'href' => $this->url->https('account/download/download&order_download_id=' . $result['order_download_id'])
);
}
}
$pagination = new Pagination();
$pagination->total = $download_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->http('account/download&page=%s');
$this->data['pagination'] = $pagination->render();
$this->data['continue'] = $this->url->https('account/account');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/download.tpl')) {
$this->template = $this->config->get('config_template') . '/template/account/download.tpl';
} else {
$this->template = 'default/template/account/download.tpl';
}
$this->children = array(
'common/header',
'common/footer',
'common/column_left',
'common/column_right'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
} else {
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_error'] = $this->language->get('text_error');
$this->data['button_continue'] = $this->language->get('button_continue');
$this->data['continue'] = $this->url->https('account/account');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/error/not_found.tpl')) {
$this->template = $this->config->get('config_template') . '/template/error/not_found.tpl';
} else {
$this->template = 'default/template/error/not_found.tpl';
}
$this->children = array(
'common/header',
'common/footer',
'common/column_left',
'common/column_right'
);
$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
}
}
public function download() {
if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->https('account/download');
$this->redirect($this->url->https('account/login'));
}
$this->load->model('account/download');
if (isset($this->request->get['order_download_id'])) {
$order_download_id = $this->request->get['order_download_id'];
} else {
$order_download_id = 0;
}
$download_info = $this->model_account_download->getDownload($order_download_id);
if ($download_info) {
$file = DIR_DOWNLOAD . $download_info['filename'];
$mask = basename($download_info['mask']);
$mime = 'application/octet-stream';
$encoding = 'binary';
// is the mask .pdf ? if so, process it here!
if (strtolower(substr($mask, -3)) == "pdf") {
$pdf = new PDF("p", "pt", "A4");
$pdf->SetAuthor("Someone");
$pdf->SetTitle("Something");
$pdf->SetFont("times", "", 10);
$pdf->SetTextColor(255,0,0);
$pagecount = $pdf->setSourceFile($file);
for($i=1;$i<=$pagecount;$i++)
{
$tplidx = $pdf->importPage($i);
$pdf->AddPage();
$pdf->useTemplate($tplidx);
}
$tmpfname = tempnam("/tmp", "PDF");
$pdf->Output($tmpfname, 'F');
$pdf->closeParsers();
if (!headers_sent()) {
header('Pragma: public');
header('Expires: 0');
header('Content-Description: File Transfer');
header('Content-Type: ' . $mime);
header('Content-Transfer-Encoding: ' . $encoding);
header('Content-Disposition: attachment; filename=' . ($mask ? $mask : basename($tmpfname)));
header('Content-Length: ' . filesize($tmpfname));
if (file_exists($tmpfname)) {
$file = readfile($tmpfname, 'rb');
print($file);
unlink($tmpfname);
} else {
exit('Error: Could not find file ' . $file . '!');
}
} else {
exit('Error: Headers already sent out!');
}
} else {
if (!headers_sent()) {
header('Pragma: public');
header('Expires: 0');
header('Content-Description: File Transfer');
header('Content-Type: ' . $mime);
header('Content-Transfer-Encoding: ' . $encoding);
header('Content-Disposition: attachment; filename=' . ($mask ? $mask : basename($file)));
header('Content-Length: ' . filesize($tmpfname));
if (file_exists($tmpfname)) {
$file = readfile($file, 'rb');
print($file);
} else {
exit('Error: Could not find file ' . $file . '!');
}
} else {
exit('Error: Headers already sent out!');
}
}
$this->model_account_download->updateRemaining($this->request->get['order_download_id']);
} else {
$this->redirect($this->url->https('account/download'));
}
}
}
?>
Of course this would be better if it was say, the user's name and email address. The SQL is a little beyond me. Anyone care to suggest a fix?
What did you do to get your system to upload PDF files. I am trying to upload PDF files to the download section and it wont allow me to do pdf files.
Im sorry but excuse my ignorance, but who is that done?antijoe wrote:Check the directory permissions of the /download directory are 755
I have installed this mod and many other before it, but I am getting an error on the PDF download attempt. Dumb question... the PDF that I uploaded is password protected so it cannot be modified other than print and view. My guess is that this PDF stamping mod must "open" the PDF in order to stamp it, yes??
If yes, then the PDF is left vulnerable to modification because then there is not security. The end-user simply opens the stamped PDF in Adobe Pro and "loses" the headers and footers. Am I wrong or is the error I get unrelated to a "secure" PDF.
Thanks
If yes, then the PDF is left vulnerable to modification because then there is not security. The end-user simply opens the stamped PDF in Adobe Pro and "loses" the headers and footers. Am I wrong or is the error I get unrelated to a "secure" PDF.
Thanks
kksoft wrote:I have installed this mod and many other before it, but I am getting an error on the PDF download attempt. Dumb question... the PDF that I uploaded is password protected so it cannot be modified other than print and view. My guess is that this PDF stamping mod must "open" the PDF in order to stamp it, yes??
If yes, then the PDF is left vulnerable to modification because then there is not security. The end-user simply opens the stamped PDF in Adobe Pro and "loses" the headers and footers. Am I wrong or is the error I get unrelated to a "secure" PDF.
Thanks
That is the same issue I am having now. Im trying to figure out how to crack the passwords or open it with another program
I found this program to unlock PDF files.http://www.ehow.com/how_4735211_unlock- ... ndows.html
Im waiting to see if this fixes my upload issues.
Im waiting to see if this fixes my upload issues.
Hi,
This its something else ..
If you want to do this on the fly.. hm.. must think and also work
The easy way: 1 unlock your file -> upload into o.cart -> download
Regards
So the PDF Protected Documents its out.
Please see:
http://www.opencart.com/index.php?route ... ion_id=477
This its something else ..
If you want to do this on the fly.. hm.. must think and also work
The easy way: 1 unlock your file -> upload into o.cart -> download
Regards
So the PDF Protected Documents its out.
Please see:
http://www.opencart.com/index.php?route ... ion_id=477
I am not a coder, but here is my vqmod update for opencart 1.5.3.1
for product http://www.opencart.com/index.php?route ... search=pdf
Hope it helps
for product http://www.opencart.com/index.php?route ... search=pdf
Hope it helps
Who is online
Users browsing this forum: No registered users and 74 guests