Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > Adjust all content fit in a page

Forum

Search UsersRules
Adjust all content fit in a page
#1
Just came
Points:: 0
Joined:: Aug 5, 2024

How can the content of a printed page automatically fit on one page and be centered?

Currently,

this print form mainly uses A5 size
the number of lines is arbitrary
In the case that the number of lines increases, is there a way for the font size to automatically adjust so that the printed page does not overflow to another page?

In practice, when I adjust the print scale, it tends to keep the alignment towards the top-left of the printed page.

Thank in advance

Have a good day

Profile
#2
Just came
Points:: 0
Joined:: Aug 14, 2024

This is what I've come up with. I'm not certain it will work, but it's worth a try.

You'll need to implement the following script:

Code
Procedure AdjustFontSizeAndMarginsBeforePrint(PrintForm)
    // Set default values
    MaxLines = 50; // Example: Maximum lines that fit on an A5 page
    ActualLines = PrintForm.LineCount();

    // Calculate if font size adjustment is needed
    If ActualLines > MaxLines Then
        ScaleFactor = MaxLines / ActualLines;
        AdjustedFontSize = PrintForm.FontSize * ScaleFactor;
        PrintForm.SetFontSize(AdjustedFontSize);
    EndIf;

    // Calculate margins for centering
    ContentHeight = PrintForm.ContentHeight;
    ContentWidth = PrintForm.ContentWidth;

    VerticalMargin = (A5Height - ContentHeight) / 2;
    HorizontalMargin = (A5Width - ContentWidth) / 2;

    // Apply the calculated margins
    PrintForm.SetMargins(VerticalMargin, HorizontalMargin);
EndProcedure


If you have any questions, feel free to write them down. We'll try to figure it out somehow.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.