I use attached java program (based on your sample) to add barcode 39 to a 38 page PDF, and then try to read back the barcode, to verify the written bar code. Original PDF (38.pdf) and result PDF (38 with barcode) also attached (only the first 4 pages added because of trial license).
If you "run" (not debug) the program on eclipse 3.6.2 windows 7 professional 64-bit (shipped with IBM Integration Designer 7.5.1.1) as a stand-alone, no issue. Here is the output.
Total Pages = 38
Codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
page=1
page=2
page=3
page=4
barcode file saved.
Extracting image 1
Extracting image 2
codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
Extracting image 3
Extracting image 4
Extracting image 5
codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
Extracting image 6
Extracting image 7
Extracting image 8
codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
Extracting image 9
too many >10 images
Finish at the end.
But I will run into issues when trying to scale it up on a J2EE server.
1. It seems to me, based on ASPOSE sample here, you can only add barcode as an image to a PDF from java.io.FileInputStream.
java.io.FileInputStream imageStream = new java.io.FileInputStream(new java.io.File(image + ".png"));
Page page2 = pdfDocument1.getPages().get_Item(i+1);
page2.getResources().getImages().add(imageStream);
The API Add() here only has file input, not from a BarcodeBuilder --> BufferedImage directly in the memory. So I have to write the barcode to a tmp file, read it back into program and add to PDF, not efficient. Any advice here?
2. When I run the program, ASPOSE created tmp files for all the images from the source PDF on a local directory,
05/16/2013 10:02 AM 5,151 tmpbarcode1.png
05/16/2013 10:02 AM 41,271 tmpbarcode2.png
05/16/2013 10:02 AM 40,416 tmpbarcode3.png
05/16/2013 10:02 AM 5,151 tmpbarcode4.png
05/16/2013 10:02 AM 41,271 tmpbarcode5.png
05/16/2013 10:02 AM 30,796 tmpbarcode6.png
05/16/2013 10:02 AM 5,151 tmpbarcode7.png
05/16/2013 10:02 AM 41,271 tmpbarcode8.png
05/16/2013 10:02 AM 18,162 tmpbarcode9.png
because of this call,
PdfExtractor extractor = new PdfExtractor();
//Bind the input PDF document to extractor
extractor.bindPdf("38_w_Barcode.pdf");
//Extract images from the input PDF document
extractor.extractImage();
String suffix = ".png";
String image1="";
int imageCount = 1;
while (extractor.hasNextImage()) {
System.out.println("Extracting image " + imageCount);
image1 = "tmpbarcode" + imageCount + suffix;
extractor.getNextImage(image1);
If I adapt it as a web service call for multiple concurrency on J2EE, they will step on each other unless I create different sub folder for each call (and then need to clean them up). Again it seems to me there is no necessary to write these to files and read them back. But not sure if any other API to use from ASPOSE. Temp file directory doesn't work well for concurrent calls.
Plus the PDF I choose to test (randomly) has >100 tiny images, and will create >100 tmp files.
For extractor.extractImage() call, is there any way to filter images by type (barcode images only), or by location on the page (in ( [(25,100), (0,7000] rect area only for example). Other Java PDF package has this function, but not sure about your ASPOSE.PDF.
Again, I just start to play with ASPOSE and evaluate for our project. Please accept my ignorance with your ASPOSE framework.
Thank you.
If you "run" (not debug) the program on eclipse 3.6.2 windows 7 professional 64-bit (shipped with IBM Integration Designer 7.5.1.1) as a stand-alone, no issue. Here is the output.
Total Pages = 38
Codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
page=1
page=2
page=3
page=4
barcode file saved.
Extracting image 1
Extracting image 2
codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
Extracting image 3
Extracting image 4
Extracting image 5
codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
Extracting image 6
Extracting image 7
Extracting image 8
codetext: 9876543210-ABCDEFGHIJKLMNOPQWSTUVWXYZ-.$ /+%
Extracting image 9
too many >10 images
Finish at the end.
But I will run into issues when trying to scale it up on a J2EE server.
1. It seems to me, based on ASPOSE sample here, you can only add barcode as an image to a PDF from java.io.FileInputStream.
java.io.FileInputStream imageStream = new java.io.FileInputStream(new java.io.File(image + ".png"));
Page page2 = pdfDocument1.getPages().get_Item(i+1);
page2.getResources().getImages().add(imageStream);
The API Add() here only has file input, not from a BarcodeBuilder --> BufferedImage directly in the memory. So I have to write the barcode to a tmp file, read it back into program and add to PDF, not efficient. Any advice here?
2. When I run the program, ASPOSE created tmp files for all the images from the source PDF on a local directory,
05/16/2013 10:02 AM 5,151 tmpbarcode1.png
05/16/2013 10:02 AM 41,271 tmpbarcode2.png
05/16/2013 10:02 AM 40,416 tmpbarcode3.png
05/16/2013 10:02 AM 5,151 tmpbarcode4.png
05/16/2013 10:02 AM 41,271 tmpbarcode5.png
05/16/2013 10:02 AM 30,796 tmpbarcode6.png
05/16/2013 10:02 AM 5,151 tmpbarcode7.png
05/16/2013 10:02 AM 41,271 tmpbarcode8.png
05/16/2013 10:02 AM 18,162 tmpbarcode9.png
because of this call,
PdfExtractor extractor = new PdfExtractor();
//Bind the input PDF document to extractor
extractor.bindPdf("38_w_Barcode.pdf");
//Extract images from the input PDF document
extractor.extractImage();
String suffix = ".png";
String image1="";
int imageCount = 1;
while (extractor.hasNextImage()) {
System.out.println("Extracting image " + imageCount);
image1 = "tmpbarcode" + imageCount + suffix;
extractor.getNextImage(image1);
If I adapt it as a web service call for multiple concurrency on J2EE, they will step on each other unless I create different sub folder for each call (and then need to clean them up). Again it seems to me there is no necessary to write these to files and read them back. But not sure if any other API to use from ASPOSE. Temp file directory doesn't work well for concurrent calls.
Plus the PDF I choose to test (randomly) has >100 tiny images, and will create >100 tmp files.
For extractor.extractImage() call, is there any way to filter images by type (barcode images only), or by location on the page (in ( [(25,100), (0,7000] rect area only for example). Other Java PDF package has this function, but not sure about your ASPOSE.PDF.
Again, I just start to play with ASPOSE and evaluate for our project. Please accept my ignorance with your ASPOSE framework.
Thank you.