Hello,
Welcome to Microsoft Q&A!
I want to change the space between the content of my document and the edge of the paper.
About change the space between the content of my document and the edge of the paper, you can refer to the Scenario3CustomOptions part of Printing official sample. You can use PrintCustomItemListOptionDetails property to create a list of Margins option. Then if you want to change the margin, in the printDetailedOptions_OptionChanged event, setting the ApplicationContentMarginTop and ApplicationContentMarginLeft as 0. For example:
RandomAccessStreamReference narrowMarginsIconReference = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/narrowMargins.svg"));
zeroMarginsIconTask = narrowMarginsIconReference.OpenReadAsync().AsTask();
PrintCustomItemListOptionDetails margins = printDetailedOptions.CreateItemListOption("Margins", "Margins");
margins.AddItem("ZeroMargins", "Zero", "Each margin is 0% of the paper size", await zeroMarginsIconTask);
async void printDetailedOptions_OptionChanged(PrintTaskOptionDetails sender, PrintTaskOptionChangedEventArgs args)
{
......
if (optionId == "Margins")
{
PrintCustomItemListOptionDetails marginsOption = (PrintCustomItemListOptionDetails)sender.Options["Margins"];
string marginsValue = marginsOption.Value.ToString();
switch (marginsValue)
{
case "ZeroMargins":
ApplicationContentMarginTop = 0;
ApplicationContentMarginLeft = 0;
break;
......
}
}
}
Get current margins.
You can based on the ApplicationContentMarginTop property to get current margins.