public override void Run(
            )
        {
            // 1. PDF file instantiation.
            files::File file     = new files::File();
            Document    document = file.Document;

            // Set default page size (A4)!
            document.PageSize = PageFormat.GetSize();

            // 2. Content creation.
            DateTime creationDate = DateTime.Now;
            // 2.1. Template.
            FormXObject template = BuildTemplate(document, creationDate);

            // 2.2. Welcome page.
            BuildWelcomePage(document, template);
            // 2.3. Free Software definition.
            BuildFreeSoftwareDefinitionPages(document, template);
            // 2.4. Bookmarks.
            BuildBookmarks(document);

            // 3. Serialization.
            Serialize(file, "Complex Typesetting", "complex typesetting", "typesetting, bookmarks, hyphenation, block composer, primitive composer, text alignment, image insertion, article threads");
        }
Exemplo n.º 2
0
        private void Populate(Document document)
        {
            PdfType1Font bodyFont = PdfType1Font.Load(document, PdfType1Font.FamilyEnum.Courier, true, false);

            Pages pages = document.Pages;

            PageFormat.SizeEnum[]        pageFormats      = (PageFormat.SizeEnum[])Enum.GetValues(typeof(PageFormat.SizeEnum));
            PageFormat.OrientationEnum[] pageOrientations = (PageFormat.OrientationEnum[])Enum.GetValues(typeof(PageFormat.OrientationEnum));
            foreach (PageFormat.SizeEnum pageFormat in pageFormats)
            {
                foreach (PageFormat.OrientationEnum pageOrientation in pageOrientations)
                {
                    // Add a page to the document!
                    Page page = new Page(document, PageFormat.GetSize(pageFormat, pageOrientation));
                    // Instantiates the page inside the document context.
                    pages.Add(page); // Puts the page in the pages collection.

                    // Drawing the text label on the page...
                    SKSize            pageSize = page.Size;
                    PrimitiveComposer composer = new PrimitiveComposer(page);
                    composer.SetFont(bodyFont, 32);
                    composer.ShowText(
                        pageFormat + " (" + pageOrientation + ")", // Text.
                        new SKPoint(
                            pageSize.Width / 2,
                            pageSize.Height / 2
                            ),                 // Location: page center.
                        XAlignmentEnum.Center, // Places the text on horizontal center of the location.
                        YAlignmentEnum.Middle, // Places the text on vertical middle of the location.
                        45                     // Rotates the text 45 degrees counterclockwise.
                        );
                    composer.Flush();
                }
            }
        }
Exemplo n.º 3
0
        private void BuildContent(Document document)
        {
            // Set default page size (A4)!
            document.PageSize = PageFormat.GetSize();
            // Add a font to the fonts collection!
            document.Resources.Fonts[ResourceName_DefaultFont] = new StandardType1Font(
                document,
                StandardType1Font.FamilyEnum.Courier,
                true,
                false
                );

            // Add a page to the document!
            Page page = new Page(document); // Instantiates the page inside the document context.

            document.Pages.Add(page);       // Puts the page in the pages collection.

            // Create a content composer for the page content stream!
            PrimitiveComposer composer = new PrimitiveComposer(page);

            string[]             steps  = new string[5];
            colorSpaces::Color[] colors = new colorSpaces::Color[5];
            SKSize pageSize             = page.Size;

            BuildSteps(composer, steps, colors, pageSize);

            BuildLegend(composer, steps, colors, pageSize);

            composer.Flush();
        }
Exemplo n.º 4
0
        public override void Run(
            )
        {
            // 1. Instantiate the source PDF file!
            string filePath = PromptFileChoice("Please select a PDF file to use as source");

            using (var sourceFile = new File(filePath))
            {
                // 2. Instantiate a new PDF file!
                File file = new File();

                // 3. Source page combination into target file.
                Document          document       = file.Document;
                Pages             pages          = document.Pages;
                int               pageIndex      = -1;
                PrimitiveComposer composer       = null;
                SizeF             targetPageSize = PageFormat.GetSize(PageFormat.SizeEnum.A4);
                foreach (Page sourcePage in sourceFile.Document.Pages)
                {
                    pageIndex++;
                    int pageMod = pageIndex % 2;
                    if (pageMod == 0)
                    {
                        if (composer != null)
                        {
                            composer.Flush();
                        }

                        // Add a page to the target document!
                        Page page = new Page(
                            document,
                            PageFormat.GetSize(PageFormat.SizeEnum.A3, PageFormat.OrientationEnum.Landscape)
                            );           // Instantiates the page inside the document context.
                        pages.Add(page); // Puts the page in the pages collection.
                        // Create a composer for the target content stream!
                        composer = new PrimitiveComposer(page);
                    }

                    // Add the form to the target page!
                    composer.ShowXObject(
                        sourcePage.ToXObject(document), // Converts the source page into a form inside the target document.
                        new PointF(targetPageSize.Width * pageMod, 0),
                        targetPageSize,
                        XAlignmentEnum.Left,
                        YAlignmentEnum.Top,
                        0
                        );
                }
                composer.Flush();

                // 4. Serialize the PDF file!
                Serialize(file, "Page combination", "combining multiple pages into single bigger ones", "page combination");
            }
        }