COPY PAGE TO PAGE EXAMPLE

The following .NET application has been developed using ABCpdf, ASP.NET, and the C# language.

This ABCpdf example copies a PDF document page to another PDF document.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Text;
using System.Net;
using System.IO;
using WebSupergoo.ABCpdf8;

namespace ABCpdfExamples
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // ---- Draw a page from one PDF document onto 
            // the current page ----
            Doc theSrc = new Doc();
            theSrc.Read(
                Server.MapPath("~/images/fox_dog_raw_image.pdf"));
            int theCount = theSrc.PageCount;

            Doc theDst = new Doc();
            theDst.MediaBox.String = theSrc.MediaBox.String;
            theDst.Rect.String = theDst.MediaBox.String;
            theDst.Rect.Magnify(0.5, 0.5);
            theDst.Rect.Inset(10, 10);
            double theX, theY;
            theX = theDst.MediaBox.Width / 2;
            theY = theDst.MediaBox.Height / 2;

            for (int i = 1; i <= theCount; i++)
            {
            switch (i % 4)
                {
            case 1:
                   theDst.Page = theDst.AddPage();
                   theDst.Rect.Position(10, theY + 10);
            break;
            case 2:
                   theDst.Rect.Position(theX + 10, theY + 10);
            break;
            case 3:
                   theDst.Rect.Position(10, 10);
            break;
            case 0:
                   theDst.Rect.Position(theX + 10, 10);
            break;
                }
                theDst.AddImageDoc(theSrc, i, null);
                theDst.FrameRect();
            }

            theDst.Save(Server.MapPath("~/Results/Output.pdf"));
            theSrc.Clear();
            theDst.Clear();
        }
    }
}

Page to Page

© 1997-2021    Codehacker - All Rights Reserved