iprint2 Posted January 22, 2016 Share Posted January 22, 2016 Hey Everyone, I have an image rule I've been using for about a year that works great. Now i need to adjust it so that it does something slightly different. Basically this is what ive got now var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18] = [Field("P1"),Field("P2"),Field("P3"),Field("P4"),Field("P5"),Field("P6"),Field("P7"),Field("P8"), Field("P9"),Field("P10"),Field("P11"),Field("P12"),Field("P13"),Field("P14"),Field("P15"),Field("P16"),Field("P17"),Field("PROTOCOL")].filter(String); var pdfMap = { "1": "Heart disease1.pdf", "2": "Heart failure2.pdf", "3": "Breathing3.pdf", "4": "Kidney4.pdf", "5": "Diabetes5.pdf", "6": "Depression6.pdf", "7": "7_Other Health Conditions.pdf", "8": "8_No Health Conditions Listed.pdf", "9": "************9.pdf", "10": "Multiple medications10.pdf", "11": "Falls11.pdf", "12": "Cane12.pdf", "13": "Caregiver13.pdf", "14": "Calling14.pdf", "15": "Overnight15.pdf", "16": "Memory loss16.pdf", "17": "17_Confidence in Filling Out Med Forms.pdf", "201": "Closing letter18.pdf", "701": "Closing letter18.pdf", "702": "Closing letter18.pdf", "703": "Closing letter18.pdf", } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource(); What is does is add a bunch of graphics, and then when there isnt anymore "active" fields, it returns a blank. What i need now it that is does the same thing, but i need it to add a particular pdf before the blank, for every record. Ive included a zip with the test file im working with. Any thoughts JasonHtel Test.zip Quote Link to comment Share on other sites More sharing options...
step Posted January 22, 2016 Share Posted January 22, 2016 (edited) Can you be a little more descriptive about what you're trying to do? While I appreciate you attaching your template, you didn't supply any of the graphic elements so it's kind of hard to get a grasp of what you're trying accomplish. Are you wanting to add a specific PDF before every blank that may be needed (PDF, blank, PDF, blank, etc) or are you trying to add a specific PDF before the blanks start (PDF, blank, blank, blank, etc). Sample output would be very helpful. If it's the latter, you could probably do this: var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18] = [Field("P1"),Field("P2"),Field("P3"),Field("P4"),Field("P5"),Field("P6"),Field("P7"),Field("P8"), Field("P9"),Field("P10"),Field("P11"),Field("P12"),Field("P13"),Field("P14"),Field("P15"),Field("P16"),Field("P17"),Field("PROTOCOL")[color="red"], 'BeforeBlanks'[/color]].filter(String); var pdfMap = { "1": "Heart disease1.pdf", "2": "Heart failure2.pdf", "3": "Breathing3.pdf", "4": "Kidney4.pdf", "5": "Diabetes5.pdf", "6": "Depression6.pdf", "7": "7_Other Health Conditions.pdf", "8": "8_No Health Conditions Listed.pdf", "9": "************9.pdf", "10": "Multiple medications10.pdf", "11": "Falls11.pdf", "12": "Cane12.pdf", "13": "Caregiver13.pdf", "14": "Calling14.pdf", "15": "Overnight15.pdf", "16": "Memory loss16.pdf", "17": "17_Confidence in Filling Out Med Forms.pdf", "201": "Closing letter18.pdf", "701": "Closing letter18.pdf", "702": "Closing letter18.pdf", "703": "Closing letter18.pdf", [color="Red"]"BeforeBlanks": 'SpecificPDF.pdf', [/color] } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource(); Edited January 23, 2016 by step Quote Link to comment Share on other sites More sharing options...
iprint2 Posted January 22, 2016 Author Share Posted January 22, 2016 Man sorry i didnt even consider the Graphics, The whole job should be attached now, at least everything needed for this. Also a pdf of what im able to get, and what i want to get. Are you wanting to add a specific PDF before every blank that may be needed (PDF, blank, PDF, blank, etc) or are you trying to add a specific PDF before the blanks start (PDF, blank, blank, blank, etc). Sample output would be very helpful. If it's the former, you could probably do this: what i would need is the second option. PDF before the blanks start (PDF, blank, blank, blank, etc) I have one pdf (closing letter_ps.pdf in the attached zip folder.) that will need to be placed before the template outputs blanks to the remaining graphic frames. var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : [color=Red]Resource("Closing Letter_PS")[/color]; If I make the change in red to the code i already posted, i get the pdf i attaced "this is what im getting" What i would like is for the the closing letter ps, to go in, and then have the rest be blank. Im not sure if this is any clearer, let me know if you have more questions. ThanksHtel Test.zipShould look like this.pdfThis is what im getting.pdf Quote Link to comment Share on other sites More sharing options...
step Posted January 23, 2016 Share Posted January 23, 2016 what i would need is the second option. Cool, then the code I wrote earlier will work: var frameName = FusionPro.Composition.CurrentFlow.name; var [p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,p18] = [Field("P1"),Field("P2"),Field("P3"),Field("P4"),Field("P5"),Field("P6"),Field("P7"),Field("P8"), Field("P9"),Field("P10"),Field("P11"),Field("P12"),Field("P13"),Field("P14"),Field("P15"),Field("P16"),Field("P17"),Field("PROTOCOL"),'ps'].filter(String); var pdfMap = { "1": "1_cardiacas.pdf", "2": "2_Insuficiencia.pdf", "3": "3_Problemas respiratorios.pdf", "4": "4_Dialisis renal.pdf", "5": "5_Diabetes.pdf", "6": "6_Depresion.pdf", "7": "7_Otras condiciones.pdf", "8": "8_No hay condiciones.pdf", "9": "9_Medicamentos.pdf", "10": "10_Varios medicamentos.pdf", "11": "11_Caidas.pdf", "12": "12_Baston.pdf", "13": "13_Necesidad.pdf", "14": "14_Llamar.pdf", "15": "15_Hospitalizacion.pdf", "16": "16_Perdida.pdf", "17": "17_Confianza.pdf", "201": "18_Closing Letter.pdf", "701": "18_Closing Letter.pdf", "702": "18_Closing Letter.pdf", "703": "18_Closing Letter.pdf", "704": "18_Closing Letter.pdf", "705": "18_Closing Letter.pdf", "706": "18_Closing Letter.pdf", "707": "18_Closing Letter.pdf", "708": "18_Closing Letter.pdf", "710": "18_Closing Letter.pdf", "711": "18_Closing Letter.pdf", "712": "18_Closing Letter.pdf", "713": "18_Closing Letter.pdf", "714": "18_Closing Letter.pdf", "715": "18_Closing Letter.pdf", "716": "18_Closing Letter.pdf", "717": "18_Closing Letter.pdf", "718": "18_Closing Letter.pdf", "719": "18_Closing Letter.pdf", "720": "18_Closing Letter.pdf", "721": "18_Closing Letter.pdf", "722": "18_Closing Letter.pdf", "723": "18_Closing Letter.pdf", "801": "18_Closing Letter.pdf", "901": "18_Closing Letter.pdf", "902": "18_Closing Letter.pdf", "904": "18_Closing Letter.pdf", "502": "19_Closing LetterCIP.pdf", "ps": "Closing Letter_PS" } var field = eval(frameName); return (field) ? Resource(pdfMap[field]) : NullResource(); Quote Link to comment Share on other sites More sharing options...
iprint2 Posted January 25, 2016 Author Share Posted January 25, 2016 This would assume that there is a field in my Xcel file for "ps" though right? Is there a good way to get it to populate that graphic frame without having it in the excel list? Quote Link to comment Share on other sites More sharing options...
step Posted January 25, 2016 Share Posted January 25, 2016 (edited) This would assume that there is a field in my Xcel file for "ps" though right? No. What makes you think that? Notice that there's no "Field" function wrapping it. Here's what's happening: You have an array that contains the values of fields P1-P17, the value of the protocol field, and a static 'ps' string. Then that array is filtered and the empty positions are removed. So for example: var arr = ['val1','','val3',''].filter(String); // arr[1] & arr[3] are removed // now arr == ['val1', 'val3'] var [a,b,c,d] = arr; // this assigns variables a,b,c,d to each position in the 'arr' array return b; // returns 'val3' Once the array is filtered and the remaining positions are assigned to their respective variables, the values are checked against the 'pdfMap' object to determine which graphic to return. So: pdfMap = { 'val1' : 'PdfforValue1.pdf', 'val2' : 'PdfforValue2.pdf', 'val3' : 'PdfforValue3.pdf', 'val4' : 'PdfforValue4.pdf', }; var graphic = pdfMap[b]; // PdfforValue3.pdf In your specific case, with the addition of the static 'ps' string means that it will never be filtered out because it is not empty. The value "ps" is simply used to map which PDF to pull in for that value. Edited January 25, 2016 by step Quote Link to comment Share on other sites More sharing options...
iprint2 Posted January 25, 2016 Author Share Posted January 25, 2016 Ah i see how that works. Have you ever considered, teaching java? You seem to have a Damn good handle on it, and both times you've helped you've also explained how its working in an understandable way. Not something i see a lot dealing with coding stuff. I bet you could make some money on a site like udemy. I know id take that course. Anyway, thanks a ton for the help again! 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.