Developers

  1. Modify Css / Styles / Layout
    1. Layout (Menu Items, General)
    2. Frontend Css
    3. Admin Css
  2. Templates
    1. Pages
      1. page.order.php
      2. page.confirm-order.php
      3. page.processing.php
      4. page.thankyou.php
      5. page.cancelled.php
      6. page.purchase-history.php
    2. Order
      1. itemised.php
      2. summary.php
      3. transaction_details.php
    3. Global
      1. orderinfo.php (Widget)
      2. openingtimes.php (Widget)
      3. additives.php (Widget)
      4. navigation.list.php (Widget)
      5. navigation.dropdown.php (Widget)
      6. search.php (Widget)
      7. totals.php (Widget)
      8. pickup_choice.php (Mixed)
      9. login.php (Module)
      10. profile.register.php (Module)
      11. profile.update.php (Module)
      12. pages.pickup_note.php (Module)
      13. formfields.inputs.php (Module)
      14. formfields.values.php (Module)
    4. Cart
      1. cart.container.php
      2. cart.shopclosed.php
      3. cart.empty.php
      4. cart.pickup_note.php
      5. cart.checkout_button.php
      6. cart.empty_cart_button.php
      7. cart.minimum_order.php
      8. minicart.php
    5. Loop (Menu Items)
      1. header.php
      2. no_results.php
      3. posts.title.php
      4. posts.thumbnail.php
      5. posts.prices.php
      6. posts.content.php
      7. posts.permalink.php
      8. additives.php
      9. pagination.php
      10. theme-wrapper.php
    6. Search Results
      1. search.php
    7. Single Menu Item
      1. single.php
    8. functions.php
  3. Filters, Actions, Functions
    1. Global WPPizza functions
    2. WPPizza options (Filter)
    3. Currency (Filter)
    4. After every order (Action)
    5. Getting orders (Function)
  4. Constants
    1. Admin Name
    2. Admin Menu Icon
    3. SORT_ITEMS_AS_ADDED
    4. SINGLE_PERMALINK_VAR
    5. WIDGET_CSS_CLASS
    6. PLAINTEXT_LINE_LENGTH
    7. ADMIN_{CONSTANTS}
    8. DEV_{CONSTANTS}
    9. INSTALL_{CONSTANTS}
    10. TRANSACTION_{CONSTANTS}
  5. Codesnippets
    1. Create your own sales report
    2. Order history - todays orders
    3. Email/Print templates
    4. Email Subject Line
    5. Add attachment to email
    6. On order status update
    7. Unconfirmed orders
    8. Customise order id
    9. Changing post type arguments
    10. Gateway filter frontend
    11. Users previous orders
    12. Dynamic menu item prices
    13. Update prices in bulk
    14. Prices output loop
    15. Pickup opening times
    16. Checkout Formfields
    17. Additional validation function
  6. Extensions / Gateways
    1. Add Ingredients
    2. Autoprint
    3. Confirm | Reject | Notify
    4. Coupons and Discounts
    5. Cross-Sells
    6. Delivery By Post/Zipcode
    7. Goodcom Printer
    8. Mailinglists
    9. Pdf Invoices
    10. Preorder
    11. Gateway - Stripe

6.9.Pdf Invoices

CSS Declaration Examples and Filters available using WPPizza – Pdf Invoices

Using your own font (this must be a truetype font – see also “Know Issues” below)

To use your own font, follow the guide below:

  • Go to “WPPizza -> Settings-> PDF Invoices”
  • Make sure the template selected is of “Format: HTML” (additional CSS declarations will be ignored for “Plaintext” Templates)
  • The font url used in your CSS must be the ABSOLUTE PATH to your font.ttf
  • If necessary, ensure you ask for permission to utilise the font (if using a commercial font for example)
  • Set “Global – PDF Font [Html]” to “– Custom Font –“
  • Enter your font declaration – as outlined in the below CSS example – and preview the PDF output
  • If your font selected is not being used, make sure you clear the font cache by clicking on the “Clear Font Cache” button (especially and every time you change the path to the font you want to use)
  • If you are happy with the display/output of the PDF, Save your settings
	/* 
	 CSS example:
	 using an invented myfont.ttf / myfont-bold.ttf / myfont-italic.ttf /myfont-italicbold.ttf  
	 for the relevant font-weights. 
	 If there is only a myfont.ttf (and no distinct bold/italc etc .ttf) use that instead for all src urls
	*/
	/* src:url must be an ABSOLUTE path to a TRUETYPE font */ 
	@font-face{
		font-family: "MyFont"; 
		font-style: normal; 
		font-weight: normal; 
		src: url("[absolute/server/path/to]/myfont.ttf") format("truetype");
	}
	@font-face{
		font-family: "MyFont"; 
		font-style: normal; 
		font-weight: bold; 
		src: url("[absolute/server/path/to]/myfont-bold.ttf") format("truetype");
	}
	@font-face{
		font-family: "MyFont"; 
		font-style: italic; 
		font-weight: normal; 
		src: url("[absolute/server/path/to]/myfont-italic.ttf") format("truetype");
	}
	@font-face{
		font-family: "MyFont"; 
		font-style: italic; 
		font-weight: bold; 
		src: url("[absolute/server/path/to]/myfont-italicbold.ttf") format("truetype");
	}
	
	/*
	 overriding previous font faces for all elements 
	 (!important might not always be necessary here, but wont do much harm) 
	*/
	html,body,table,tbody,tr,td,th,span,div{
		font-family:'MyFont' !important;
	}

