A script in C1PrintDocument does not seem tobe working as expected

Posted by: jsnahil on 10 April 2020, 10:59 pm EST

  • Posted 10 April 2020, 10:59 pm EST

    I used ObjectResolvedScript to ensure that a document starts on an odd page if programmed to do so.

    If the document is going to be rendered on an even page then the script below uses LayoutChangeNewPage to insert a blank page without header and footer, forcing the document is to starts on an odd page.

    The issue is that the blank page sometimes is output that contains header and footer.

    Script:
    <code>
    </

    RenderEmpty re = new RenderEmpty();
    re.ObjectResolvedScript =
    "if MultiDocument.PageCount mod 2 = 0 then\r\n" +
    " Dim lc As LayoutChangeNewPage = New LayoutChangeNewPage()\r\n" +
    " lc.PageLayout = New PageLayout()\r\n" +
    " lc.PageLayout.Pageheader = New RenderEmpty()\r\n" +
    " lc.PageLayout.PageFooter = New RenderEmpty()\r\n" +
    " Document.Body.Children(RenderObject.IndexInOwner + 1).LayoutChangeAfter = lc\r\n" +
    "else\r\n" +
    " Document.Body.Children(RenderObject.IndexInOwner + 1).LayoutChangeAfter = Nothing\r\n" +
    "end if";
    doc.Body.Children.Add(re);
    doc.Body.Children.Add(new RenderEmpty());


    An example that show this behaviour can be loaded here:



    -Joginder Nahil
    PageBreakTest.zip
  • Replied 15 April 2020, 3:47 am EST

    Hello,

    I have modified the sample for you. Please refer to the attached sample.

    Thanks,
    MohitPageBreakTest.zip
  • Replied 15 April 2020, 8:40 am EST

    Many thanks. It works. What is thinking behind your solution?
  • Replied 15 April 2020, 8:12 pm EST

    Also when you create longer than 1 page then the page numbers do have the desired effect. Make the following change and see it yourself,

    I would like to a page header and footer on all page except the page that is forced to start a document on a even page.


    private void button3_Click(object sender, EventArgs e)
    {
    C1MultiDocument md = new C1MultiDocument();
    md.Items.Add(CreateDoc("Coversheet", 10, false));
    md.Items.Add(CreateDoc("TOC", 100, true));
    md.Items.Add(CreateDoc("Code A", 120, true));
    md.Items.Add(CreateDoc("Code B", 200, false));
    md.Items.Add(CreateDoc("Code C", 12, true));
    md.Items.Add(CreateDoc("Index", 150, true));
    md.Generate();

    using (C1PrintPreviewDialog d = new C1PrintPreviewDialog())
    {
    d.Document = md;
    d.ShowDialog();
    };
  • Replied 21 April 2020, 6:33 pm EST

    Hello,

    Sorry for the delay!

    We are working on this and will update you once I find the solution for this.

    Thanks,
    Mohit
  • Replied 24 April 2020, 1:21 am EST

    Hello,

    I have escalated the issue to our development team (432691) and will inform you once I get any information from them.

    Thanks,
    Mohit
  • Replied 24 April 2020, 2:12 am EST

    Thank you Mohit.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels