> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/get-started/samples/impositiontest.md).

# Imposition

Sample C# code for using Apryse SDK to impose (combine) multiple PDF pages. Page imposition can be used to arrange/order pages prior to printing or for document assembly (assemble a 'master' page from

Sample C# code for using Apryse SDK to impose (combine) multiple PDF pages. Page imposition can be used to arrange/order pages prior to printing or for document assembly (assemble a 'master' page from several 'source' pages). It is also possible to write applications that can re-order the pages such that they will display in the correct order when the hard copy pages are compiled and folded correctly. Learn more about our [Xamarin SDK](/core/get-started/frameworks/dotnet.md) and [PDF Editing & Manipulation Library](/core/page-manipulation/manipulation.md).

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------
using System;
using System.IO;
using System.Collections;
using pdftron;
using pdftron.Common;
using pdftron.SDF;
using pdftron.PDF;

//-----------------------------------------------------------------------------------
// The sample illustrates how multiple pages can be combined/imposed 
// using PDFNet. Page imposition can be used to arrange/order pages 
// prior to printing or to assemble a 'master' page from several 'source' 
// pages. Using PDFNet API it is possible to write applications that can 
// re-order the pages such that they will display in the correct order 
// when the hard copy pages are compiled and folded correctly. 
//-----------------------------------------------------------------------------------

using NUnit.Framework;

namespace MiscellaneousSamples
{
	[TestFixture]
	public class ImpositionTest
	{
		
		[Test]
		public static void Sample()
		{

			// Relative path to the folder containing test files.
			const string input_path =  "TestFiles/";

			try	
			{    
				Console.WriteLine("-------------------------------------------------");
				Console.WriteLine("Opening the input pdf...");
				using (PDFDoc in_doc = new PDFDoc(Utils.GetAssetTempFile(input_path + "newsletter.pdf")))
				{
					in_doc.InitSecurityHandler();

					// Create a list of pages to import from one PDF document to another.
					ArrayList import_list = new ArrayList(); 
					for (PageIterator itr = in_doc.GetPageIterator(); itr.HasNext(); itr.Next()) 
						import_list.Add(itr.Current());

					using (PDFDoc new_doc = new PDFDoc()) //  Create a new document
					using (ElementBuilder builder = new ElementBuilder())
					using (ElementWriter  writer  = new ElementWriter())
					{
						ArrayList imported_pages = new_doc.ImportPages(import_list);

						// Paper dimension for A3 format in points. Because one inch has 
						// 72 points, 11.69 inch 72 = 841.69 points
						Rect media_box= new Rect(0, 0, 1190.88, 841.69); 
						double mid_point = media_box.Width()/2;

						for (int i=0; i<imported_pages.Count; ++i)
						{
							// Create a blank new A3 page and place on it two pages from the input document.
							Page new_page = new_doc.PageCreate(media_box);
							writer.Begin(new_page);

							// Place the first page
							Page src_page = (Page)imported_pages[i];
							Element element = builder.CreateForm(src_page);

							double sc_x = mid_point / src_page.GetPageWidth();
							double sc_y = media_box.Height() / src_page.GetPageHeight();
							double scale = Math.Min(sc_x, sc_y);
							element.GetGState().SetTransform(scale, 0, 0, scale, 0, 0);
							writer.WritePlacedElement(element);

							// Place the second page
							++i; 
							if (i<imported_pages.Count)	
							{
								src_page = (Page)imported_pages[i];
								element = builder.CreateForm(src_page);
								sc_x = mid_point / src_page.GetPageWidth();
								sc_y = media_box.Height() / src_page.GetPageHeight();
								scale = Math.Min(sc_x, sc_y);
								element.GetGState().SetTransform(scale, 0, 0, scale, mid_point, 0);
								writer.WritePlacedElement(element);
							}

							writer.End();
							new_doc.PagePushBack(new_page); 
						}
						new_doc.Save(Utils.CreateExternalFile("newsletter_booklet.pdf"), SDFDoc.SaveOptions.e_linearized);
						Console.WriteLine("Done. Result saved in newsletter_booklet.pdf...");
					}
				}
			}
			catch (Exception e)
			{
				Console.WriteLine("Exception caught:\n{0}", e);
				Assert.True(false);
			}
		}
	}
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/get-started/samples/impositiontest.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
