Using Debenu Quick PDF Library it is possible to scale down or shrink the content on a page in order to leave a margin on the sides and the top and bottom. This means that you can shrink the content on the page in order to make room for adding new content, such as page size, along the margins of the page.

Here is some C# code that demonstrates how to scale down the content of a page to make room for new content along the margins.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
double pageWidth, pageHeight, horizBorder, vertBorder;
double scaleFactor = 0.70;     // 70 % scaling reduction.
int capturedPageId;
int ret;
 
DPL.LoadFromFile("Pages.pdf");
DPL.SetOrigin(1);
 
int numPages = DPL.PageCount();
int pageId;
 
for (int i = 1; i <= numPages; i++)
{
DPL.SelectPage(1);
pageWidth = DPL.PageWidth();
pageHeight = DPL.PageHeight();
horizBorder = pageWidth * (1.0 - scaleFactor) / 2;
vertBorder = pageHeight * (1.0 - scaleFactor) / 2;
 
capturedPageId = DPL.CapturePage(1); // This deletes the page from the document.
 
pageId = DPL.NewPage();
DPL.SetPageDimensions(pageWidth, pageHeight);
 
ret = DPL.DrawCapturedPage(capturedPageId, horizBorder, vertBorder, pageWidth - 2 * 
horizBorder, pageHeight - 2 * vertBorder);
}
 
DPL.SaveToFile("newpages.pdf");
System.Diagnostics.Process.Start(@"newpages.pdf");

DPL.LoadFromFile("Pages.pdf");
DPL.SetOrigin(1);

int numPages = DPL.PageCount();
int pageId;

for (int i = 1; i <= numPages; i++)
{
DPL.SelectPage(1);
pageWidth = DPL.PageWidth();
pageHeight = DPL.PageHeight();
horizBorder = pageWidth * (1.0 - scaleFactor) / 2;
vertBorder = pageHeight * (1.0 - scaleFactor) / 2;

capturedPageId = DPL.CapturePage(1); // This deletes the page from the document.

pageId = DPL.NewPage();
DPL.SetPageDimensions(pageWidth, pageHeight);

ret = DPL.DrawCapturedPage(capturedPageId, horizBorder, vertBorder, pageWidth - 2 *
horizBorder, pageHeight - 2 * vertBorder);
}

DPL.SaveToFile("newpages.pdf");
System.Diagnostics.Process.Start(@"newpages.pdf");