Known issues using fonts:

  • Not all fonts will support all character sets / languages. Many fonts simply do not have character support for Asian/Non-Western languages or provide support for the default icons in the WPPizza – Add Ingredients” extension for half/half, quarters (If used). Therefore, if you see a ‘?’ or some square boxes in your pdf output instead of the appropriate character, you will have to use a different font I’m afraid (or use the inbuilt ones into the plugin if that is an option)

Adding additional CSS

Note: Any additional CSS entered in the textbox will only be applied to “Format:HTML” templates.

  • Many, but not all, possible CSS that would normally be valid for html documents will be understood by the dompdf library in use. KEEP IT SIMPLE (and use valid css)
  • For security reasons, any images you use in your CSS MUST reside on the same domain.
  • To view the html elements from which the PDF will be generated, use the preview button next to the CSS textarea and your browsers element inspector to find the element you wish to target
  • For font-sizes in particular, I recommend you use relative sizes like ‘%’ instead of pixels
  • In some cases you might have to add ‘!important’ to your css
  • If you wish, you can also enter these declarations directly into the css are for the print template you are using. However, they would then also apply if you choose to use this template for other purposes (though this could be prevented from prefixing every declaration with body#wppizza_pdfinv which is only applied when generating these PDFs)
/* Example - adding a background image to your header - left aligned */
#header{
	background-image:url('http[s]://www.yourdomain.com/[my/server/path]/myimage.png');
	background-repeat: no-repeat;
	background-position: left;
}
//Note: "background-size" is not supported, make sure you size your image according to your requirements. Images must reside on the same domain.
/* Examples - changing margins */
	body{margin:0 !important}//zero margin
	body{margin:2cm 1cm !important}//top,bottom 2cm | left,right 1cm
/* Example - making fontsizes bigger/smaller/bold of a particular element */
	#overview #order_id td {font-size:50%}//making order id (if enabled) smaller
	#summary #total td {font-weight:bold}//bolding the "total" in the summary
/* 
	etc etc , you get the idea. if necessary, you might have to add !important in some cases, depending on what your particular scenario
*/
	
/* 
	Targeting the footer (which is not visible in the css previews but will be rendered in the PDFs)
	you will most likely need an !important here to override the default of 
	color:#666666; text-align:center; font-size:80% 
	
	the "position" is dynamic depending on paper margins but is by default similar to
	position: fixed; bottom: 0.75cm; left: 0.75cm; right: 0.75cm;
	if you want to override it
*/
	footer{color:red !important}

/* Example - background image for refunded orders - images must be on the same domain */
	body.payment-refunded{
		background-image:url('http[s]://www.yourdomain.com/[my/server/path]/refunded.png');
		background-repeat: no-repeat;
		background-position: center;
	}

/* Example - background image prepaid or delivered status - image must be on the same domain */
	body.payment-prepaid,body.order_status-delivered{
		background-image:url('http[s]://www.yourdomain.com/[my/server/path]/paid.png');
		background-repeat: no-repeat;
		background-position: center;
	}

/* 
	other statuses that might be available depending on your specific settings (this follows the status set for each order in the order history):
	
	body.payment-on_delivery{}
	body.order_status-new{}
	body.order_status-acknowledged{}
	body.order_status-on_hold{}
	body.order_status-processed{}
	body.order_status-custom_1{}
	body.order_status-custom_2{}
	body.order_status-custom_3{}
	body.order_status-custom_4{}
*/

//Note: "background-size" is not supported, make sure you size your image according to your requirements. Images must reside on the same domain.

Enabling other inbuilt PDF formats using filter: ‘wppizza_pdfinv_format’

Additional formats are available by using the filter as follows:

@param: array
@return: array

add_filter('wppizza_pdfinv_format', 'myprefix_pdfinv_format');
function myprefix_pdfinv_format($format){
	/* adding A5 */
	$format['A5'] = array(
		'label' => 'A5', //label
		'page_margin' => array(0.5, 0.5), //top, left margin (in cm)
		'font_size' => array(7, 7) //font size - in pt (plaintext, html). the inbuilt A4/letter/legal format use 8pt, if omitted will default to dompdfs default of 12pt
	);

return $format;
}

full list of formats available with suggested margins/font sizes you could use in the function above

	// A Format
	$format['A3'] = array('label' => 'A3', 'page_margin' => array(0.5, 0.5), 'font_size' => array(10, 10));
