• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

BarCode Read

 
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using  com.itextpdf.text.pdf.*; jar file for barcode generation and to read.

My task is to read .pdf file and generate each page into .png file and save in the name of barcode place at top of each page. like if .pdf file has 20 pages then 20 .png files are generated. I have successfully generated it but i cant find howto save .png file using barcode name.

Like 2021-01-01-0001-01 (This is the barcode generated using Code128).

Please help where i need more code to fix it. Currently file is generated using for loop (1,2,3,4.... .png files)

test1.pdf file is source document and 1.png file is generated via these code.

Here is the code.



 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I assume that the problem is extracting text from a barcode in an image embedded in a PDF (and not saving a file under a given name) - correct?

I don't know that iText has any facilities for reading barcodes, I think you need a library like ZXing for that. https://issues.apache.org/jira/browse/PDFBOX-2124 shows how that works with the PDFBox library.
 
Saloon Keeper
Posts: 28810
212
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, as I read it, you want to be able to read in a PDF with multiple pages and from each page in turn, generate an image of that page with a barcode overlaying part of the image, then take that page image and write it as a .png file.

You can use iText to read the PDF, but that's about its limit. If the pages in the PDF have more than just raw images in them - for example, they have typeset text - then you would need a way to interpret those typesetting commands and overlay the text onto the image workspace. You would also have to use a barcode font/generator library to overlay the barcode into the image space. Finally you'd use Java's image writer functions to output the image space as a PNG-format (NOT PDF!!!) file. Ensuring it has been given a ".png" file extension is just part of the standard file output.
 
Anand Karia
Ranch Hand
Posts: 158
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes TIM Moores, it is something like extracting the text of barcode from .pdf. and letter i will save document under extracted barcode text.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest that you can try Spire.Office.jar to accomplish this job. Here is the code snippet for your reference.

 
Liar, liar, pants on fire! refreshing plug:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic