Sterling Rouse <sterling <at> 360works.com> writes:

> 
> I need to be able to define my own spot color and apply it to the QR code. 
This is to be read by a printing press,
> which will apply the spot color in place of the black that is actually 
displayed if you open the PDF in Acrobat.
> 
> On Aug 1, 2012, at 12:41 PM, John Renfrew <rwu <at> btclick.com> wrote:
> 
> > You can convert it to a Java awt image using
> > qrcode.createAwtImage(java.awt.Color.GREEN, java.awt.Color.White) for
> > example to give green on white
> > 
> > 
> > john renfrew 
> > Right Way Up 
> > 
> > -----Original Message-----
> > From: Sterling Rouse [mailto:sterling <at> 360works.com] 
> > Sent: 01 August 2012 16:53
> > To: itext-questions <at> lists.sourceforge.net
> > Subject: [iText-questions] QR Code
> > 
> > Is there a way to apply a spot color to a QR code generated in iText?
> > 
> > 
> > ----------------------------------------------------------------------------
> > --
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and 
> > threat landscape has changed and how IT managers can respond. Discussions 
> > will include endpoint security, mobile security and the latest in malware 
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > iText-questions mailing list
> > iText-questions <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > 
> > iText(R) is a registered trademark of 1T3XT BVBA.
> > Many questions posted to this list can (and will) be answered with a
> > reference to the iText book: http://www.itextpdf.com/book/
> > Please check the keywords list before you ask for examples:
> > http://itextpdf.com/themes/keywords.php
> > 
> > 
> > 
> > ----------------------------------------------------------------------------
--
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and 
> > threat landscape has changed and how IT managers can respond. Discussions 
> > will include endpoint security, mobile security and the latest in malware 
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > iText-questions mailing list
> > iText-questions <at> lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/itext-questions
> > 
> > iText(R) is a registered trademark of 1T3XT BVBA.
> > Many questions posted to this list can (and will) be answered with a 
reference to the iText book: http://www.itextpdf.com/book/
> > Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> iText-questions mailing list
> iText-questions <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a 
> reference 
to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php
> 
> 

Hi Sterling, don't know if you ever got a solution. I couldn't find any way to 
get a bitmap image into a spot colour space. I have a workaround that's a bit 
messy but does the job. Basically, I make a white inverted image of the QR code 
and float it over a solid fill of spot colour. Example code below.

cheers, Mike



          // get the QR code image
          BarcodeQRCode qrcode = new BarcodeQRCode(rawtext, 0, 0, null);
          Image qrImage = qrcode.getImage();          
          float pSize = (float)MM_TO_POINTS*size;          
          qrImage.scaleToFit(pSize, pSize); 
          qrImage.setAbsolutePosition(0, 0);
    
          // set up the PDF page
          Document doc = new Document(); 
          FileOutputStream fos = new FileOutputStream(file);
          PdfWriter writer = PdfWriter.getInstance(doc, fos);
          doc.setPageSize(new com.itextpdf.text.Rectangle(pSize, pSize));
          doc.open();              
          
          // fill page with required spot colour 
          PdfSpotColor spot = new PdfSpotColor("spot blue", new CMYKColor(1.0f, 
1.0f, 0f, 0f));                                               
          PdfContentByte canvas = writer.getDirectContent();
          canvas.setColorFill(spot, 1.0f);
          canvas.newPath();
          canvas.moveTo(0.0f, 0.0f);
          canvas.lineTo(pSize, 0.0f);
          canvas.lineTo(pSize, pSize);
          canvas.lineTo(0.0f, pSize);
          canvas.closePath(); 
          canvas.fill();           
          
          // float white inverse image of qr code over the top
          qrImage.setInverted(true);
          qrImage.makeMask();          
          byte[] data = {(byte)255};
          Image fil = Image.getInstance(1, 1, 1, 8, data); // 1 pixel white img
          fil.scaleAbsolute(pSize, pSize);
          fil.setImageMask(qrImage);
          fil.setAbsolutePosition(0.0f, 0.0f);                   
          canvas.addImage(fil);
          
          doc.close();


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to