Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] PDF data-sheet maker v.1.1


alverman

Recommended Posts

Hi All!

If you've got product names with the letter 'Å' or 'å' (like I do) you'll need to add them in catalog/pdf/pdf_datasheet_functions.php. In my file it's the lines 768-777. This probably goes for every 'odd' character and symbol out there...

function GenerateFilename($docfilename){
// Variable $docfilename kommt aus function ProductsDataSheet
global $languages_id;
//$find = array('/ä/','/ö/','/ü/','/ß/','/Ä/','/Ö/','/Ü/','/ /','/:/','/;/');
//$find = array('/ä/','/ö/','/ü/','/ß/','/Ä/','/Ö/','/Ü/','/ /','/[:;]/');
//$replace = array('ae','oe','ue','ss','Ae','Oe','Ue','_','');
$find = array('/å/','/ä/','/ö/','/ü/','/ß/','/Å/','/Ä/','/Ö/','/Ü/','/ /','/[:;]/','/\//');
$replace = array('aa','ae','oe','ue','ss','Aa','Ae','Oe','Ue','_','','-');
return preg_replace ($find , $replace, strtolower($docfilename) . '_l' . $languages_id . '.pdf'); 
}

//Micke

Link to comment
Share on other sites

  • 1 month later...
  • Replies 179
  • Created
  • Last Reply

Top Posters In This Topic

  • 11 months later...

I have a new version out 1.7: http://addons.oscommerce.com/info/1077

 

Since v1.6.4

------------

* Added most available options to the admin

* Added a few options to the Admin that didn't exist

* Eliminated unnecessary options from config file

* Multi-lingual ready

* Patched the "Divide by Zero" error when no image exists and "Keep Image Proportions" is set to "Yes"

* Further streamlined product_info link

* Streamlined and updated the code

* Removed the previously integrated code for the "options as images" addon; placed it in a separate folder

* Cleaned up the installation doc

* Added update doc

* Added screenshots

 

Scott

Link to comment
Share on other sites

Hi,

I`ve got the following prob with IE7:

Pushing the link for the datasheet doesn`t work?!

Example Site

Works fine in Opera and Firefox!

