Creating an autoresist printout

My application must print something. The layout should be somewhat dynamic (sometimes certain fields may contain more data, which may require wrapping them in words or some such), but the printout should never exceed one page. If there is too much data, I want to reduce the font size a bit and try again, and repeat this until everything is placed on one page (there will never be so much data that the font will be unreadably small).

I need to print text and images on one page.

The layout should look something like this:

+------------------------------------------------------------------+
| +------+                                               +-------+ |
| | seal |                   text field 1                | photo | |
| |      |                   text field 2                |       | |
| +------+                                               +-------+ |
| ---------------------------------------------------------------- |
|  text header 1:                 text data                        |
|  text header 2:                 longer text data                 |
|  text header 3 with long title: very long text data which does   |
|                                 not fit on a single line         |
| ---------------------------------------------------------------- |
|  text header 4:                 text data                        |
.                                                                  .
.     (...)                          (...)                         .
.                                                                  .
|                                                                  |
+------------------------------------------------------------------+

text field 1 , , . text field 2 , , , . () .

, , .

NSView (, , ) XIB . NSTextField elemnts . NSTextField, (.. , ), , .

, :

  • , NSTextField , , , , . , ( ), .
  • API , NSView, , . , NSView, . , .

? , ? , ?

API- Core Printing, .

,

+4
1

NSTextField , Behavior None Selectable.

, NSView knowPageRange: rectForPage:. PageRange: (1) YES. rectForPage: , , , [self layoutSubtreeIfNeeded] self.bounds. [[NSPrintOperation currentOperation] printInfo] printinfo.

+2

Source: https://habr.com/ru/post/1607419/


All Articles