Trim Box Issue and FloatingBox Placements

prbcover-gn-PB-personalized.pdf (334.7 KB)
prbcover-output-gn-PB-personalized.pdf (357.9 KB)

I can not set the TRIM BOX with Aspose.PDF. In addition, The FloatingBox seems to be offset about an inch down and right even though I set the top =1 and left = 1. …Any ideas on why the Trim Box setting will not save and why the FloatingBOx box is moved down and right. The Code is listed below.

    public void AssemblePressSheet()
         Document doc = new Document( inputFile);
         Page page = doc.Pages[1];
         SetTrimBox( doc, page );
         ShowInfo( doc );

    public void SetTrimBox( Document doc, Page page)
        page.TrimBox.LLX = 292;            // (left Side) points from left side of pdf 
        page.TrimBox.LLY = 144;            // (bottom) points from bottom of pdf
        page.TrimBox.URX = 904;            // (right side) points from left side of pdf  
        page.TrimBox.URY = 650;            // (top) points from bottom side of pdf  

    public void ShowInfo(Document doc)
        Page page = doc.Pages[1];

        FloatingBox box = new Aspose.Pdf.FloatingBox();
        box.Top    = 1;
        box.Left   = 1;
        box.Height = 100;
        box.Width  = 160;
        box.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.ColorTranslator.FromHtml("#FFFFFF"));
        box.HorizontalAlignment = HorizontalAlignment.Left;
        box.VerticalAlignment = VerticalAlignment.Top;
        box.ZIndex = 10;
        box.Border = new BorderInfo(BorderSide.Box);

        string LLX = page.TrimBox.LLX.ToString();      // (left Side) points from left side of pdf 
        string LLY = page.TrimBox.LLY.ToString();      // (bottom) points from bottom of pdf
        string URX = page.TrimBox.URX.ToString();      // (right side) points from left side of pdf  
        string URY = page.TrimBox.URY.ToString();      // (top0) points from bottom side of pdf 

        TextFragment fragment = new Aspose.Pdf.Text.TextFragment( 
                "Trim Box " + Environment.NewLine +
                "LLX = " + LLX + Environment.NewLine + 
                "LLY= " + LLY + "\nURX = " + URX + "\nURY = " + URY );

        fragment.TextState.Font = FontRepository.FindFont("TimesNewRoman");
        fragment.TextState.FontSize = 8;
        fragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.ColorTranslator.FromHtml("#000000"));


Thank you for contacting support.

We have been able to notice the problem while setting trim box. A ticket with ID PDFNET-46400 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

Moreover, the floating box is being offset because of page margins. So you may set page margins to zero before calling SetTrimBox method.

Document doc = new Document( inputFile);
Page page = doc.Pages[1];
page.PageInfo.Margin = new MarginInfo(0,0,0,0);
SetTrimBox(doc, page);

We are sorry for the inconvenience.

Thank you Farhan. Do you think this will be resolved on the next release? When is the next release?


Please note that the issue has been logged under free support model and will be investigated on first come first serve basis so it may take some months. As soon as we have some definite updates regarding ticket’s resolution, we will let you know. Moreover, new version of Aspose.PDF for .NET API is usually released within first two weeks, every month.


We have investigated it further and are pleased to share with you that, getter TrimBox property returns Rectangle class which describes trim box of the page. In order to change TrimBox please use getter of TrimBox property, i.e. assign

page.TrimBox = new Recangle (LLX, LLY, URX, URY );

Thus, please use the following code snippet:

        public void SetTrimBox(Document doc, Page page)
            page.TrimBox = new Rectangle(292, 144, 904, 650);
            //instead of: 
            //page.TrimBox.LLX = 292;            // (left Side) points from left side of pdf 
            //page.TrimBox.LLY = 144;            // (bottom) points from bottom of pdf
            //page.TrimBox.URX = 904;            // (right side) points from left side of pdf  
            //page.TrimBox.URY = 650;            // (top) points from bottom side of pdf  

We hope this will be helpful.