简体   繁体   中英

Read iText7 XObject QrCode c#

I've been playing with iText7 for a bit and have a question about its FormXObject QrCode generation.

PdfWriter writer = new PdfWriter("C:\\Testing\\Documentation\\Infomercial.pdf");
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
iText.Barcodes.BarcodeQRCode qrcode = new BarcodeQRCode("{\"item\":\"123\",\"id\":\"123\"}");
var codeFormObject = qrcode.CreateFormXObject(pdf);

What i would like to do now, is read the barcode...when i try to extract the image out of it using code i found on here i cannot seem to get to the image of the barcode.

So option 1 is: to on the fly read the barcode on the pdf if possible Option2: I suppose i could flatten the pdf page to an image and then use zxing? to read the barcode?

I would like to do option1 rather than 2 but not sure if thats even possible, I've tried to extract the image of the barcode but it seems like it isn't actually an image?

Thanks,

I am the image of my father, does not imply I am a pixel or vector family representative.

Bar/QR codes should be vector objects and can be generated by using vector fonts or scalable vector graphics.

For convenience they are sometimes generated as monochrome PNG/TIF/GIF pixel images with integer pixel sizes. Thus a single QR square could be 4x4 pixels. One reason NOT to use Jpeg as it approximates 8x8 pixels at a time producing "halo" artefacts.

To answer your question you either need to convert those image objects to a pixel image or extract as a font or vector image.

Perhaps the generation example description helps to show how simpler 2D barcodes may be constructed see https://kb.itextpdf.com/home/it5kb/faq/how-to-generate-2d-barcode-as-vector-image

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM