Example #1
0
        public virtual void testAutomateLayout_PlateSet()
        {
            for (int loop = 0; loop < 3; loop++)
            {
                n.getAuditPool().appendXMLComment("This is a simple example of an automated layout used for conventional prepress\n" + "The structure is aligned as closely as possible with a static Layout", null);

                JDFRunList run = rl.addRun("file://host/data/test.pdf", 0, -1);
                run.setNPage(128);
                rl.setResStatus(EnumResStatus.Available, true);
                rl.setDescriptiveName("This is a RunList specifiying 128 pages each in a pdf file.");

                lo = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);
                lo.setResStatus(EnumResStatus.Available, true);

                lo.setMaxOrd(4);
                lo.setAutomated(true);
                const string format = "Sheet%02i";
                lo.setAttribute("NameFormat", format);
                lo.setAttribute("NameTemplate", "SheetNum");
                lo.appendXMLComment("Simple automated Layout with exactly one sheet\n", null);
                JDFLayout sheet = (JDFLayout)lo.addPartition(EnumPartIDKey.SheetName, "Sheet");
                sheet.setDescriptiveName("two sided 2 up sheet");
                JDFLayout        sheetFront = (JDFLayout)sheet.addPartition(EnumPartIDKey.Side, EnumSide.Front);
                JDFContentObject co         = sheetFront.appendContentObject();
                co.setCTM(new JDFMatrix(1, 0, 0, 1, 0, 0));
                co.setOrd(0);
                co.setDescriptiveName("Front 1st, 5th, 9th... Page");

                co = sheetFront.appendContentObject();
                co.setCTM(new JDFMatrix(1, 0, 0, 1, 8.5 * 72, 0));
                co.setOrd(1);
                co.setDescriptiveName("Front 2nd, 6th, 10th... page");

                JDFLayout sheetBack = (JDFLayout)sheet.addPartition(EnumPartIDKey.Side, EnumSide.Back);
                co = sheetBack.appendContentObject();
                co.setCTM(new JDFMatrix(1, 0, 0, 1, 0, 0));
                co.setOrd(2);
                co.setDescriptiveName("Back 3rd, 7th, 11th... Page");

                co = sheetBack.appendContentObject();
                co.setCTM(new JDFMatrix(1, 0, 0, 1, 8.5 * 72, 0));
                co.setOrd(3);
                co.setDescriptiveName("Back 4th, 8th, 12th... page");

                JDFRunList rlSheet = (JDFRunList)n.appendMatchingResource(ElementName.RUNLIST, EnumProcessUsage.AnyOutput, null);
                rlSheet.setDirectory("file://host/out/");
                if (loop == 0) // instantiate individually
                {
                    PrintfFormat fmt = new PrintfFormat(format);
                    for (int i = 0; i < 128; i += 4)
                    {
                        string     sheetName = fmt.tostr(1 + i / 4);
                        JDFRunList rlp       = (JDFRunList)rlSheet.addPartition(EnumPartIDKey.SheetName, sheetName);
                        JDFRunList rlF       = (JDFRunList)rlp.addPartition(EnumPartIDKey.Side, EnumSide.Front);
                        rlF.appendLayoutElement().setMimeURL(sheetName + "Front.pdf");
                        JDFRunList rlB = (JDFRunList)rlp.addPartition(EnumPartIDKey.Side, EnumSide.Back);
                        rlB.appendLayoutElement().setMimeURL(sheetName + "Back.pdf");
                    }
                }
                if (loop == 1) // instantiate individually
                {
                    rlSheet.appendLayoutElement().setMimeURL("AllSheets.pdf");
                    PrintfFormat        fmt = new PrintfFormat(format);
                    JDFIntegerRangeList integerRangeList = new JDFIntegerRangeList();
                    for (int i = 0; i < 128; i += 4)
                    {
                        string     sheetName = fmt.tostr(1 + i / 4);
                        JDFRunList rlp       = (JDFRunList)rlSheet.addPartition(EnumPartIDKey.SheetName, sheetName);
                        JDFRunList rlF       = (JDFRunList)rlp.addPartition(EnumPartIDKey.Side, EnumSide.Front);
                        integerRangeList.Clear();
                        integerRangeList.Append(i / 2);
                        rlF.setPages(integerRangeList);
                        JDFRunList rlB = (JDFRunList)rlp.addPartition(EnumPartIDKey.Side, EnumSide.Back);
                        integerRangeList.Clear();
                        integerRangeList.Append(1 + i / 2);
                        rlB.setPages(integerRangeList);
                    }
                }
                else
                // instantiate by template
                {
                    JDFFileSpec fs = rlSheet.appendLayoutElement().appendFileSpec();
                    fs.setMimeType("application/pdf");
                    fs.setFileFormat(format + "%s_%s.pdf");
                    fs.setFileTemplate("SheetNum,Surface,Separation");
                }

                doc.write2File(sm_dirTestDataTemp + "AutomatedLayout_Plateset" + loop + ".jdf", 2, false);
                n.getResourceLinkPool().deleteNode();
                n.getResourcePool().deleteNode();
            }
        }