Esempio n. 1
0
        public virtual void testBuildOldLayout()
        {
            reset();

            n.setVersion(EnumVersion.Version_1_2);
            JDFLayout lo = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);

            Assert.IsFalse(JDFLayout.isNewLayout(lo), "lo 1.3");
            JDFSignature si = lo.appendSignature();

            si.setName("Sig1");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");
            Assert.IsFalse(si.hasAttribute(AttributeName.CLASS));
            si = lo.appendSignature();
            si.setName("Sig2");
            Assert.AreEqual(2, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");

            JDFSheet sh = si.appendSheet();

            sh.setName("Sheet2_1");
            sh.makeRootResource(null, null, true); // see what happens with
            // refelements
            sh = si.appendSheet();
            sh.setName("Sheet2_2");
            Assert.AreEqual(2, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.SHEET, sh.LocalName, "sheet name");
            sh = si.getCreateSheet(4);
            Assert.AreEqual(3, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.SHEET, sh.LocalName, "sheet name");
            sh = si.getSheet(2);
            Assert.AreEqual(3, si.numSheets(), "num sheets");
            Assert.AreEqual(ElementName.SHEET, sh.LocalName, "sheet name");

            JDFSurface su = sh.appendFrontSurface();

            Assert.AreEqual(1, sh.numSurfaces(), "num surfaces");
            Assert.AreEqual(ElementName.SURFACE, su.LocalName, "sheet name");
            Assert.IsTrue(sh.hasFrontSurface(), "hasfrontSurface");
            su.appendContentObject();
            su.appendMarkObject();
            su.appendContentObject();
            su.appendContentObject();

            su = sh.appendBackSurface();
            su.makeRootResource(null, null, true);
            su.appendContentObject();
            su.appendMarkObject();
            su.appendContentObject();
            su.appendContentObject();
            su.appendMarkObject();
            Assert.AreEqual(2, sh.numSurfaces(), "num surfaces");
            Assert.AreEqual(ElementName.SURFACE, su.LocalName, "sheet name");
            Assert.IsTrue(sh.hasBackSurface(), "hasBackSurface");

            try
            {
                sh.appendBackSurface();
                Assert.Fail("append second surface");
            }
            catch (JDFException)
            { // nop
            }

            si = lo.getCreateSignature(4);
            Assert.AreEqual(3, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");
            si = lo.getSignature(2);
            Assert.AreEqual(3, lo.numSignatures(), "num sigs");
            Assert.AreEqual(ElementName.SIGNATURE, si.LocalName, "signature name");
            si = lo.getSignature(5);
            Assert.IsNull(si, "si null");
            Assert.AreEqual(lo.numSignatures(), lo.getSignatureVector().Count);
        }
Esempio n. 2
0
        public virtual void testDynamicMarks()
        {
            JDFElement.setLongID(false);
            JDFLayout lo = (JDFLayout)n.appendMatchingResource(ElementName.LAYOUT, EnumProcessUsage.AnyInput, null);

            lo.setXMLComment("Layout that illustrates dynamic mark placement - all margins are 25 points (gutter=2*25)");
            lo.setSurfaceContentsBox(new JDFRectangle(0, 0, 500, 350));
            JDFSheet   s  = lo.appendSheet();
            JDFSurface su = s.appendFrontSurface();

            JDFContentObject co0 = su.appendContentObject();

            co0.setOrd(0);
            JDFMatrix m1 = (JDFMatrix)JDFMatrix.unitMatrix.Clone();

            m1.shift(25, 25);
            co0.setCTM(JDFMatrix.unitMatrix);
            co0.setTrimSize(new JDFXYPair(200, 300));
            string[] id = new string[2];
            id[0] = co0.appendAnchor(null);
            JDFContentObject co1 = su.appendContentObject();

            m1 = (JDFMatrix)JDFMatrix.unitMatrix.Clone();
            m1.shift(275, 25);
            co1.setCTM(m1);
            co1.setTrimSize(200, 300);
            id[1] = co1.appendAnchor(null);

            {
                JDFMarkObject mark0 = su.appendMarkObject();
                mark0.setXMLComment("Register Mark on the top right of the sheet - assumed size is 20*30, assumed sheet size is 500*350");
                mark0.setTrimSize(20, 30);
                mark0.setCTM(new JDFMatrix(1, 0, 0, 1, 500 - 20, 350 - 30));
                mark0.appendDeviceMark().setAttribute("Anchor", "TopRight");
                mark0.appendRegisterMark().setXMLComment("mark metadata goes here");
                appendRefAnchor(mark0, "TopRight", "Parent", null);
            }

            {
                JDFMarkObject mark0 = su.appendMarkObject();
                mark0.setXMLComment("Vertical Slug Line beginning at the top of the bottom margin of of the sheet between the 2 pages" + "\nnote that no TrimSize need be specified and therefore TrimCTM / CTM place the point defined by @Anchor" + "\nnote also that the anchor points to centerleft which is in the unrotated (horizontal) cs of the slug line");
                JDFMatrix m0 = new JDFMatrix(1, 0, 0, 1, 0, 0);
                m0.rotate(90);
                m0.shift(250, 25);
                mark0.setCTM(m0);
                JDFDeviceMark dm = mark0.appendDeviceMark();
                dm.setAttribute("Anchor", "CenterLeft");
                dm.setFontSize(10);
                dm.setFont("GhostCrypt");
                JDFJobField jf = mark0.appendJobField();
                jf.setXMLComment("Result: Sheet Printed by Dracula at the moonphase FullMoon");
                jf.setAttribute("JobFormat", "Sheet Printed by %s at the moonphase %s");
                jf.setAttribute("JobTemplate", "Operator,MoonPhase");
                appendRefAnchor(mark0, "BottomCenter", "Parent", null);
            }

            for (int i = 0; i < 2; i++)
            {
                JDFMarkObject mark0 = su.appendMarkObject();
                mark0.setXMLComment("Horizonzal Slug Line, centered 5 points over the top of page " + i + "\nnote that page is not yet a predefined token\n");
                JDFMatrix m0 = new JDFMatrix(1, 0, 0, 1, 0, 0);
                m0.rotate(90);
                m0.shift(25 + 100, 300 + 25 + 5);
                if (i == 1)
                {
                    m0.shift(250, 0);
                }
                mark0.setCTM(m0);
                JDFDeviceMark dm = mark0.appendDeviceMark();
                dm.setAttribute("Anchor", "BottomCenter");
                dm.setFontSize(8);
                JDFJobField jf = mark0.appendJobField();
                jf.setXMLComment("Result: Page # " + i + " for Customer, Polanski - Job: J11");
                jf.setAttribute("JobFormat", "Page # %i for Customer, %s - Job: %s");
                jf.setAttribute("JobTemplate", "Page,JobRecipientName,JobID");
                appendRefAnchor(mark0, "BottomCenter", "Sibling", id[i]);
            }
            doc.write2File(sm_dirTestDataTemp + "LayoutDynamicMarks.jdf", 2, false);
        }