How can I set the page or section margins in XML?

The documentation states how to do this in code, but I’d like to set the margins declaratively in the XML/XSL. It’s not clear to me how to set any properties on objects encapsulated on the main object. Like the MarginInfo or PageInfo properties.



Hi,

Thanks for using our products.

In XML, PageSize is not supported and you can only use numbers. The units supported for setting the page size are as follows:

  • point
  • cm
  • inch

Note: In API, only point unit is supported.

Please take a look over the contents of XML file shared below.

[XML]

<?xml version="1.0" encoding="utf-8" ?>
<Pdf xmlns="Aspose.Pdf">
<Section PageWidth="8inch" PageHeight="25cm" >
<Text MarginTop="10" MarginLeft="60" Color="Blue" BackgroundColor="Yellow">
<Segment FontSize="16"> Hello World</Segment>

</Section>
</Pdf>

For more information, please visit the following link Set Page Size and Margins

In case it does not resolve your problem or you have any further query, please feel free to contact. We apologize for your inconvenience.

Hello,


Thank you for your response. De documentation you showed only shows how to set margins for text, and a width for the page. Not how to set the margins used for the page.


Hi,

Please take a look over the following XML contents in which Page Top, Left and Right margin is specified. More along, you can also find the information on how to set Page Border.

[XML]

<?xml version="1.0" encoding="utf-8" ?>
<Pdf xmlns="Aspose.Pdf">
<Section PageWidth="8inch" PageHeight="25cm" PageMarginLeft="30" PageMarginTop="50" PageMarginRight="200">

<All LineWidth="0.5">

<Text MarginTop="10" MarginLeft="60" Color="Blue" BackgroundColor="Yellow">
<Segment FontSize="16"> Hello World</Segment>

</Section>
</Pdf>

In case you have any further query, please feel free to contact. We apologize for your inconvenience.

I might've misunderstood, but in your documentation you claim that margins are set with attribute MarginX instead of PageMarginX.

If this is really the case, it might be wise to fix it: http://www.aspose.com/docs/display/pdfnet/Set+Page+Size+and+Margins

Hi Otto,


Thanks for your inquiry. In referenced documentation, we have used MarginInfo class to set Page Margin so used MarginX properties of MaginInfo object. Hopefully it will help you to fulfill your requirements. If still there is any confusion then please share some more details and your sample code/input document here, so we will provide you more information accordingly.

We are sorry for the inconvenience caused.

Best Regards,