PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

putting last few pages together using MigraDoc and pdfshape
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2979
Page 1 of 1

Author:  tony.1992 [ Fri Nov 14, 2014 1:38 am ]
Post subject:  putting last few pages together using MigraDoc and pdfshape

Hi All,

I am making a report with only migradoc

My question is how do I make the last page rotate 90 degree and put 2 pages as 1 like the image below.
Also if there is too much data, I also want to create a new page and rotate 90 degree and start from the top left again.
Any Idea?

I am also confuse on how pdfsharp and migradoc working together.

Image
http://postimg.org/image/mr37lxi9b/

Tony

Update I got it show in the report, but my 2nd page is on top of the 1st page.
Here is my code.

Code:
            Document doc =  CreateDocSectionIII(ImagePath, "");
            DocumentRenderer SectiondocRenderer = new DocumentRenderer(doc);

            SectiondocRenderer.PrepareDocument();
           
            XRect A4Rect = new XRect();
           
            int pageCount = SectiondocRenderer.FormattedDocument.PageCount;

            for (int idx = 0; idx < pageCount; idx+=2)
            {
                PdfPage page = renderer.PdfDocument.AddPage();

                page.Width += page.Width;

                double width = page.Width;
                double height = page.Height;

                //page.Rotate = 90;
                //int rotate = page.Elements.GetInteger("/Rotate");

                XGraphics gfx = XGraphics.FromPdfPage(page);
               
                // HACKĀ²
                gfx.MUH = PdfFontEncoding.Unicode;
                gfx.MFEH = PdfFontEmbedding.Default;

                A4Rect = new XRect(0, 0, width/2, height);
                 
                // Use BeginContainer / EndContainer for simplicity only. You can naturaly use you own transformations.
                XGraphicsContainer container = gfx.BeginContainer(A4Rect, A4Rect, XGraphicsUnit.Point);
                 
                // Draw page border for better visual representation
                gfx.DrawRectangle(XPens.LightGray, A4Rect);
                 
                // Render the page. Note that page numbers start with 1.
                SectiondocRenderer.RenderPage(gfx, idx + 1);
               
                // Pop the previous graphical state
                gfx.EndContainer(container);

                if (idx + 1 < pageCount)
                {
                    A4Rect = new XRect(width / 2, 0, width / 2, height);

                    container = gfx.BeginContainer(A4Rect, A4Rect, XGraphicsUnit.Point);

                    // Draw page border for better visual representation
                    gfx.DrawRectangle(XPens.LightGray, A4Rect);


                    //DocumentObject[] docObjects = SectiondocRenderer.GetDocumentObjectsFromPage(idx + 1);
                    //for (int lol = 0; lol < docObjects.Count(); lol++)
                    //{
                    //    SectiondocRenderer.RenderObject(gfx, width / 2,0, width/2, docObjects[lol]);
                    //}

                    SectiondocRenderer.RenderPage(gfx, idx + 2);

                    // Pop the previous graphical state
                    gfx.EndContainer(container);
                }
            }

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/