// 	$format['A4'] = array('label' => 'A4', 'page_margin' => array(0.5, 0.5), 'font_size' => array(8, 8));/* inbuilt into plugin */
	$format['A5'] = array('label' => 'A5', 'page_margin' => array(0.5, 0.5), 'font_size' => array(7, 7));
	$format['A6'] = array('label' => 'A6', 'page_margin' => array(0.5, 0.5), 'font_size' => array(6, 6),);
	$format['A7'] = array('label' => 'A7', 'page_margin' => array(0.5, 0.5), 'font_size' => array(4.5, 4.5),);
	$format['A8'] = array('label' => 'A8', 'page_margin' => array(0.5, 0.5), 'font_size' => array(3, 3),);
	$format['A9'] = array('label' => 'A9', 'page_margin' => array(0.5, 0.5), 'font_size' => array(2, 2),);
	$format['A10'] = array('label' => 'A10', 'page_margin' => array(0.5, 0.5), 'font_size' => array(1.5, 1.5),);

	// B Format
	$format['B3'] = array('label' => 'B3', 'page_margin' => array(0.5, 0.5), 'font_size' => array(10, 10));
	$format['B4'] = array('label' => 'B4', 'page_margin' => array(0.5, 0.5), 'font_size' => array(8, 8));
	$format['B5'] = array('label' => 'B5', 'page_margin' => array(0.5, 0.5), 'font_size' => array(7, 7),);
	$format['B6'] = array('label' => 'B6', 'page_margin' => array(0.5, 0.5), 'font_size' => array(6.5, 6.5),);
	$format['B7'] = array('label' => 'B7', 'page_margin' => array(0.5, 0.5), 'font_size' => array(4.5, 4.5),);
	$format['B8'] = array('label' => 'B8', 'page_margin' => array(0.5, 0.5), 'font_size' => array(3, 3),);
	$format['B9'] = array('label' => 'B9', 'page_margin' => array(0.5, 0.5), 'font_size' => array(2, 2),);
	$format['B10'] = array('label' => 'B10','page_margin' => array(0.5, 0.5), 'font_size' => array(1.5, 1.5),);

	// C Format
	$format['C3'] = array('label' => 'C3', 'page_margin' => array(0.5, 0.5), 'font_size' => array(10, 10));
	$format['C4'] = array('label' => 'C4', 'page_margin' => array(0.5, 0.5), 'font_size' => array(8, 8));
	$format['C5'] = array('label' => 'C5', 'page_margin' => array(0.5, 0.5), 'font_size' => array(7, 7),);
	$format['C6'] = array('label' => 'C6', 'page_margin' => array(0.5, 0.5), 'font_size' => array(6.5, 6.5),);
	$format['C7'] = array('label' => 'C7', 'page_margin' => array(0.5, 0.5), 'font_size' => array(4.5, 4.5),);
	$format['C8'] = array('label' => 'C8', 'page_margin' => array(0.5, 0.5), 'font_size' => array(3, 3),);
	$format['C9'] = array('label' => 'C9', 'page_margin' => array(0.5, 0.5), 'font_size' => array(2, 2),);
	$format['C10'] = array('label' => 'C10', 'page_margin' => array(0.5, 0.5), 'font_size' => array(1.5, 1.5),);

	// Misc Standards
//	$format['letter'] = array('label' => 'Letter', 'page_margin' => array(0.5, 0.5), 'font_size' => array(8, 8));/* inbuilt into plugin */
//	$format['legal'] = array('label' => 'Legal', 'page_margin' => array(0.5, 0.5), 'font_size' => array(8, 8));/* inbuilt into plugin */
	$format['ledger'] = array('label' => 'Ledger', 'page_margin' => array(0.5, 0.5), 'font_size' => array(10, 10));
	$format['tabloid'] = array('label' => 'Tabloid', 'page_margin' => array(0.5, 0.5), 'font_size' => array(10, 10));
	$format['executive'] = array('label' => 'Executive', 'page_margin' => array(0.5, 0.5), 'font_size' => array(10.5, 10.5));
	$format['folio'] = array('label' => 'Folio');

	// Misc Fixed Sizes
	$format['8.5x11'] = array('label' => '8.5x11', 'page_margin' => array(0.5, 0.5),);
	$format['8.5x14'] = array('label' => '8.5x14', 'page_margin' => array(0.5, 0.5),);
	$format['11x17'] = array('label' => '11x17', 'page_margin' => array(0.5, 0.5),);

Adding custom formats using filter: ‘wppizza_pdfinv_custom_format’

If you wish to add your own custom format use the filter like so :

@param: array
@return: array

add_filter('wppizza_pdfinv_custom_format', 'myprefix_pdfinv_format_custom');
function myprefix_pdfinv_format_custom($format){
	$format['80mm_160mm'] = array(//use A-Za-z0-9 (whithout spaces) for the key
		'label' => 'My Format (80mmx160mm)',//set the label
		'paper_size' => array(0, 0, 226, 552),//in points (example here equates to 80mm x 160mm)
		'page_margin' => array(0.25, 0.25),//page_margin in cm (top, left)
		'orientation' => 'portrait',//portrait or landscape
		'font_size' => array(5, 5),//fontsizes - in points - for plaintext,html. omit for default of 12pt (necessity depends on paper size set )
	);

return $format;
}

Suggest Edit

documentor id 5