We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bar Code Generator on Files on the fly

i have a requirement from a customer to have the feature of uploading a file (Microsoft Office Document - Images - PDF) and then the system should generate a bar code and print it on the uploaded file
do you have a library to achieve this requirement?

we are using java


You may use Aspose.BarCode for Java API to generate your desired barcode and embed it (image) into your uploaded PDF file using Aspose.PDF for Java.

See the documents in the section on how to generate barcodes using Aspose.BarCode for Java. Moreover, see the document on how to add/insert images into an existing PDF document using Aspose.PDF for Java for your reference.

OK can this be done to Microsoft Office Documents and images (png - jpg - …etc) as well?

Yes, you can save the barcode as an image (PNG, BMP, JPEG, EMF, SVG, GIF, TIFF) and then insert this image into Microsoft Office Documents or wherever images can be inserted as per your requirement.

do i need a separate library to insert that image into Microsoft Office documents and images?
i need this to be done programmatically


Yes, you would need relevant Aspose APIs for different MS Office documents.

For example, you will use Aspose.Words for Java API to insert the barcode image into MS Word documents.
Similarly you will use Aspose.Slides for Java API to insert the barcode image into PPT/PPTX files.
…and so on.

Please check Aspose Java APIs here in Aspose.Total for Java package for your complete reference.

i generated the bar code successfully
but when i try to add the image i was stuck in determining the image coordinates in order to be printed on first page at top left corner
after several trial and error i used this code
mender.addImage(“d:\barcodeCaption.jpg”, 1, 0, 0, 50, 1550);
this is very strange since the pdf page size is 612*792, so i do not know from where this value (1550) comes
how can i put the coordinate values to make the image at top left corner dynamically as PDF page size may differ from one file to another?


In case you want to add the image at the top-left corner, you can add it using ImageStamp which provides the capability to specify the alignment of the image. Furthermore, the PDF follows a coordinating system that starts from bottom-left which means (0,0) and the measurement unit in Aspose.PDF is Point where 72 Points = 1 Inch.

Please try using ImageStamp and feel free to let us know by sharing sample source files and code snippet in case you still face any issues.