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
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; } @Override protected void addParameterDefinitions(List paramList) { for (String s : new String[] {PARAM_PAGE_NO}) { paramList.add(new ParameterDefinitionImpl(s, DataTypeDefinition.TEXT, true, getParamDisplayLabel(s))); } } @Override 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, ContentModel.PROP_CONTENT); 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(); qrcodeImage.setAbsolutePosition(10,10); over.addImage(qrcodeImage); stamper.close(); pdfReader.close(); } catch (ContentIOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } }
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
share/src/main/amp/web/components/documentlibrary/actions/
Evaluator (Shows action only on PDF document)
Create a separate with the following code at
share/src/main/amp/config/alfresco/web-extension/
application/pdf
iText Library
Add the following dependency to pom.xml to use this library.
com.itextpdf itextpdf 5.0.6
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 moreThe technology has been a pioneer in speeding up the data analysis of customers for enterprises.
17 Jul 2024
Learn about Alfresco development and its benefits for businesses. Discover how leveraging Alfresco can enhance efficiency and collaboration.
17 Jul 2024
Mastering Alfresco Development: Essential Tips for Success in ECM Solutions” provides crucial insights and strategies for developers to excel in…
17 Jul 2024
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
34 Applegrove Ct. Brampton ON L6R 2Y8
We use cookies to improve your browsing experience.
OKAYThis website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.