Alfresco
When the world is heading towards digitization, a barcode is no longer a new term for the enterprises. Tracking and storing information about goods, from individual items to large stocks of millions of items, barcode has provided ease and relief to the system. Barcode allows you to accurately track large stocks and also look up any single piece of merchandise in a matter of second. There are many other cases where the barcode is applied to the documents. We, at Tridhya Tech, have come up with the solution to add the barcode to the document stored in the Alfresco system.
Here is the technical approach on how to generate a barcode in Alfresco. If you want to explore the QR code, then please visit this link.
1.Java Action
public class BarcodePdfActionExecuter extends ActionExecuterAbstractBase { private static Log logger = LogFactory.getLog(BarcodePdfActionExecuter.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)); String barcodeString = "abcd0001"; 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(inputStream); PdfStamper stamper = new PdfStamper(pdfReader, outputStream); PdfContentByte over = stamper.getOverContent(1); Barcode128 barcode128 = new Barcode128(); barcode128.setCode(barcodeString); barcode128.setCodeType(Barcode.CODE128); Image code128Image = barcode128.createImageWithBarcode(over, null, null); code128Image.setAbsolutePosition(10,10); over.addImage(code128Image); stamper.close(); pdfReader.close(); } catch (ContentIOException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } } }
alfresco/src/main/amp/config/alfresco/module/${project-name}/context/ to register action class.
share/src/main/amp/config/alfresco/web-extension/site-data/extensions/ in separate or existing xml file.
icon=”barcode” type=”javascript”
label=”alfresco.doclib.action.barcodePdf.label”>
onActionFormDialog
action
barcode-pdf
create
{node.nodeRef}
alfresco.doclib.action.barcodePdf.msg.success
alfresco.doclib.action.barcodePdf.msg.failure
alfresco.barcodePdf.evaluator.checkPDFFileType
ID for the Repository Action that this form is associated with
label-id=”alfresco.doclib.action.barcodePdf.form.field.pageNo”>
share/src/main/amp/config/alfresco/web-extension/messages/
alfresco.doclib.action.barcodePdf.label=Barcode Pdf alfresco.doclib.action.barcodePdf.msg.success=Pdf have been barcoded. alfresco.doclib.action.barcodePdf.msg.failure=Problem in barcoding Pdf, please contact Administrator alfresco.doclib.action.barcodePdf.form.field.pageNo=Page Number
share/src/main/amp/web/components/documentlibrary/actions/
2.Evaluator
share/src/main/amp/config/alfresco/web-extension/
parent=”evaluator.doclib.action.isMimetype”>
application/pdf
3. A Java PDF library (iText)
Add the following dependency to pom.xml to use this library.
com.itextpdf
itextpdf
5.0.6
Feel free to contact us if there is any help you need while executing this code.
Alfresco
Discover how Alfresco ECM revolutionizes insurance operations with seamless document management, enhanced compliance, and improved efficiency—empowering your firm to deliver…
28 Oct 2024
Alfresco
Transform your law firm with Alfresco ECM. Streamline workflows, boost efficiency, and go digital. Embrace change now or risk falling…
25 Sep 2024
Alfresco
Quick Summary: Due to technological advancements like IoT, digital transactions, social media, cloud computing, and others, companies need vast amounts…
13 Aug 2024
Alfresco
This blog outlines the top business advantages of implementing a Contract Lifecycle Management (CLM) system with
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.