Mike Edwards Posted June 1, 2018 Share Posted June 1, 2018 Hi, everybody! First time posting. I've got a problem in getting a properly-formatted Datamatrix barcode to print for use with our intelligent inserter. It has to be of the format X999999SSTT where XX is a string, 999999 is a zero-padded sequence number, SS is a zero-padded number representing the current sheet, and TT is a zero-padded number representing the total sheets being inserted. Here is the code I came up with: { // Rule converted from XML Template "DataMatrix Barcode Rule": /* The goal here is to generate the proper Datamatrix 2D barcode * using the established pattern for our Rival inserter. * FusionPro does not have the notion of simplex/duplex, so we * have to state up front what that is. */ // Choose the following values: var JobIDseq = "INSCODE"; // Standard EDWARDS field name var TotalSheets = "SHEETS"; // Standard EDWARDS field name var Sides = "Simplex"; // Use Duplex here for duplex jobs. Mixed modes are not supported. var EncodingMode = "ASCII"; var PreferredFormat = "0"; var PointSize = 6; // "Font size (defaults to 10)": SingleLine var NoFontTag = false; var Font = "IDAutomationDMatrix"; var ProcessTilde = false; var TotSheets = FormatNumber( "00", FieldOrRule( TotalSheets ) ); // For simplex jobs, the current sheet is simply the page number. // For duplex jobs, we have to do some basic math. var CurrSheet = Sides == "Simplex" ? FormatNumber( "00", FusionPro.Composition.currentPageNumber ) : FormatNumber( "00", Math.ceil( FusionPro.Composition.currentPageNumber / 2 ) ) ; var DataToEncode = FieldOrRule( JobIDseq ) + CurrSheet + TotSheets; return MakeDataMatrixBarcode( DataToEncode, ProcessTilde, EncodingMode, PreferredFormat, PointSize, NoFontTag, Font ); } Everything seems to work except for assigning CurrSheet. It appears that FusionPro.Composition.currentPageNumber is not returning the correct value. Either that or I'm using FormatNumber wrong. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 4, 2018 Share Posted June 4, 2018 The FusionPro.Composition.currentPageNumber property returns the page number in the record, so if each record is outputting one or two pages, it will always be page one or two, in every record. You can use FusionPro.Composition.pageNumberInJob instead. But in an imposed job, you probably want FusionPro.Composition.impositionSheetNumber. The FusionPro.Composition.impositionSheetIsBack property may be useful as well. Quote Link to comment Share on other sites More sharing options...
Mike Edwards Posted June 4, 2018 Author Share Posted June 4, 2018 Yes, I get that, and it's what I expect, but this code is returning "00" for CurrSheet in every instance. I was hoping someone could tell me if my syntax is wrong or what the problem might be. Quote Link to comment Share on other sites More sharing options...
Mike Edwards Posted June 4, 2018 Author Share Posted June 4, 2018 Further testing shows that although when I run Validate during rule construction I get the correct value, when the job previews or is composed, it still shows "00" every time. Am I not understanding how this is supposed to work, or is there a bug? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 5, 2018 Share Posted June 5, 2018 (edited) Yes, I get that, and it's what I expect, but this code is returning "00" for CurrSheet in every instance. I was hoping someone could tell me if my syntax is wrong or what the problem might be. Yes, "this" code, as in the only code you've posted so far, won't work. Did you try using FusionPro.Composition.impositionSheetNumber instead, as I recommended? Posting the template would probably be helpful than more rounds of back-and-forth like this. Further testing shows that although when I run Validate during rule construction I get the correct value I don't see how you could possibly know that. First of all, there's no actual page or sheet number at rule validation time; it's just a rule, with no context of where you might be when actually composing. Second, if you validate the rule you've posted, all you will get are some markup tags that make a DataMatrix barcode, which look something like this: <f name="IDAutomationDMatrix"><z newsize="10"><leading newsize="100">AIHPDOCIHK<br>AEMONMCLLK<br>DLLDDDLDLL<br> How do you know at validation time whether that's the correct value? when the job previews Preview is a completely invalid test here as well, since you're not imposing the output, you're just previewing a single record, one-up. or is composed, it still shows "00" every time. Again, how does it "show" this? Are you scanning the barcode? With what scanning device and software? Perhaps posting a picture of the barcode would give me some idea of what you're talking about. Though as I said, the template would be better. Am I not understanding how this is supposed to work, or is there a bug? We're not understanding each other, at least. I'm trying to help. But I don't have your data, or the rest of your template. I don't know what you're seeing in the output, or how you're analyzing it. I can only look at the code you've posted and try to guess as to what's wrong. Please post the template so I can fully analyze the issue. Edited June 7, 2018 by Dan Korn Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 5, 2018 Share Posted June 5, 2018 I think this will work: var TotSheets = FormatNumber( "00", FusionPro.Composition.impositionTotalSheets ); var CurrSheet = FormatNumber( "00", FusionPro.Composition.impositionSheetNumber ); But you have to actually be making imposed output, not non-imposed output, and not a Preview, and validating the rule in the editor won't do you any good either. Again, I don't have your job files, so I can't test this for you in the context of your job. But I do know that those properties work in the sample job posted here: http://forums.pti.com/showpost.php?p=11530&postcount=3 That sample also shows how to put per-sheet post-press control barcodes and other such information on the imposed sheet, outside the area of the imposed page contents, which is probably what you want to do for your inserter anyway. Quote Link to comment Share on other sites More sharing options...
Mike Edwards Posted June 5, 2018 Author Share Posted June 5, 2018 My apologies. I guess I wasn't being clear. There is no imposition on this job. Each record gets 6 letter-size pages duplexed on 3 sheets of paper as output. For our inserter equipment to properly read the barcode, a portion of the barcode must read 0103, 0203, and 0303 (sheet 1 of 3, 2 of 3, and 3 of 3). This tells the inserter when it is done with one record and can fold and insert, and move on to the next set. However, this code produces 0003 for every page. We checked it with a barcode scanning app known to work. It scans just fine, but the value returned is not what we need. As a test of what currentPageNumber returns, I made a simple rule and inserted it into the cellphone.pdf tutorial piece: var CurrPage = FusionPro.Composition.currentPageNumber; return CurrPage; When I click validate on that rule, it shows "1". When I preview it and when I compose it, it shows "0". It seems to me that it isn't returning what I think it should be. I am new to these forums and am hesitant to post customer data and/or art in this public space. However, we did send it to Alex at Marcom support on Friday, but his response was word-for-word the same as your initial post here and we haven't heard a response to my follow-up. If we weren't under a time crunch on this project, I wouldn't be following both methods of inquiry. Thanks for your assistance. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted June 5, 2018 Share Posted June 5, 2018 Can you specify the exact versions of FusionPro, Acrobat, and your operating systems? As a test of what currentPageNumber returns, I made a simple rule and inserted it into the cellphone.pdf tutorial piece: var CurrPage = FusionPro.Composition.currentPageNumber; return CurrPage; When I click validate on that rule, it shows "1". When I preview it and when I compose it, it shows "0". It seems to me that it isn't returning what I think it should be. You probably need to check the "Re-evaluate this rule for every text flow" box. Quote Link to comment Share on other sites More sharing options...
Mike Edwards Posted June 5, 2018 Author Share Posted June 5, 2018 That checkbox solved the problem. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.