I am new to Aspose, I need help on the following in Java.
1. We are able to create a barcode (code 39) in PNG format and add it on an existing PDF, but the barcode is always at the bottom left corner, can you please advise how to add it on the upper corner, and is there any tool to help us find out the position. We downloaded the demo and uses
mendor.addImage(inImgStream, pages, 50, 50, 100, 100); for add.
2. We created the barcode in PNG format and added on a PDF, please advise the steps to read the barcode (how to read barcode from PDF).
You can use Aspose.BarCode to generate barcodes images and recognize barcodes
from images. To read barcodes from PDF, you need to extract images from the PDF
documents and feed them to BarCodeReader class for processing. I had asked the
staffs from pdf team to look in to this post and they will provide details soon.
I only have the evaluation copy of the software and we just realized that the evaluation copy doesnt recognize vertical barcode. Now we are able to add the barcode at a desired location. But we still cant read barcode from a PDF file (reading from PNG is successful).
Can you please provide some sample code on how to read the barcode from PDF? I am not sure if we need to exact barcode image (PNG format) from PDF first and then read it.
We also have scanned PDF and faxed TIFF files, does Aspose read barcode from TIFF files? How do we read barcode from a scanned PDF (in this case the barcode will be part of the PDF file).
As shared by Dean, Aspose.BarCode for Java have support for image formats like jpg, gif and png. To read barcodes from tiff and pdf files, you need different methods, which are listed below:
Pdf files: To read barcode from pdf files, you need a component that can extract images from pdf file. These images can then be passed to Aspose.BarCode for Java for barcode recognition. Sample code snippet is given below:
try { // set license License licPdfKit = new License(); FileInputStream stream = new FileInputStream(“e:\AsposeLicense.lic”); licPdfKit.setLicense(stream);
com.aspose.barcode.License licBarCode = new com.aspose.barcode.License(); licBarCode.setLicense(“e:\AsposeLicense.lic”);
Attached is our Java code and testing PDF, we are not able to exact the image which means that the counter "imageCount" and "imageCount2" are always printed as "1". They should be printed as "2" is the image can be exacted correctly.
The PDF was created from Aspose, the barcode was created as PNG and added on the PDF.
Thanks for posting the sample pdf file. I was also unsuccessful in extracting the images from it.
Could you please also post the code to insert these images in pdf file? I will also check it out with Aspose.Pdf.Kit team about image extraction issue.
I’m a support developer from Aspose.Pdf.Kit team. I would like to update you that I have tested the problem you’re having while extracting the images from the attached PDF; I’m also unable to extract the images.
There seems some problem with the image extraction feature of Aspose.Pdf.Kit for Java. I have logged this issue as PDFKITJAVA-10835 in our issue tracking system. Our development team will be looking into the matter and you’ll be updated via this forum as the issue is resolved.
If you have any further questions or concerns regarding Aspose.Pdf.Kit, you can post your questions in the Aspose.Pdf.Kit Forum. We’ll be pleased to help you out.
Hi Shahzad, I’d like to know how soon this will be resolved, is it in days or weeks? We already purchased Aspose and our development cycle will end 10/23, so please resolve this as soon as possible. Do you think this only happens to PDF? Should we use TIFF before the issue is fixed? Thanks.
Joanna
Hi Joanna,
I have logged this issue today and our development team hasn’t yet investigated the issue in detail. As the team will complete its investigation and share some time frame for this issue, I’ll update you accordingly. I would suggest that you use TIFF in the meanwhile.
We are unable to extract barcode from the TIFF file (see attached). We used the sample code provided in below link (mentioned earlier in this thread). Can you please advise what needs to be added?
We have below code for extracting barcode from TIFF (see attchment). Still not able to read. Please advise. Thanks.
System.out.println(System.getProperty("java.class.path"));
Iterator readers = javax.imageio.ImageIO.getImageReadersBySuffix("tiff");
String fileName="c:/w8imytaxform-vertical.tif";
if (readers.hasNext()) {
File fi = new File(fileName);
ImageInputStream iis = javax.imageio.ImageIO.createImageInputStream(fi);
TIFFDecodeParam param = null;
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", fi, param);
//Get the page count of the tiff image
int pageCount = dec.getNumPages();
ImageReader _imageReader = (ImageReader) (readers.next());//System.out.println(_imageReader);
if (_imageReader != null) {
_imageReader.setInput(iis, true);
//Feed each page to the BarCodeReader
System.out.println(_imageReader);
for (int i = 0; i < pageCount; i++) {
BufferedImage _bufferedImage = _imageReader.read(i);
BarCodeReader reader = new BarCodeReader(_bufferedImage, BarCodeReadType.Code39Standard);
//Read the barcodes in a single page
while (reader.read()) {
System.out.println(reader.getCodeText());
}
}
}
}
}
My classpath has the below jars. Still not able to read.
Could you please test the attached tif file with the above code and post the results, if there is problem reading the tiff file or recognizing the barcodes.
However, I tested the code with your sample tif file and there seems to be a problem with the recognition of barcode. I have sent the tif file to the development team for further analysis and will get back to you when its fixed.
We are able to read your TIFF file. Can you please advise how you generate the TIFF file? We created the TIFF file from MS imaging writter. I will try to read a TIFF file via fax.
I created a small program in .NET to create this multi-page tiff file. But, however, the barcode was generated by Aspose.BarCode itself, so there was no problem in recognition.
The barcode from your sample could not be read because it was scanned. However, it can read the barcodes from most of the scan documents. Could you please try to increase the quality/dpi for the document. It might work after that.
In the meanwhile, our development team is also working on the original tiff file sent by you.
We don't have a problem reading the barcode image which is generated directly from Aspose.BarCode itself. The problem is when we add that barcode on a TIFF or PDF, the new image with the barcode can not be recognized.
Can you please send over a scanned barcode document which can be read by your program? A document which has barcode and some context, not just a barcode by itself.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.