Print Barcodes
print labels directly from salesforce list views or related lists using avery compatible label stock by default, this feature is available in contacts and assets tabs, supporting avery 5162 (letter) and avery 7163 (a4) formats customize these pages to adjust label layouts, encoded data, or support additional objects how it works capabilities supports qr codes and code 128 font size adjusts automatically if text exceeds label boundaries preconfigured layouts for text and code placement supported label size avery 5162 4" x 1 33" (101 6 mm x 33 8 mm) letter (8 5" x 11") avery 7163 3 9" x 1 5" (99 1 mm x 38 1 mm) a4 (8 3" x 11 7") recommendations test labels by saving to pdf first use formula fields to truncate long text (e g , left(field c, 20)) if resizing causes issues print barcodes from list view navigate to the contacts or assets tab select a list view check the boxes next to the records you want to print click the print labels button in the print dialog, choose to print immediately, save as pdf, or use other browser supported options for special margin configurations, preview the labels as a pdf before printing to avoid wasting label stock verify browser page settings (e g , margins, paper size) if switching between letter/a4 formats print from related list navigate to a record with a related list of contacts or assets (e g , an account) in the related list, check the boxes next to the records click the print labels button customize you can tailor the print labels feature to support additional objects, change label sizes, or modify the displayed data the feature uses visualforce pages ( printlabelscontact and printlabelsasset ), which you can clone and edit without requiring apex code or custom fields examine the source code of scananything’s printlabelscontact and printlabelsasset visualforce pages since there is no apex code or custom fields involved, you can clone directly without worrying about global keywords or having to add namespaces to fields the top part of the page contains the variables controlling the size, margins, code used \<apex\ variable var="pagesize" value="letter" /> \<apex\ variable var="pagemargintop" value="0 845in" /> \<apex\ variable var="width" value="4in" /> \<apex\ variable var="height" value="1 33in" /> \<apex\ variable var="marginright" value="0 1in" /> \<apex\ variable var="code" value="qrcode" /> \<apex\ variable var="codewidth" value="1 13in" /> \<apex\ variable var="codewheight" value="1 13in" /> \<apex\ variable var="codepadding" value="0 1in" /> \<apex\ variable var="textwidth" value="2 5in" /> \<apex\ variable var="textheight" value="1 13in" /> \<apex\ variable var="textpadding" value="0 1in" /> the bottom contains the layout and data to be printed on a single label or card \<apex\ repeat value="{!selected}" var="r"> 	\<div id="{!r id}" class="card"> 	 \<div class="code"> 	 \<canvas id="{!r id}" data text="{!r id}">please wait \</canvas> 	 \</div> 	 \<div class="text">\<span>\<b>{!r name}\</b> 	 {!r mailingstreet} 	 {!r mailingcity} 	 {!r mailingpostalcode} 	 {!r mailingstate}\</span>\</div> 	\</div> \</apex\ repeat> support new objects to adapt the feature for a different object go to setup > visualforce pages locate printlabelscontact or printlabelsasset and click clone name the cloned page and modify it as needed edit the first line of the visualforce page to reference your object for example \<apex\ page standardcontroller="yourobjectname" > create a list view button navigate to setup > object manager > \[your object] > buttons, links, and actions click new button or link set the label and name, select list button , and enable display checkboxes choose visualforce page as the content source and select your cloned page add the button to the layout go to setup > object manager > \[your object] > search layouts for salesforce classic edit the list view layout and add your new button for more details on visualforce pages, refer to the salesforce visualforce developer guide change label type to adjust the label size or paper type, modify the apex\ variable variables at the top of the visualforce page for example \<apex\ variable var="pagesize" value="letter" /> \<apex\ variable var="pagemargintop" value="0 845in" /> \<apex\ variable var="width" value="4in" /> \<apex\ variable var="height" value="1 33in" /> \<apex\ variable var="marginright" value="0 1in" /x> update these values to match your label specifications for avery 7163 on a4 paper, set pagesize to a4 and adjust dimensions accordingly avery 5162 comes as a 2x7 sheet with 4" x 1 33" letter (8 5" x 11") if you are implementing a new label, you will need to calculate dimensions for example, pagemargintop was calculated as (11 (7 1 33)) / 2 = 0 845 change encoded data to change the data encoded in qr codes or barcodes, update the data text attribute in the \<canvas> tag within the visualforce page for example, the sample pages use different fields for contact and asset \<! contact > \<canvas id="{!r id}" data text="{!r id}">please wait \</canvas> \<! asset > \<canvas id="{!r id}" data text="{!r serialnumber}">please wait \</canvas> the id attribute ({!r id}) should remain unique to identify each canvas element the data text attribute determines what’s encoded and can be set to any field on the record, such as {!r name} , {!r email} , or a custom field like {!r custom field c} also, ensure the selected field’s data is compatible with the code type for instance, numeric codes may not support text well you can also use salesforce formula expressions to handle special cases, such as {!blankvalue(r email, r account email c)} this formula encodes the contact’s email if available, or the account’s email as a fallback for more on formula syntax, see salesforce formula operators and functions change code type to switch between qr codes and code 128 barcodes, modify the code variable \<apex\ variable var="code" value="qrcode" /> set it to qrcode for qr codes or code128 for code 128 barcodes for changing dimensions, adjust codewidth and codeheight qr codes can encode more data than code 128 barcodes select a code type that supports your data’s length and character set the minimum unit for barcodes or 2d codes is a 1px bar or square, but to improve readability, the default setting uses a scale 2 parameter you can experiment with this value if necessary, though it may affect scan reliability view label outlines for testing to preview label boundaries in the browser, find this line in the visualforce page / outline 1px dashed; style for testing / uncomment it to outline 1px dashed; this line will display dashed outlines around each label for layout verification comment it out again before final printing change the information layout to adjust how information is displayed on the label, modify the content within the \<div> tag with the class card in the visualforce page for example \<div id="{!r id}" class="card"> \<! content here > \</div> the sample pages demonstrate different layouts contact sample includes a clearly defined code area (e g , qr code or barcode) and a text area with fields like {!r name} , {!r mailingstreet}, etc asset sample contains only a code area (e g , {!r serialnumber} encoded as a barcode), with no text area tweak the content inside the \<div class="card"> tag to achieve your desired layout for example, you could add or remove fields, adjust spacing, or change styling preview the changes in the browser to ensure the layout meets your needs if you need assistance, contact customer support through the salesforce help portal advanced customizations options for additional flexibility include print all records replace {!selected} with {!records} in the visualforce page to print all records in a list view without selecting checkboxes this aligns with the standardsetcontroller getrecords method, as opposed to getselected for checked records custom filters add an apex controller or extension to read parameters like apexpages currentpage getparameters() or the filter id with ssc getfilterid() , then apply any filters you want for guidance, see the salesforce apex developer guide