Mouseover shows the destination, but it`s unclickable...

Anyone else got the prob?

Thanks!

 

Your correct - I looked at it too... I'll look into it.

 

Scott

Link to comment
Share on other sites

Here is the fix in catalog/product_info.php

 

replace this:

				<td align="center" valign="middle" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank"><table border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle">' . TEXT_PDF_DOWNLOAD1 . ' <td><td valign="middle">' . tep_image('images/pdf.png',TEXT_PDF_DOWNLOAD2) .'</td></tr></table></a>'; ?></td>

 

with this:

				<td align="center" valign="middle" class="main"><?php echo '<table border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle"><a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank">' . TEXT_PDF_DOWNLOAD1 . '</a> <td><td valign="middle"><a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank">' . tep_image('images/pdf.png',TEXT_PDF_DOWNLOAD2) .'</a></td></tr></table>'; ?></td>

 

Scott

Edited by olsonsp4c
Link to comment
Share on other sites

Thank you for the contribution. I have it working 99%.

 

First, the code in 1.71 for the link in product_info.php is still buggy... the following is working for me (got rid of IE errors). I think you were just missing a / on a </td>

<!-- Begin PDF Datasheets //-->				

			<td align="center" valign="middle" class="main"><?php echo '<table border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle"><a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank">' . TEXT_PDF_DOWNLOAD1 . '</a> </td><td valign="middle"><a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank">' . tep_image('images/pdf.gif',TEXT_PDF_DOWNLOAD2) . '</a></td></tr></table>'; ?></td>	

<!-- End PDF Datasheets //-->

 

The 2 issues I am seeing are:

1. The top half of product descriptions is not alwsys being included. Sometimes it is, sometimes not. I've read this entire thread and have seen the same issue but no definitive solution. Anyone?

2. Certain special characters like TM show as & #8442;, and single quotes as & #8221; etc.... Where can I modify the special character handling?

 

Thanks for any help or a kick in the right direction.

-Dave

Link to comment
Share on other sites

Thank you for the contribution. I have it working 99%.

 

First, the code in 1.71 for the link in product_info.php is still buggy... the following is working for me (got rid of IE errors). I think you were just missing a / on a </td>

<!-- Begin PDF Datasheets //-->				

			 <td align="center" valign="middle" class="main"><?php echo '<table border="0" cellspacing="0" cellpadding="0"><tr><td valign="middle"><a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank">' . TEXT_PDF_DOWNLOAD1 . '</a> </td><td valign="middle"><a href="' . tep_href_link(FILENAME_PDF_DATASHEET, 'products_id=' . $product_info['products_id']) .'" target="_blank">' . tep_image('images/pdf.gif',TEXT_PDF_DOWNLOAD2) . '</a></td></tr></table>'; ?></td>	

<!-- End PDF Datasheets //-->

 

The 2 issues I am seeing are:

1. The top half of product descriptions is not alwsys being included. Sometimes it is, sometimes not. I've read this entire thread and have seen the same issue but no definitive solution. Anyone?

2. Certain special characters like TM show as & #8442;, and single quotes as & #8221; etc.... Where can I modify the special character handling?

 

Thanks for any help or a kick in the right direction.

 

the link is fixed in 1.72 - issue 2 is addressed in 1.72 - i've sometimes seen formatting issues IF you don't either have the product name, manufacturer, or model number before the description - one of them must be selected... don't know why it doesn't include part of the description...

 

Scott

Link to comment
Share on other sites

Thank you for the contribution.

I have the following problem. The header of the pdffile is not correct. It is neither the category nor the product name. Everything else is fine.

 

Ines

 

did you verify that the logo name you uploaded is in the catalog/images file and that the name is EXACTLY the same in the Admin as the file you uploaded - i.e. logo.jpg NOT logo.JPG that there are no spaces in the name of the logo: my_logo.jpg NOT my logo.jpg ?

 

Scott

Link to comment
Share on other sites

hello,

 

logo is ok, but the line with categorie and product_name is only grey and ">" is on the grey line.

 

Ines

 

Well, it works on my site so I can't really give you any pointers there... this is the code that inserts that in pdf\pdf_datasheet_functions.php

 

First here:

 

	// Header Text
$this->Ln(0);
$path = $this->GetPath($products_id, $languages_id);
$products_name = $this->ProductsName($products_id, $languages_id);
$product_path_font=explode(",",PDF_PRODUCT_PATH_FONT);
$this->SetFont($product_path_font[0],$product_path_font[1],$product_path_font[2]);
$header_color_table=explode(",",PDF_HEADER_COLOR_TABLE);
$this->SetFillColor($header_color_table[0], $header_color_table[1], $header_color_table[2]);
$this->Cell(0,6,$path .' > '. $products_name,0,0,'L',1);
$this->Ln(10);

 

And the queries are later here:

 

  function GetPath($products_id, $languages_id) {
$cPath = '';
$cat_count_sql = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . $products_id . "'");
$cat_count_data = tep_db_fetch_array($cat_count_sql);
if ($cat_count_data['count'] == 1) {
  $categories = array();
  $cat_id_sql = tep_db_query("select pc.categories_id, cd.categories_name from " . TABLE_PRODUCTS_TO_CATEGORIES . " pc,  " . TABLE_CATEGORIES_DESCRIPTION . " cd where
							  pc.products_id = '" . $products_id . "' and
							  cd.categories_id = pc.categories_id and
							  cd.language_id = '" . $languages_id . "'");
  $cat_id_data = tep_db_fetch_array($cat_id_sql);
  tep_get_parent_categories($categories, $cat_id_data['categories_id']);
  $size = sizeof($categories)-1;
  for ($i = $size; $i >= 0; $i--) {
	if ($cPath != '') $cPath .= ' > ';
	$parent_id_sql = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where
									  categories_id = '" . $categories[$i] . "' and
									  language_id = '" . $languages_id . "'");
	$parent_id_data = tep_db_fetch_array($parent_id_sql);
	$cPath .= $parent_id_data['categories_name'];
  }
  if ($cPath != '') $cPath .= ' > ';
  $cPath .= $cat_id_data['categories_name'];
}
return $cPath;
 }

 function ProductsName($products_id, $languages_id) {
$products_name_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where
									 products_id = '" . $products_id . "' and
									 language_id = '" . $languages_id . "'");
$products_name = tep_db_fetch_array($products_name_query);
return $products_name['products_name'];
 }

 

If you've modified any of the defaults in your store, this would cause an error - I'm sure it could be other things as well, I just don't know what.

 

Scott

Link to comment
Share on other sites

The only suggestion that I could have is that you copy the english files back to your store and see if that effects anything. You can disable the language in your admin, so they don't need to be deleted anyways. As it works on more than 20 stores that I know of personally, and I can not duplicate the issue, it is difficult to further troubleshoot. Is anyone else out there having this issue that can help him?

 

Scott

Link to comment
Share on other sites

I create the database new with oscommerce.sql for oscommerce-2.2rc2a and I do only the changes for this contrib. But the result is the same.

I use MySQL 5.1 and PHP 5.2.3 on Vista with IIS7. It seems, that the two functions working with no error and with no result.

 

Ines

Link to comment
Share on other sites

2 ideas:

 

1. Check catalog/pdf/pdf_datasheet_functions.php:

 

define('FPDF_FONTPATH','pdf/font/');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PDF_DATASHEET);
require('pdf/pdf_datasheet_config.php');
require('pdf/fpdf/fpdf.php');

 

make sure these lines are configured properly...

 

2. Check catalog/includes/configure.php:

 

  define('HTTP_SERVER', 'http://www.your-domain.com');
 define('HTTPS_SERVER', 'https://www.your-domain.com');
 define('ENABLE_SSL', true); // if you have SSL (true)
 define('HTTP_COOKIE_DOMAIN', 'www.your-domain.com');
 define('HTTPS_COOKIE_DOMAIN', 'www.your-domain.com');
 define('HTTP_COOKIE_PATH', '/');
 define('HTTPS_COOKIE_PATH', '/');
 define('DIR_WS_HTTP_CATALOG', '/');
 define('DIR_WS_HTTPS_CATALOG', '/');
 define('DIR_WS_IMAGES', 'images/');
 define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/');
 define('DIR_WS_INCLUDES', 'includes/');
 define('DIR_WS_BOXES', DIR_WS_INCLUDES . 'boxes/');
 define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
 define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
 define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
 define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');

 define('DIR_WS_DOWNLOAD_PUBLIC', 'pub/');
 define('DIR_FS_CATALOG', '/home/yourdomain/www/www/'); // could also be something like /home/yourdomain/www/public_html/
 define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
 define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');

 

make sure these are configured properly...

 

if this doesn't work, message me with your website address and I'll take a quick look too.

 

Scott

Link to comment
Share on other sites

i installed the last version and got this message error :FPDF error: Some data has already been output, can't send PDF file

here are the debuf infos :

 

Notice: Undefined variable: specials_price in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 497

 

Notice: Undefined variable: specials_expires in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 498

 

Notice: Undefined property: angle in v:\easyphp\www\ms2fr\shop\pdf\fpdf\fpdf.php on line 1070

 

Notice: Use of undefined constant IMAGE_KEEP_PROPORTIONS - assumed 'IMAGE_KEEP_PROPORTIONS' in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 210

FPDF error: Some data has already been output, can't send PDF file

 

any informations would help :-)

MS2

Link to comment
Share on other sites

i installed the last version and got this message error :FPDF error: Some data has already been output, can't send PDF file

here are the debuf infos :

 

 

 

any informations would help :-)

 

I missed one definition - sorry - in line 248 of pdf_datasheet_functions.php:

 

Find this:

 

IMAGE_KEEP_PROPORTIONS

 

REPLACE with this:

 

PDF_IMAGE_KEEP_PROPORTIONS

 

After you do this, I'll be it all gets fixed...

 

Scott

Link to comment
Share on other sites

i dir it here is now what i got as error :

 

Notice: Undefined variable: specials_price in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 499

 

Notice: Undefined variable: specials_expires in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 500

 

Notice: Undefined property: angle in v:\easyphp\www\ms2fr\shop\pdf\fpdf\fpdf.php on line 1070

 

Notice: Use of undefined constant FOOTER_CELL_BG_COLOR - assumed 'FOOTER_CELL_BG_COLOR' in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 129

 

Notice: Undefined offset: 1 in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 130

 

Notice: Undefined offset: 2 in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 130

 

Notice: Use of undefined constant FOOTER_CELL_TEXT_COLOR - assumed 'FOOTER_CELL_TEXT_COLOR' in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 131

 

Notice: Undefined offset: 1 in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 132

 

Notice: Undefined offset: 2 in v:\easyphp\www\ms2fr\shop\pdf\pdf_datasheet_functions.php on line 132

FPDF error: Some data has already been output, can't send PDF file

MS2

Link to comment
Share on other sites

i dir it here is now what i got as error :

 

I'd unstall the addon and re-install from scratch - delete all files you uploaded and directories - reupload fileset and insert edits from v1.7.3

 

I say this because there are no references to the database entries FOOTER_CELL_BG_COLOR or FOOTER_TEXT_BG_COLOR in the pdf_datasheet_functions.php file at all.

 

Scott

Link to comment
Share on other sites

  • 1 month later...

Hello.

 

Recently installed this contrib, and find it quite handy. There are a few cosmetic items I'll need to address (logo image sizes, fonts sizes, etc), but most of these have been at least addressed in earlier posts on this thread.

 

However, I'm stuck with the issue of tables within the product descriptions. Most of my products contain part numbers and corresponding dimensions. The content of the table is being output, but is not retaining the formatting - it's all scrunched (sorry for the non-technical term) into the center of the page, in a column approximately 1" in width, and results in the table content being cascaded for pages.

 

Complicating matters, each of the tables may have different layouts, due to the nature of the product's physical attributes.

 

The table as part of the description works well when viewed online, as it automatically adjusts to display settings.

 

I found a reference to Tables with MultiCell on fpdf.org. Is this the only way to do it, with some new tables to control table/column layouts etc?

 

Products also have other images incorporated into the description that are not being displayed...I'm considering an additional image contribution. Would these be included in the rendered PDF, and if so, could I make a separate image of the table data, and output it as well?

 

Thanks

Link to comment
Share on other sites

  • 7 months later...

hello,

 

logo is ok, but the line with categorie and product_name is only grey and ">" is on the grey line.

 

Ines

 

I have the identical issue. All is working except the category and product_name is only grey and ">"

 

Using ver 1.73

php5.1.6

MySQL 5.0.77

Linux 2.6.18-164.2.1.el5

Apache2.2.3

 

BTW - whoever posted 1.74 - your fix is wrong and broke my store - could just be me. 1.73 works (mostly)

Edited by Roaddoctor

-Dave

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...