Step-by-Step Guide to Add QR Code to Document in Alfresco

The QR code is no longer a new term for techies as well as non-technical persons. Out of many possible applications of QR code, one is to apply it to the documents that have stored or associated information. For those who want a technical definition of a QR code, we can mention here what Wikipedia says: A QR code is an optical and machine-readable representation of data; here, the data describes something about the object that carries the QR code.

Alfresco, as a document management system, requires the documents to be printed with QR codes. These QR codes contain some associated data of the said documents.

We, at Tridhya Tech, have developed a solution wherein you can directly pick the document metadata from PDF files in the form of the QR code in Alfresco.

Here is the technical approach on how to generate a QR code in Alfresco:

  • Java action - To allow users to generate and decide where to place the QR code in the document
  • Evaluator - To show action only on PDF documents (share side class)
  • A Java PDF library (iText) - Provides classes and functions to edit PDF documents

Java Action

Create a Java class with following code at alfresco/src/main/java

 public class BarcodeQRCodePdfActionExecuter extends ActionExecuterAbstractBase {
	private static Log logger = LogFactory.getLog(BarcodeQRCodePdfActionExecuter.class);
	private ServiceRegistry serviceRegistry;

	public static final String PARAM_PAGE_NO = "page-no";

	public void setServiceRegistry(ServiceRegistry serviceRegistry) {
		this.serviceRegistry = serviceRegistry;

	protected void addParameterDefinitions(List paramList) {
		for (String s : new String[] {PARAM_PAGE_NO}) {
			paramList.add(new ParameterDefinitionImpl(s, DataTypeDefinition.TEXT, true, getParamDisplayLabel(s)));

	protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {

		logger.debug("Page No " + action.getParameterValue(PARAM_PAGE_NO));
		Map props = serviceRegistry.getNodeService().getProperties(actionedUponNodeRef);
		String qrCodeString = new String();
		for (Map.Entry entry : props.entrySet()){ 
            qrCodeString += entry.getKey().getLocalName()+" : "+entry.getValue()+"\n";
		ContentWriter writer = serviceRegistry.getContentService().getWriter(actionedUponNodeRef,
				ContentModel.PROP_CONTENT, true);
		ContentReader reader = serviceRegistry.getContentService().getReader(actionedUponNodeRef,
		int pageNo = Integer.parseInt((String) action.getParameterValue(PARAM_PAGE_NO));
		try {

			PdfReader pdfReader = new PdfReader(reader.getContentInputStream());
			PdfStamper stamper = new PdfStamper(pdfReader, writer.getContentOutputStream());
			PdfContentByte over = stamper.getOverContent(pageNo);
			BarcodeQRCode barcodeQRCode = new BarcodeQRCode(qrCodeString, 1, 1, null);
			Image qrcodeImage = barcodeQRCode.getImage();

		} catch (ContentIOException e) {

		} catch (IOException e) {

		} catch (DocumentException e) {


Create a separate at alfresco/src/main/amp/config/alfresco/module/${project-name}/context/ to register action class.


Create an extension module at share/src/main/amp/config/alfresco/web-extension/site-data/extensions/ in separate or existing xml file.

onActionFormDialogactionbarcodeQRCode-pdf create{node.nodeRef}alfresco.doclib.action.barcodeQRCodePdf.msg.successalfresco.doclib.action.barcodeQRCodePdf.msg.failure alfresco.barcodeQRCodePdf.evaluator.checkPDFFileType ID for the Repository Action that this form is associated with    

Create a properties file for Label at share/src/main/amp/config/alfresco/web-extension/messages/

 alfresco.doclib.action.barcodeQRCodePdf.label=QRCode Pdf
alfresco.doclib.action.barcodeQRCodePdf.msg.success=Pdf have been QRcoded.
alfresco.doclib.action.barcodeQRCodePdf.msg.failure=Problem in qrcoding Pdf, please contact Administrator
alfresco.doclib.action.barcodeQRCodePdf.form.field.pageNo=Page Number

Note: You have to add images for the action icon at


Evaluator (Shows action only on PDF document)

Create a separate with the following code at
iText Library

Add the following dependency to pom.xml to use this library.

12 aaaa  

That’s it for now! If you have any feedback or suggestions regarding this approach, we would love to hear from you. We certainly hope that this article will guide you when you need to address QR code document management requirement in Alfresco. Though you must have come across an online barcode generator, we believe that this technique will add value to the Alfresco development practice.

What’s more, as Alfresco deals with digitization projects, integration with Ephesoft helps you achieve OCR indexing, i.e. to extract values from the scanned documents and pushing it to the database. The application is widely used in Purchase Document Management and Pharmaceutical Document Management.

Tridhya Tech team would be happy to help! Please feel free to approach us for a free consultation of the high-level requirement understanding.


Top 8 Reasons Why You Need Alfresco Document Management System Read more
Alfresco Development


Alfresco Development: How It Helps Businesses and Why It's Beneficial

Learn about Alfresco development and its benefits for businesses. Discover how leveraging Alfresco can enhance efficiency and collaboration.

Alfresco ECM Consultants


Alfresco ECM Consultants Unveil Secrets to Success

Mastering Alfresco Development: Essential Tips for Success in ECM Solutions" provides crucial insights and strategies for developers to excel in creating robust ECM solutions using the Alfresco platform. With essential tips and best practices, this resource is indispensable for both novice and experienced developers seeking to harness Alfresco's full potential for ECM projects.

Transform Your Business With Digital Enterprise Solutions

Contact us

Our Offices


401, One World West, Nr. Ambli T-Junction 200, S P Ring Road, Bopal, Ahmedabad, Gujarat 380058


Kemp House 160 City Road, London, United Kingdom EC1V 2NX


Nürnberger Str. 46 90579 Langenzenn Deutschland


Level 36 Riparian Plaza, 71 Eagle Street, Brisbane, QLD 4000


4411 Suwanee Dam road, Bld. 300 Ste. 350 Suwanee GA, 30024


Cube Work Space, 24 Hans Strijdom Avenue, Cape Town


B 503 Sama Tower, Sheikh Zayed Road, United Arab Emirates

country-flag CANADA

34 Applegrove Ct. Brampton ON L6R 2Y8