Jump to content

QR Code still prints when spreadsheet field is blank


smccauley

Recommended Posts

Probably a very easy fix to this but I am a new FP user so need a little direction.

 

Created a VDP document with a QRCBarcodeRule. The output only only requires the barcode on every other envelope, however, even though the fields in the csv file are blank when the code is not needed it still inserts (and, therefore prints) a blank QR Code (the scan verifies a "NULL" value).

 

Is there a rule I can put in place that tells the template not to print a barcode if the csv field is empty?

Link to comment
Share on other sites

  • 2 years later...

Hello. I realize this is an old posting but I thought i'd give it a shot. We just upgraded from fusion pro 6.1 - 9.1 so we're a little new at the QR abilities. This has the exact issue we are experiencing plus 1.

 

We currently have business cards set up so that people may select the option to place a personalized qr code onto it. Same issue as the original poster has described, if the qr code field is blank, it displays a null qr code on the finalized image. We tried setting up the suggested javascript rule but aren't sure we are doing this correctly. Replaced fieldname with the exact field name its reading from, but still no luck, it still displays an invalid qr code.

 

if (Field ("fieldname") == "")

 

{

return "";

}

 

else

{

return Rule("QR Barcode Rule");

}

 

The second issue may be more complex. Each business card has 2 different graphics on the business card which requires the QR code to be placed in a different place depending on where the graphic is. Let's say for example image 1 requires the code to be placed in the bottom left hand side of the card, and if they select design 2 it requires the qr code to be placed in the bottom right side of the card. What would be the simplest solution for this?

 

Please let me know if any additional information is needed at all. I appreciate any assistance given.

Link to comment
Share on other sites

Your first problem is difficult to assess without seeing your rule and some data. Are you able to post an example of your situation?

 

The second problem is certainly achievable. If you are using FusionPro Producer for composition, you can set the coordinates of your QR text frame in the OnRecordStart Callback rule. Just make sure you've named that text frame (something like QR):

// If the Design is 1, leave the text box where it is, if it's 2, move it to the right
if (Field("Design") == "2"){
    FindTextFrame("QR").x = 2 * 7200; // Set the x coordinates to 2" (7200 pts per inch)
}

 

Alternatively, you could set up two text frames positioned correctly for each design and suppress one of them (from OnRecordStart) when it's not needed:

FindTextFrame("QR1").suppress = (Field("Design") == "1");
FindTextFrame("QR2").suppress = (Field("Design") == "2");

 

Hope that gets you started

Link to comment
Share on other sites

Replaced fieldname with the exact field name its reading from, but still no luck, it still displays an invalid qr code.

 

if (Field ("fieldname") == "")

 

{

return "";

}

 

else

{

return Rule("QR Barcode Rule");

}

So you created a new rule with that syntax. Did you also go into the text frame where the "QR Barcode Rule" rule is being called and change it to call your new rule instead?

 

The other thing you could do, instead of writing a second rule, is to convert the "QR Barcode Rule" rule to JavaScript and add this right before the "return" statement near the end:

if (!DataToEncode)
   return "";

The second issue may be more complex. Each business card has 2 different graphics on the business card which requires the QR code to be placed in a different place depending on where the graphic is. Let's say for example image 1 requires the code to be placed in the bottom left hand side of the card, and if they select design 2 it requires the qr code to be placed in the bottom right side of the card. What would be the simplest solution for this?

You can do what Step suggests if you're composing to FusionPro VDP Producer (Direct), or to FusionPro VDP Producer API (Server), either in your own system or with a web-to-print system such as MarcomCentral.

 

If you're running FusionPro VDP Creator (Desktop), then Step's suggestion to use two different frames and suppress one of them is probably your best bet.

 

However, if the design is radically different between the two pages, then it might be easier to just create two completely different Body pages in your template, and call the FusionPro.Composition.SetBodyPageUsage function from OnRecordStart to output the appropriate page for each design.

Link to comment
Share on other sites

Your first problem is difficult to assess without seeing your rule and some data. Are you able to post an example of your situation?

 

Ok, so the only rule that we currently have in our pdf is the basic text QR Barcode Rule:

 

var FieldOrRuleToEncode = "QRCode";

var EncodingMode = "Byte";

var ErrorCorrectionMode = "M";

var PreferredFormat = "0";

var PointSize = "4";

var NoFontTag = false;

var Font = "IDAutomation2D";

var ProcessTilde = false;

 

var DataToEncode = FieldOrRule(FieldOrRuleToEncode);

return MakeQRBarcode(DataToEncode, ProcessTilde,

EncodingMode, ErrorCorrectionMode, PreferredFormat,

PointSize, NoFontTag, Font);

 

As you can see the field it pulls data from is an entry in our CSV source. This field is collected from an online form and either has data such as myemail@myisp.net or the user simply chooses not to use the field.

 

So what i'm wanting to do is basically what the original poster stated. It needs to generate a qr code only for the specific people who choose to enter something in there and not create a qr code for anyone who chooses not to.

 

The second problem has been resolved by simply changing images. Thanks for your help.

Link to comment
Share on other sites

Ok, so the only rule that we currently have in our pdf is the basic text QR Barcode Rule:

 

var FieldOrRuleToEncode = "QRCode";

var EncodingMode = "Byte";

var ErrorCorrectionMode = "M";

var PreferredFormat = "0";

var PointSize = "4";

var NoFontTag = false;

var Font = "IDAutomation2D";

var ProcessTilde = false;

 

var DataToEncode = FieldOrRule(FieldOrRuleToEncode);

return MakeQRBarcode(DataToEncode, ProcessTilde,

EncodingMode, ErrorCorrectionMode, PreferredFormat,

PointSize, NoFontTag, Font);

So if you've already converted your rule to JavaScript, then all you need to do is exactly what I said in my previous post: add a line right before the return statement to return an empty string if the data to encode is empty, like so, below in green:

var FieldOrRuleToEncode = "QRCode";
var EncodingMode = "Byte";
var ErrorCorrectionMode = "M";
var PreferredFormat = "0";
var PointSize = "4";
var NoFontTag = false;
var Font = "IDAutomation2D";
var ProcessTilde = false;

var DataToEncode = FieldOrRule(FieldOrRuleToEncode);

[color=Green]if (!DataToEncode)
   return "";
[/color]
return MakeQRBarcode(DataToEncode, ProcessTilde,
         EncodingMode, ErrorCorrectionMode, PreferredFormat,
         PointSize, NoFontTag, Font);

Edited by Dan Korn
rule converted to JavaScript, not to PDF
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...