Á߂‡ ÍË Ä‚ˆ

Á߂‡ ÍË Ä‚ˆ ÿߘ™Á ‚ƒ ÿŸ‚œŒÀ

‚ŸœÍž„‹ à›‚˜œ : ݇ͅ›

àšŠ
Java Ä‚éˆ ÿ‚éAPI ‚éƒ ÁÍ ‚雌 Á߂‡ ÍË Ä‚ˆ ÞÁߜ ʼn… ś‹– µ ÍË Å‹Šœ ъƒ
ÁÍ Í‚é— Áß‚é‡ ÍË Ä‚éˆ Ý…‹Ÿ‹ џ‚›ÎÀ ‚ƒ Jean-Pierre Dube .Ë͗ ˝Áߊ ‚œŒÀ
àéƒ ‚é…韂žœ ß ËŒ ˝Áߊ ɟ͌… È ł‰šÔÁ ÎÁ ÿސƒ Є‹ .Ëߛœ ˝Áߊ ΂’À
Íéƒ à‚é…ß— à›Ë–› ڟ ‚ƒ ßÁ .Å•Í ËÁߊ џ„ Á߂‡ ÍË Ä‚ˆ ÿ‚API łŸì· É͌
ъƒ ޟ™ßÁ àƒ .Ëߛœ ˝Áߊ á͟˜ à‡Ÿ…œ Jean-Pierre Dube ԋ߅ È ق– ÿßÍ
ØééŽ ‚éŸ ß ÅÍ˖ àƒ ÜßÁ à™‰Í› ÍË .˟˛À Ñߊ Á߂‡ ÍË Ä‚ˆ ÿ…›‹– µ á͋ ÍË
‚é… Ý韂é›éœ Úé›é— ‚雌 àƒ à— Å‹Á ޟÁ ޛ ØË .Ë̓ ˟Áߊÿ„ È ÍË Á߂‡
Î‚éƒ ‚é›éŒ ÿÁ̓ ÁÍ àÁÍ ß à…•Í˜ ÍÁ͖ API ÿßÍ Íƒ à— ËŸŸ‚›œ àŸž… ÿƒßˆÍ‚žˆ
àé— ËéËÿé› à΂‡Á ‚›Œ Ã߈͂žˆ .˟ߌ ҚŠ ÿ‡ß͊ àŸž… ÿ‚Í‹ËÍË ÎÁ ß ËŸ‚›œ
‚éžé™ßˇ ß ÍŸß‚… ¬‚ž•Á͘Á͂„ ß ËŸœ— ˂‡ŸÁ headers/footers ‚ƒ ÁÍ Å‚‰•
.˟΂‹ƒ ÁÍ

ÜËé› ß Ëß雜 ݝÁߊ ɟ͌… ‚›Œ ÿÁ̓ ÁÍ Ä‚ˆ àƒ Ô߃͛ ł‰šÔÁ ¬Å›‹– ޟÁ ÍË
‚éžéŸÍ‹ ޟÁ ÍË à—ŸÍßԜ‚› .Ëߛœ ݝÁߊ ÿ•͐› ‚›Œ ÿÁ̓ ÁÍ API ß Á߂‡ È
‚éŸ àéß雇› ł‰• á΂‹Áˇ .ŋŸœ ނ‹À API ÎÁ à˂•…‹Á ‚ƒ È ËŸË ËŸÁߊ
ܟ™Ë ނ› àƒ ÞŸÁ ß .ˌ‚ƒ ڛ— ŋÁ ޗ›› API ÎÁ ͅš‚ƒ à™‰Í› ڟ ÎÁ à˂•…‹Á
ËÍßé› ÍË à韙ßÁ ؟‚Õß Ý‚›… à— ÝŸÎ‚‹ƒ Ã߈͂žˆ ڟ ݟÁߊÿ› ‚› à— Å‹Á ҂Š
àéŸ‚é„ ÍߛÁ á͟˜Á͕ àƒ ÜßÁ ˟Ëƒ à΂‡Á Є .Ëߌ à˜‚‡œ˜ ÞÀ ÍË á΂‹ à‰•
¬Ä‚éˆ API ÍË Ëßé‡ßé› ÿ‚žŸÏߙߜ—… ɟ͌… ÎÁ ܃– -à‰• ڟ ɟ͌… .ݟÎÁË̈́ƒ
ÁÍ Öߎߛ ,˜Áàˌ à˂•…‹Á á͋ ޟÁ ÍË à— Å‚‰šÔÁ ÿސƒ É͌ ‚ƒ ˟Ëƒ à΂‡Á
ÍË‚é– ‚é›Á Ë霋Íÿ› Í՜ƒ ş›Á ÿƒ ܗ ÍË Å‚‰šÔÁ ޟÁ àˆ Í˜Á .ݟŸ‚›œ ΂’À
.ËéœéŸ‚é›éœ Üé‰ (Margins) ‚éàŸŒ‚‰ à͂ƒÍË ÁÍ ‚žŸ˜ËŸˆŸ„ ÿސƒ Ë߃ ˜Áߊ
ÞÀ ÍË .Ëßé›éœ ÖÁÍé…éŠÁ ÁÍ Ä‚ˆ ޟŒ‚› ޟ™ßÁ Û̓œ…ߘ à— ËŸÍÁË ÖšÔÁ š‚›…‰Á
ٟÍÔ ÎÁ ÁÍ à‰• ڟ ÉÍÔ ËœÁ߅ƒ à— Ëߛœÿ› à˂•…‹Á ÿÁàÏÁß ÎÁ ˟‚ƒ ßÁ ނ›Î
.ŋÁ à‰• ڟ ÎÁ Û̓œ…ߘ É͌ ޟÁ .˜— ܟ™‰… ß àŸÎ‡… ÞÀ


± ܗŒ


² ܗŒ

.Åé‹Á àËéŒ ÝéŸé‹é–é… Øé™é…Š› ÿ‚ž…›‹– àƒ à‰• à— ÝŸœŸƒÿ› ² ß± ÿ‚ž™—Œ ÍË
àéƒ àé…鋃Áß ‚Ž• ޟÁ .˜Ëÿ› ܟ—Œ… ÁÍ à‰• ÿ…‚›Ë–› ъƒ ͅœŸÍ„ ÿ‚àŸŒ‚‰
΂éŸéœ Ìé’‚é— Üͅœ— ß Å—Í‰ އ ͘„‚ˆ à— Å‹Á ÿŸ‚Ž• ܖÁˉ ß àË߃ ‚Í˜„‚ˆ
àÎÁËéœÁ ÅÍËéœéƒ ‚é› .ËË ÍŸŸ“… ˜Á߅ÿ›œ ̓͂— ÁÍ Í…œŸÍ„ ÿ‚àŸŒ‚‰ .ËÍÁË
ÎÁ ÿ鎐ƒ ‚›Á .ݟŸ‚›œÿ› à˂•…‹Á ‚žœÀ ÎÁ ‚Ÿ ß ÝŸœÁËÿ› ÁÍ Í…œŸÍ„ ÿ‚àŸŒ‚‰
ÍË .ËéœÁàËßé›éœ ɟ͌… à˜œ— ØÍ› ÿ‚ž˜ß™‚…‚— ÍË ÁÍ ‚žœÀ ͅœŸÍ„ ނ˜ËœÎ‚‹
ҊŒ› ÁÍ Ä‚ˆ ËÍߛ ܉› ˂ƒÁ API .ݟÍÁ˜ ‚àÎÁ˜Á ޅ‹œÁË àƒ Î‚Ÿœ ‚› Á߂‡
à鉕 ÿœß͟ƒ ś‹– à— Ëœ…‹ ÿŸ‚àŸŒ‚‰ ¬Í…œŸÍ„ ÿ‚àŸŒ‚‰ ܊ÁË ÍË .˟‚›œÿ›
ÁÍ àé‰é•é ÜßéÔ Åé‹ÁÍ ß Äˆ ś‹ ÿ‚àŸŒ‚‰ à— ËŸŸ‚›œ Å–Ë .˜ÁàË͗ ҊŒ› ÁÍ
àéŸéŒ‚é‰ ڟ Ĉ ś‹ ś‹– ÍË Gutter .˜Ëÿ› ނŒœ ޟŸ‚„ ß š‚ƒ àŸŒ‚‰ ÿ‚žœ›
àË霂釜˜ ˜ߌ ‚… ˟‚ƒ ß ËœßÍÿ› …— ܊ÁË àƒ Å‚‰• à— ÿœ‚›Î ÿÁ̓ ÿ•‚ŽÁ
Íé ÍË Ä‚éˆ ÿœŸ à— ËœßŒÿ› È duplex mode ÅÍߍƒ ł‰• à—Ÿœ‚›Î ÍË .ŋÁ
ŋ˃ ÿÁ̓ .ŋÁ à…•Í˜ Í՜ ÍË ÿŸÁàŸŒ‚‰ Ϝ ŋÁÍ Å›‹ ÍË Í…ß˜ ¬Å‹Á ś‹– ßË
ß Åé‹ÁÍ Å›‹ ÍË ÁÍ Í…ß˜ ÿ‚àŸŒ‚‰ ˟‚ƒ ̒‚— ÍË à˂•…‹Á ËÍߛ ܉› ܗ ÞËÍßÀ
Íé…ßé˜ àéŸéŒ‚é‰ Üé›‚éŒ ¬API È .˟Ÿ‚›œ à•‚ŽÁ ÞÀ àƒ ß ËŸÍŸ˜ƒ Í՜ ÍË Äˆ
ÃéŸé‡ à™ì‹› .˟Ÿ‚›œ ҊŒ› Á͜À ˟œÁ߅ÿ› à— Å‹Ÿß‰œƒ Ã߈͂žˆ ‚›Á ¬Ëߌÿ›œ
à͂ˆ àÁÍ ‚žœ… ޟÁ̓‚œƒ ¬Ë͟˜ÿ›œ Í՜ ÍË ÁÍ àŸŒ‚‰ Ϝ API à— Å‹‚‡ ޟÁ ÍË
.ËéŸéŸ‚é›éœ ÝéŸéÕéœé… ÁÍ Ä‚ˆ ܃‚– àŸ‰‚œ àÎÁ˜Á ß Ü‰› ‚›Œ à— Å‹Á ޟÁ ÍË
ÍË .ËßéŒÿé› àËéœÁߊ È ܃‚– àŸ‰‚œ ݂œƒ à‰• Ô‹ß ÍË àŸ‰‚œ ޟÁ ¬"‚…Ÿ‚žœ
ÞÀ àƒ ‚› à— ËŸ‚Ÿƒ BorderLayout àŸƒŒ Í՜ àƒ Å‹Á ޗ›› à‰• ÉÍÔ ¬ÜßÁ à‚˜œ
à鉕 ޟŸ‚„ ß š‚ƒ ÍË Ë߇ߛ ÿ‚žŒŠƒ BorderLayout ÍË àˆ Í˜Á .ݟÁàË͗ Å˂
ÿ‚éàéŸéŒ‚‰ à‰• ÿ—ŸÎŸ• ъƒ ÍË à—Ÿ™‚‰ ÍË ËœŸÁΕÁÿ› ÁÍ ÍÁËߛœ àŸ‰‚œ Ó͏
.˜Áàˌ à˜‚‡œ˜ ŋÁÍ ß Äˆ ÿ‚àŸŒ‚‰ ޟƒ ޟŸ‚„ ß š‚ƒ

á͟˜àÎÁ˜Á ÿ‚Ë‰Áß
à‚阅‹Ë ÿ‚Ž• ޟƒ Ù͕ à— Å‹Á ÝΚ ݟœ—ÿ› ͂— Graphics_2D К— ‚ƒ à—Ÿ›‚˜œ
ÿßÍ Üé‹é—Ÿ„ ÿ‚àԖœ ‚ƒ ‚›Œ à‚˜…‹Ë ÿ‚Ž• ÍË .ݟœÁ˃ ÁÍ à˜œ— ØÍ› ÿ‚Ž• ß
1024x768 Åé–Ë ÍË Ü‹—Ÿ„ ±°°x±°° ‘ƒÍ› ڟ àÎÁ˜Á .˟ÍÁË Í‚—ß͋ ͟ߍ… à‰•
.Ëßéƒ ËéÁߊ Å߂•…› Ëߌÿ› render ±¶°°x±²°° Å–Ë ‚ƒ ÿ‹ŸÁßŸË ÿÁ̓ à— ÿ…–ß
áÍé…錟ƒ ÿ‚ž™‹—Ÿ„ ȜŸÁ ͝ ÍË ÝßË ÐŸÁßŸË Á͟Π¬Å‹Á ތßÍ Í‚Ÿ‹ƒ ݝ ÞÀ ř
.˟‹Í ˝Áߊ Í՜ àƒ Í…—ˆß— ‘ƒÍ› à‡Ÿ…œ ÍË ß ËËÿ› ނŒœ ÁÍ

ÿ‚éËé‰Áß ËÍßé› ÍË àé— ËéËÿé› à΂é‡Á ‚é› àƒ ÍƒÍ‚— ÿ‚Ž• ¬Í˜ŸË Å͂ƒ àƒ
ÿéŸéŒ ÚéŸ ‚雌 à—Ÿ›‚˜œ .ݟœ— ͗• à‚˜…‹Ë şŽß àƒ à‡ß… Þß˃ á͟˜àÎÁ˜Á
¬ËŸŸ‚›œÿ› àŸž… (à‰• ‚Ÿ à˜œ— È) Í՜ ËÍߛ à‚˜…‹Ë ÿÁ̓ ÁÍ Graphics_2D
¬àË霜— ØÍ› ÿ‚Ž• ÍË .ËÁË ËŸÁߊ ͟Ÿ“… ПÁßŸË Ð‚‹Á ̓ ÁÍ Í՜ ËÍߛ ÿ‚Ž•
Ü鋗Ÿ„ à͂ƒÍË ÞË͗ ͗• ÿ‚‡ƒ .ˌ ˝Áߊ ݟ՜… ȜŸÁ ͝ ÍË àԖœ ·² Ó͕ џ„
Ëé‰Áß ·² È霟Á ڟ ÍË ÚŸ ‘ƒÍ› ڟ .˟Ÿ‚›œ á͟˜ÝŸ›… ‚Ë‰Áß Ýߞ•› ‚ƒ ˟‚ƒ
ÎÁ à闟›‚˜œ .ŋÁ àԖœ ·¹² ÍË ¶±² (ȜŸÁ ±± ÍË ž/µ) ÿÁà›‚œ à‰• ڟ .ŋÁ
ÍË ‚éžé‹š— ݂›… Á͟Π˟œ— ͂— ‚Ë‰Áß ‚ƒ ˟‚ƒ ¬ËŸŸ‚›œÿ› à˂•…‹Á È API
.˜…‹ à˜œ— ØÍ› ÿ‚Ž•


Á߂‡ È ݅‹Ÿ‹

.ŋÁ àˌ ݂’ËÁ à‡ß… ܃‚– ͂Ÿ‹ƒ à™‰Í› ßË ÍË Á߂‡ È ݅‹Ÿ‹
à˂é•é…é‹Á Java2D API ÎÁ àé— ËéËÿ› à΂‡Á ‚›Œ àƒ Ä‚ˆ ݅‹Ÿ‹ 1.2 àŠ‹œ ÎÁ
à…Š‚‹ ނƒÎ ޟÁ ÎÁ ÿŒŠƒ ÞÁߜƒ Graphical API ÞŸÍ…à…•ÍŒŸ„ ÎÁ ÿ—Ÿ .˟Ÿ‚›œ
ÿßÍ à— áψ ͝ ËÁË ËÁߊ à΂‡Á 2D API ޟÁ .˜—ÿ› render ÁÍ à‰• à— àˌ
áͅœŸÍ„ ÎÁ Îߜ È API àˆ Í˜Á .Ëߌ àËÍßÀ ݝ ̒‚— ÿßÍ Ëߌÿ› à˟Œ— à‰•
ÂéŠé…éœÁ ÿ霂é›Î Íé ÍË ÍéƒÍ‚— ͝ ԋ߅ ͎‚‰ ܂‰ ÍË à— ËŸ‚›œÿ› à˂•…‹Á
à˂•…‹Á ͅߟ„›‚— ÿßÍ Å‚ŠŒ› ß Å‹Ÿ™ àŸž… އ ͅœŸÍ„ Ëߊ ÎÁ Á߂‡ ¬ËË͘ÿ›
ÎÁ à˂镅‹Á ݂˜œ ÍË .˜Œ‚ƒÿ› ÿÁà—ƒŒ ‚Ÿ ÿ™‰› Ë߇ߛ ÿ‚Í…œŸÍ„ .˟‚›œÿ›œ
͘Á Ԗ• ¬ËÍÁ˜ Ëß‡ß à›‚œÍƒ ‚ƒ ͅœŸÍ„ ŋŸ™ ÞËÍßÀ ŋ˃ ÿÁ̓ ÿÁÍ ÈŸ API
ޟÁ .˟‚›œ Š…œÁ ÁÍ Í…œŸÍ„ ڟ ˜Á߅ÿ› ̓͂— ¬Ëߌ ÍÁËߛœ ŜŸÍ„ Ûߙ‚ŸÁË
ÍË Internet Printing Protocol Þé…éŒÁË ‚éƒ Þ‚é‹ à— Å‹Á ÿÁàŠŒ› śš ÿ—Ÿ
Áß‚é‡ ÍË Ä‚éˆ ÜËé› .Ëߛœ ˝Áߊ Ɖƒ ܟŽ•…ƒ ÞÀ à͂ƒÍË 1.4 Á߂‡ áːƒ àŠ‹œ
šéÁ àé‰é• àŸž… ͂— ނŸÍ‡ Á߂‡ ÿ™ƒ– àŠ‹œ ÍË .ŋÁ àËߛœ ͟Ÿ“… 𛂗 1.2
á˂éŸÎ ÍÁËé–é› àéƒ ÿ™ß›› à‰• ڟ È 1.1 Á߂‡ ÍË Ü‚†› ÿÁ̓ .Ë߃œ ҊŒ›
ß Åé•͘ Í՜ ͟ΠÁÍ Í‚— ނŸÍ‡ 1.2 Á߂‡ .Ë߃ ˜— ͂Ÿ‹ƒ ß ÅŒÁË Î‚Ÿœ àՕ‚‰
ˌ‚ƒÿ› CallBack ܲ Ђ‹Á ̓ àˌ ÿ‰ÁÍÔ à͂ƒßË API ޟÁ .ŊÁ˜Á ͂—ƒ Á͜À
àéŸéžé… Ü‚é‰ ÍË à‰• à—Ÿ›‚˜œ ß ‚›Œ à›‚œÍƒ àœ Å‹Á È ÿÍ• ݅‹Ÿ‹ ڟ à—
àéƒ Åéƒé‹œ ‚… ŋÁ ÿ…œ‹ ͂Ÿ‹ƒ ş‚› ÍË Ü˛ ޟÁ .˟‚›œÿ› Üͅœ— Á͜À ¬Å‹Á
àËéžé ̓ ÁÍ Ä‚ˆ à•ŸÕß à›‚œÍƒ ܗŒ ޟÁ ÍË à— JDK 1.1 ÍË àˌ à˂•…‹Á ܲ
áËÁËÍÁÍé– ‚›Œ à›‚œÍƒ à— ÝŸìߘŸ› ÅÍߍ ޟÁ àƒ Ýߞ•› ÞË͗ à˂‹ ÿÁ̓ .ËÍÁË
݅‹Ÿ‹ .˟‚›œ àŸž… ޟ› ނ›Î ڟ ÍË ÁÍ à‰• à— ËÍÁË Ä‚ˆ ÿÍ• ÿ‚Ý…‹Ÿ‹ ‚ƒ
Ë錂ƒ à…ŒÁË Î‚Ÿœ ͂ƒ ڟ ÎÁ ͅŒŸƒ ތŸ—Ÿ™„Á ÍËœÍ ÚŸ àƒ Å‹Á ޗ›› È ÿÍ•
.ŋÁ á͂›ŒŸƒ ÿ‚ŸÁΛ ÿÁÍÁË Ü˛ ޟÁ .˟‚›œ ÍËœÍ Åƒßœ ÎÁ Ç͂Š ÁÍ Å‚‰• ‚Ÿ
àƒ .ͅœŸÍ„ àƒ à‰• ܗ ܂‹ÍÁ ÿ‚‡ àƒ à—… à—… ÅÍߍƒ à‰• ܂‹ÍÁ à› ÎÁ ÜßÁ
ÿÁàéÕé•‚é‰ àƒ à— ÁÍ áͅà˟ˆŸ„ ł‰• à— ËËÿ› à΂‡Á à›‚œÍƒ àƒ ÃŸ…Í… ޟÁ
Ë韂éƒéœ à雂éœÍƒ .˜— È ¬ËœÍÁË Î‚Ÿœ ͘„‚ˆ Ë߇ߛ àՕ‚‰ ÎÁ ͅŒŸƒ ÿ™ŸŠ
à‰• ڟ ÍßԈ ˜Á˃ ˟‚ƒ Ԗ• à—™ƒ .˜— È ߉œ àˆ àƒ ÁÍ à—… ͝ à— ËœÁ˃
.˟‚›œ render ÁÍ

Þ闛› È ÿÍ• ÿ‚ž›…‹Ÿ‹ ¬Å™‚‰ ޟÁ ÍË .ŕ͘ ˝Áߊ à˞ƒ ÁÍ Í‚— àŸ–ƒ API
àéƒ ÿé˜é…‹ƒ Ùԛ ޟÁ à— ËœŸ‚›œ render ؙ…Š› ł•Ë ÍË ÁÍ à‰• ڟ à— Å‹Á
Ì钂— à…‹Ë Í˜Á ÝßË à™‰Í› ÍË .ËÍÁË à‰• ܛ‚— È ÿÁ̓ ΂Ÿœ ËÍߛ ÿ‚Å›‹–
ÞéŒéŸé—Ÿ™„Á à— Å‹Á ÝΚ ¬ËËƒ ܟ߉… ЗÍƒ ÁÍ ‚Ì’‚— ÒߍŠ› ͅœŸÍ„ ڟ ÿßÍ
Í靂éÕ ÞÀ Åé‹ÍË Ü闌ƒ output tray ÍË à— ¬Ëœ— È ؙ‚Š› އ ÍË ÁÍ ÚÍÁ˛
.Ëߌ

ÿéœÎ Ä‚éˆ ÿ‚éÍ‚é— ËÍÁË Ëßé‡ß Áß‚é‡ ÍË Ä‚éˆ ÜËé› ßË Rendeing ÿ‚éß阙Á
(Pageable Jobs) ÿœÎ à‰• ÿ‚Í‚— ß (Printable Jobs)

ÞéŸÁ ÍË .ŋÁ ͘ŸË ܲ ÎÁ ͅœ‚‹À šß›› Printable Jobs È àƒ Ô߃͛ ÍߛÁ
ÍßéÔéƒ Å‚é‰é•é .Ëߌÿ› à˂•…‹Á ÚÍÁ˛ àŸ™— ÿÁ̓ page Printer ÎÁ Ԗ• ܲ
àé‰é• ޟ͊À à— ÿ…–ß .˜ߌÿ› Öß͌ ͕ à‰• ‚ƒ à— ËœË͘ÿ› render ÿ™Á߅›
Ä‚éˆ ÿéÍé• Ý酋Ÿ‹ .ËË̓͘ No_Such_Page àƒ ËŸ‚ƒ Page Printer Ëߌÿ› È
ÿÁ̓ .ËË Ý‚‡œÁ ߅ͅ àƒ ÁÍ Å‚‰• render à›‚œÍƒ à— Ëœ—ÿ› ŋÁߊÍË àŒŸ›
Ý酋Ÿ‹ ¬ËœßŒ ÍËœÍ · ‚… µ à‰• ÎÁ àˌ ŋÁߊÍË ‚›Œ ތŸ—Ÿ™„Á ÎÁ ͘Á ¬Ü‚†›
¶ ¬µ à鉕 Ԗ• ‚›Á ¬ËŸ‚›œÿ› ÁÍ Ý…• à‰• ‚… ł‰• à› ŋÁߊÍË Ä‚ˆ ÿÍ•
ËéËƒ ނŒœ ÁÍ Print Dialog box ڟ ‚›Œ à›‚œÍƒ ͘Á .Ë͗ ˝Áߊ È ÁÍ · ß
ÁÍéŸÎ ¬ËéŒ ËéÁß銜 àËÁË Þ‚Œœ à‰• ÿßÍ ËœßŒ È ˟‚ƒ à— Å‚‰• ܗ à͂›Œ
.ݟœÁ˃ ܃– ÎÁ ܲ ޟÁ ÍË ÁÍ ÿ„‚ˆ ł‰• ËÁː… à— Å‹Á ޗ››ÍŸ’

ÎÁ áÍé…錟ƒ ؂ԐœÁ šß›› ÿœÎà‰• ÿ‚Í‚— (Pageable Jobs) ÿœÎà‰• ÿ‚Í‚—
à酌ÁË Ø™…Š› ق– ڟ ˜Á߅Ÿ› Pageable Jobs ÍË à‰• ͝ .ËÍÁË Ä‚ˆ ÿ‚Í‚—
ÎÁ ÿÁàéßé›é‡é› .ËßéŒÿ› à˂•…‹Á ‚žƒ‚…— ÍË šß›› Pageable Jobs ÎÁ .ˌ‚ƒ
ÚéœéŸÁ ÁÍ Book К— ڟ ޛ .˜Ë ނŒœ ÁÍ Ø™…Š› ÿ‚žƒ™‚• ˜œÁ߅ÿ› à— Å‚‰•
.ݟ‚›œÿ› ߘ΂ƒ ‚›Œ ÿÁ̓



:ˌ‚ƒÿ› ͟ΠłŠŒ› ÿÁÍÁË ÿœÎž‰• ͂— ڟ
ͅœŸÍ„ ڟ ˟œÁ߅ÿ› ܂†› ÿÁ̓ ˌ‚ƒ à…ŒÁË ÁÍ ËßéŠ Í酜ŸÍ„ ˜Á߅ÿ› à‰• ͝
ÁÍ Ã™‚Ô› ŋ͞• à— Í˜ŸË ͅœŸÍ„ ڟ ¬Ëœ— È ÁÍ à鉕 ˙‡ à— ËŸŒ‚ƒ à…ŒÁË
.˟‚›œ È ÁÍ ÚÍÁ˛ Üé— àé— Ýߋ ͅœŸÍ„ ß Ëœ— È

ڟ ÍË .˟Ÿ‚›œ ؟͐… ÁÍ ÿ…ß‚•…› ق– …— ͝ ÍË à‰• ͝ ÿÁ̓ ˟Áߊÿ›
.˟Ÿ‚›œ ߗͅ ݝ ‚ƒ ÁÍ Landscape ß Portrait ł‰• ˟œÁ߅ÿ› ÿœÎà‰• ͂—
Ä‚éˆ Åƒßœ ÎÁ Ç͂Š ÁÍ Å‚‰• à— ËÁߊƒ ‚›Œ à›‚œÍƒ ÎÁ ŋÁ ޗ›› ÿÍ• ݅‹Ÿ‹
Ãé™Ô› ޟÁ à͂ƒÍË .ËË͘ ØÌ‰ ŋÁ ޗ›› ÝΚ ÅÍߍ ÍË Å‚‰• ÎÁ ÿސƒ ß ËŸŸ‚›œ
ÚÍËé› ÍË Þ‚…΂Ÿœ ËÍߛ à— à‰• ËÁː… ͝ ˟œÁ߅ÿ› Þ߈ ¬ËŸŒ‚ƒ ÞÁ͘œ ˟‚ƒœ
.˟Ÿ‚›œ ݝÁ͕ ß àŸž… ¬ËŒ‚ƒ

.ŋÁ à‰• ˜ˆ ‚›Œ à˜ß̈́ ˜Á˃ à— ËÍÁ˜ á΂Ÿœ Pageable jobs

Book К—
ËéË ÿé› à΂‡Á ‚›Œ àƒ Ðš— ޟÁ .ŋÁ àˌ à•‚ŽÁ Book ˟ˇ К— 1.2 àŠ‹œ ÎÁ
ß ËßéŠ Åé›Íé• ËœÁ߅ÿ› à‰• ͝ .˟Ÿ‚›œ ݝÁ͕ ÁÍ Ëː…› ł‰• ‚ƒ ÚÍÁ˛ à—
͂éŸé‹éƒ ÚÍÁ˛ à— ËËƒ ÁÍ Ø‚ÔœÁ ޟÁ ‚›Œ àƒ ß ËŒ‚ƒ à…ŒÁË ÁÍ Ëߊ ͅœŸÍ„
˂é‡éŸÁ Pageable ÐéŸé•Íé…éœéŸÁ Book Ðšé— à—ŸŸ‚‡œÀ ÎÁ .˟Ÿ‚›œ àŸž… ÿ™‚
Ë韜Á߅ÿ› ݝ ‚›Œ ¬Å‹Ÿœ К— ޟÁ ÍË à— ËŸÍÁË Î‚Ÿœ ÿ˜ÏŸß àƒ ÿ…–ß ¬ËŸ‚›œŸ›
.ŋÁ ł‰• ÎÁ ÿÁàß›‡› ͘œ‚Ÿ‚›œ К— ޟÁ .˟œ— ˂‡ŸÁ ÁÍ Þ‚…Ëߊ Book К—
łé‰é•é ÞËÍé— à•‚ŽÁ ÿÁ̓ .ŋŸ™‚Р𛂗 Book ÿŸŒ Ëߌÿ› ˂‡ŸÁ ÿ…–ß Á˅ƒÁ
à͂éƒÍË Þé› Å‚é‰ŸŽß… àƒ) ˟Ÿ‚›Í•ƒ Š…œÁ ÁÍ ÍŸÎ ÑßÍ ßË ÎÁ ÿ—Ÿ ˟œÁ߅ÿ›
˅› ޟÁ ͅ›Á͂„ .(˟Ÿ‚›Í•ƒ à‡ß… ͅŒŸƒ łŸŸÎ‡ ÿÁ̓ API ъƒ ÍË Class ޟÁ
ÿ韌 ڟ ß .˜Ÿ‚›œ ÿ› ޟŸ… ÁÍ à‰• ÿ—ŸÎŸ• łŠŒ› à— Å‹Á PageFormat ÿŸŒ
Íé˜Á .Ë韂é›éœÿé› ÜŸ›—… ÁÍ Printable П•Í…œŸÁ à— ËÍÁË Ëß‡ß PagePrinter
Íé…é›ÁÍ‚é„ ÿé˜Ë‚é‹ àéƒ ¬ËéŸéœÁËÿé›éœ ËßéŠ ÚÍËé› ÿßÍ ÁÍ àé‰é•é à͂é›éŒ
Íßԃ È ݅‹Ÿ‹ .˟œ— ËÍÁß append() ˅› ÍË ÁÍ UNKNOWN_NUMBER_OF_PAGES
‚é… Ëéœé—ÿé› Á˟„ ÁÍ à‰• à͂›Œ …— ÍË Å‚‰• àŸ™— ÞËÎ Áˍ ‚ƒ ڟ…‚›ß…Á
.ˋ̓ NO_SUCH_PAGE ÍÁ˖› àƒ à—œŸÁ

‚é› Üéƒé– ÿ‚éžéŒŠƒ ÍË .˜ߌÿ› ݂’ËÁ ъƒ ޟÁ ÍË ÞŸÍ›… ß áÍßì… API Ýߞ•›
ÍË .ݟË͗ щ rendering ÿ‚ž™Ë› ß á͟˜ àÎÁ˜Á ÿ‚Ë‰Áß ¬à‰• ܗŒ à͂ƒÍË
àƒ Î‚Ÿœ à— ÿŸ‚ž‹š— ݂›… .Ë͗ ݟÁߊ Í՜ Java Printing API àƒ ‚› ъƒ ޟÁ
͂éžéˆ ß ÐŸ•Í…œŸÁ à‹ ÎÁ à— ËœÍÁË ÍÁ͖ java.awt.print à…‹ƒ ÍË ËœÍÁË Ä‚ˆ
àé…é‹éƒ ÿ‚ž™ßˇ ß ‚ž‹š— à˜Ë ނŒœ ÜŸÌ ÿ‚ž™ßˇ .˜Áàˌ ܟ—Œ… ؙ…Š› К—
.ˌ‚ƒÿ› print

Name Type Description
Paper Class This class defines the page's physical characteristics.
PageFormat Class PageFormat defines the page's size and orientation. It also defines which Paper to use when rendering a page.
PrinterJob Class This class manages the print job. Its responsibilities include creating a print job, displaying a print dialog box when necessary, and printing the document.
Book Class Book represents a document. A Book object acts as a collection of pages. Pages included in the Book can have identical or differing formats and can use different painters.
Pageable Interface A Pageable implementation represents a set of pages to be printed. The Pageable object returns the total number of pages in the set as well as the PageFormat and Printable for a specified page. The Book class implements this interface.
Printable Interface A page painter must implement the Printable interface. There is only one method in this interface, print().
PrinterGraphics Interface The Graphics object implements this interface. PrinterGraphics provides the getPrinterJob() method to obtain the printer job that instantiated the print process.


Pageable П•Í…œŸÁ
:ËË͘ÿ› ܟ—Œ… ˅› à‹ ÎÁ Pageable П•Í…œŸÁ

Method Name Description
int getNumberOfPages() Returns the number of pages in the document.
PageFormat getPageFormat(int pageIndex) Returns the page's PageFormat as specified by pageIndex.
Printable getPrintable(int pageIndex) Returns the Printable instance responsible for rendering the page specified by pageIndex.


Printable П•Í…œŸÁ
:Ëߌÿ›ÜŸ—Œ… ÍÁ˖› ßË ß Ë…› ڟ ÎÁ Printable П•Í…œŸÁ

Name Type Description
int print(Graphics graphics, PageFormat pageFormat, int pageIndex) Method Requests that the graphics handle using the given page format render the specified page.
NO_SUCH_PAGE Value This is a constant. Return this value to indicate that there are no more pages to print.
PAGE_EXISTS Value The print() method returns PAGE_EXISTS. It indicates that the page passed as a parameter to print() has been rendered and does exists.



à闟Ÿ‚‡œÀ ÎÁ ¬ËŸ‚›œ ˂‡ŸÁ ÁÍ Printable П•Í…œŸÁ ڟ ˟‚ƒ ͅœŸÍ„ à‰• ͝
ނé‹À ÍéÕéœ àƒ ÿÁà‰• ÿ‚Í…œŸÍ„ ˂‡ŸÁ ¬Å‹Á Ë߇ߛ ˂‡ŸÁ ÿÁ̓ ÑßÍ ÚŸ Ԗ•
Íé àé— ËéŒ‚éƒ Í˂– ˟‚ƒ ‚›Œ ˗ à— ËŸŒ‚ƒ à…ŒÁË Ë‚Ÿƒ ˟‚ƒ àˆ Í˜Á .ˋÍÿ›
.˟‚›œ render Ńߜ ÎÁ Ç͂Š ‚Ÿ ܊ÁË ÍË ÁÍ à‰•

ß ËßéŒÿé› Üé›‚éŒ Î韜 ÁÍ Graphics à— Å‹Á Ë߇ߛ print() ÿÁ̓ ͅ›Á͂„ à‹
ÎÁ .ËËÍé˜ÿé› à˂é•é…é‹Á àé‰é• ÿßÍ Ý‹Í ÿÁ̓ à— ËŒ‚ƒÿ› ÿžƒ‚Œ› К— ÿÁÍÁË
¬Ë韂é›éœÿé› Ë‚é‡éŸÁ ÁÍ PrinterGraphic Ð韕ͅœŸÁ Graphics К— à—ŸŸ‚‡œÀ
Íé˜Á .Ë韂›œÿ› instantiate ÁÍ Ä‚ˆ à— ËŸÍßÀ ŋ˃ ÁÍ PrinterJob ˟œÁ߅ÿ›
ÿé› ¬ËÍÁË Ýé‹Í à…•ÍŒŸ„ ÿ‚žŸ˜ÏŸß ÿސƒ àƒ Î‚Ÿœ ß Å‹Á à˟ˆŸ„ ‚›Œ à‰• ÉÍÔ
ÎÁ Ðé„ .Ë韟‚›œ ܟ˃… Graphics_2D ÿŸŒ àƒ ÁÍ Graphics ÿ‚Í…›Á͂„ ˟œÁ߅
.˟Ÿ‚›œ Á˟„ ÿ‹Í…‹Ë Á߂‡ áːƒßË ÿ‚API ÿ›‚›… àƒ ËŸœÁ߅ÿ› ÞÀ

ËéœéÁߊœ ܟ˃… È ܃‚– ܉› Ĉ ś‹ ÿš‚ƒ àƒ Å‚…Š› à— ËŸŒ‚ƒ à…ŒÁË à‡ß…
.˟Ÿ‚›œ Á˟„ ÁÍ Ó͕ џ„ Öß͌ àԖœ ܉› ‚… ˟Ÿ‚›œ à‡Á͛ ³ ܗŒ àƒ .ˌ


.˟Ÿ‚›œ à‡Á͛ È ܃‚– ܉› ³ ܗŒ àƒ

±x± ܟԅ‹› ڟ È ÿÁ̓ .ˌ‚ƒÿ› ͅœŸÍ„ àŸŒ‚‰ ÿš‚ƒ ś‹– à˜Ë ނŒœ (0,0)
à˂镅‹Á ÜŸÌ ÿ‚Ë— ‚ƒ ÁÍ Äˆ ś‹ àŸŒ‚‰ ß š‚ƒ ś‹– ÎÁ ȜŸÁ ± ˟‚ƒ , ȜŸÁ
.˟Ÿ‚›œ


1: public int print (Graphics graphics, PageFormat pageFormat, int pageIndex) {

2: Graphics2D graphics2D = (Graphics2D) graphics;

3: Rectangle2D.Double rectangle = new Rectangle2D.Double ();

4: rectangle.setRect (pageFormat.getImageableX () + 72,

5: pageFormat.getImageableY () + 72,

6: 72,

7: 72);

8: graphics2D.draw (rectangle);

9: return (PAGE_EXISTS);

}


àé›é‡Íé… ÁÍ ÜéŸéԅ‹› Á˃› ÿ…‹Ë Íßԃ ˟‚ƒ ‚› à— ÝŸƒ‚Ÿÿ› ÍË ÿ™ƒ– ܂†› ÎÁ
ނé‹À ÿÁÍéƒ .ËËÍé˜ Ä‚éˆ ± ܗŒ ˜œ‚› È àŸ‰‚œ ÿš‚ƒ ÍË ËœÁ߅ƒ à— ÝŸŸ‚›œ
܃‚– Á˃› ÞÁߜƒ (0,0) ÎÁ ß ÝŸŸ‚›œ à›‡Í… ͂ƒ—Ÿ ÁÍ Å‚…Š› ˟‚ƒ ˗ ÞËߛœ
ÝéŸéÁßéŠ ÜŸÌ ÑŠƒ àƒ Üƒ– àœß›œ ܗŒ ͟Ÿ“… ß ÉšÁ ‚ƒ .ݟŸ‚›œ à˂•…‹Á È
.˟‹Í

1: public int print (Graphics graphics, PageFormat pageFormat, int pageIndex) {

2: Graphics2D graphics2D = (Graphics2D) graphics;

3: graphics2D.translate (pageFormat.getImageableX (), pageFormat.getImageableY ());

4: Rectangle2D.Double rectangle = new Rectangle2D.Double ();

5: rectangle.setRect (72, 72, 72, 72);

6: graphics2D.draw (rectangle);

7: return (PAGE_EXISTS);

8: }



ݟŸ‚›œ à›‡Í… ÁÍ Å‚…Š› ݟœÁ߅ ÿ› ³ Ԋ ÍË translate() ˅› ÎÁ à˂•…‹Á ‚ƒ
Ë鐃 àƒ àԖœ ޟÁ ÎÁ .ݟŸ‚›œ ݟ՜… È ܉› ÿš‚ƒ ÍË ÁÍ (0,0) Á˃› àԖœ ß
.˟Ë͘ ˝Áߊ ނ‹À ß Í…Š› ‚› ˗



PrinterGraphics П•Í…œŸÁ
:ËË͘ÿ› ܟ—Œ… ˅› ڟ ÎÁ PrinterGraphics П•Í…œŸÁ

Method name Description
PrinterJob getPrinterJob() Returns the PrinterJob for this rendering request and is implemented by the Graphics class



Paper К—
:ËË͘ÿ› ܟ—Œ… ˅› Ō ÎÁ Paper К—

Method name Description
double getHeight() This method returns the page's physical height in points (1 inch = 72 points). For example, if you are printing on a letter-size page, the return value will be 792 points, or 11 inches.
double getImageableHeight() This method returns the page's imageable height. The imageable height is the height of the print area that you may draw on. See Figure 1 for a graphical view of the imageable area.
double getImageableWidth() This method returns a page's imageable width (the width of the print area that you may draw on). See Figure 1 for a graphical view of the imageable area.
double getImageableX() This method returns the x origin of the imageable area. Since there is no support for margins, the return value represents the left margin.
double getImageableY() This method returns the y origin of the imageable area. The value returned from this method is equivalent to the top margin.
double getWidth() This method returns the page's physical width in points. If you print on a letter-size paper, the width is 8.5 inches, or 612 points.
void setImageableArea(double x, double y, double width, double height) This method sets the imageable area and specifies the margins on the page. Actually, the API provides no method to set the margins explicitly; you have to calculate them yourself.
void setSize(double width, double height) This method sets the physical page size. To define an 8.5-by-11-inch sheet, you would supply 612 and 792 points. Note that the default size is LETTER.


Paper Ðšé— àé— ËéŸéŒ‚éƒ à酌ÁË ÍԂŠƒ ݟß̓ áːƒ ś‹– ×Á͋ à—œŸÁ ÎÁ ܃–
ÿ雂雅 à˜ÍÁË Íƒ ÍË PageFormat К— .˜—ÿ› ؟͐… ÁÍ Ì’‚— ÿ—ŸÎŸ• łŠŒ›
Ðšé— ÞŸÁ àŒŸ› .ˌ‚ƒÿ› ̒‚— Öߜ ß àÎÁ˜Á ¬Ì’‚— އ ˜œ‚› ̒‚— ÿ‚žŸ˜ÏŸß
.ËßéŒÿé› àËÁË Í߃ Printable П•Í…œŸÁ ÍË print() ˅› àƒ áͅ›Á͂„ ÅÍߍƒ
Ãé™‚é– ÍË Ìé’‚é— Åéžé‡ ß àÎÁ˜Á ¬Ä‚ˆ ܃‚– ÿ‚Ž• ÞËÍßÀ ŋ˃ އ Paper ÎÁ
.Ëߌÿ› à˂•…‹Á Пͅ‚›

PageFormat К—
:ËË͘ÿ› ܟ—Œ… ˅› ±² ÎÁ PageFormat К—

Method name Description
double getHeight() This method returns the page's physical height in points (1 inch = 72 points). If your page measures 8.5 by 11 inches, then the return value will be 792 points, or 11 inches.
double getImageableHeight() This method returns the page's imageable height, which is the height of the print area on which you may draw. See Figure 1 for a graphical view of the imageable area.
double getImageableWidth() This method returns the page's imageable width -- the width of the print area on which you may draw. Figure 1 illustrates a graphical view of the imageable area.
double getImageableX() This method returns the x origin of the imageable area.
double getImageableY() This method returns the imageable area's y origin.
double getWidth() This method returns the page's physical width in points. If you print on letter-sized paper, the width is 8.5 inches, or 612 points.
double getHeight() This method returns the page's physical height in points. For example, letter-sized paper is 11 inches in height, or 792 points.
double[] getMatrix() This method returns a transformation matrix that translates user space into the requested page orientation. The return value is in the format required by the AffineTransform constructor.
int getOrientation() This method returns the orientation of the page as either PORTRAIT or LANDSCAPE.
void setOrientation(int orientation) This method sets the orientation of the page, using the constants PORTRAIT and LANDSCAPE.
Paper getPaper() This method returns the Paper object associated with the page format. Refer to the previous section for a description of the Paper class.
void setPaper(Paper paper) This method sets the Paper object that will be used by the PageFormat class. PageFormat must have access to the physical page characteristics to complete this task.



PrinterJob К—
Ýé Ü‚é‰ ÞŸ ÍË ËœÁ߅ÿ› ß Ëœ— ÿ› Üͅœ— ÁÍ Ä‚ˆ ͂— ނŸÍ‡ PrinterJob К—
ܛ‚— Íßԃ К— ޟÁ łŠŒ› ÜŸÌ ÍË .˟‚›œ á΂‹‚‡ ß Üͅœ— ÁÍ PrinterJob ڟ
.ŋÁ àˌ ͗Ì

Method name Description
abstract void cancel() This method cancels the current print job. You can validate the cancellation with the isCancel() method.
abstract boolean isCancelled() This method returns true if the job is cancelled.
PageFormat defaultPage() This method returns the default page format for the PrinterJob.
abstract PageFormat defaultPage(PageFormat page) This method clones the PageFormat passed in parameters and modifies the clone to create the default PageFormat.
abstract int getCopies() This method returns the number of copies that the print job will print.
abstract void setCopies(int copies) This method sets the number of copies that the job will print. Note that if you show a print dialog box, users can alter the number of copies (see the pageDialog method).
abstract String getJobName() This method returns the job name.
static PrinterJob getPrinterJob() This method creates and returns a new PrinterJob.
abstract String getUserName() This method returns the user name associated with the print job.
abstract PageFormat pageDialog(PageFormat page) This method displays a dialog that allows the user to modify the PageFormat. The PageFormat, passed in parameters, sets the fields of the dialog. If the user cancels the dialog, then the original PageFormat will be returned. But if the user accepts the parameters, then a new PageFormat will be created and returned. Since it will not show the same parameters on all operating systems, you must be careful when using the pageDialog.
abstract void setPageable(Pageable document) This method queries the document to obtain the total number of pages. The Pageable will also return the PageFormat and the Printable object for each page. See the definition of the Pageable interface for more information.
abstract void setPrintable(Printable painter) This method sets the Painter object that will render the pages to be printed. A Painter object is an object that implements the Printable class and its print() method.
abstract void setPrintable(Printable painter, PageFormat format) This method completes the same tasks as abstract void setPrintable(Printable painter), except that you supply the PageFormat that the Painter will use. As indicated in the definition of the Printable interface, the print() method passes a PageFormat object as the first parameter.
abstract void print() This method prints the document. It actually calls the print() method of the Painter previously assigned to this print job.
abstract void setJobName(String jobName) This method sets the name of the print job.
abstract boolean printDialog() This method displays a print dialog box that allows the user to change the print parameters. Note that this interaction's result will not be returned to your program. Instead, it will be passed to the peer operating system.
abstract PageFormat validatePage(PageFormat page) This method will validate the PageFormat passed in parameters. If the printer cannot use the PageFormat that you supplied, then a new one that conforms to the printer will be returned.


Book К—
:˜Ëÿ› ܟ—Œ… ÁÍ Book К— ˅› ŕ

Method name Description
void append(Printable painter, PageFormat page) This method appends a page to the Book. The painter and the PageFormat for that page are passed in parameters.
void append(Printable painter, PageFormat page, int numPages) This method completes the same tasks as void append(Printable painter, PageFormat page), except that you specify the number of pages.
int getNumberOfPages() This method returns the number of pages currently in the Book.
PageFormat getPageFormat(int pageIndex) This method returns the PageFormat object for a given page.
Printable getPrintable(int pageIndex) This method returns the painter for a given page.
void setPage(int pageIndex, Printable painter, PageFormat page) This method sets the painter and the PageFormat for a given page already in the book.






È ÿ‚ž™›™ÁÍ߅‹Ë
˂é‡éŸÁ PrintJob ÿéŸéŒ ڟ Á˅ƒÁ ÍË .ŋÁ ނ‹À ͂Ÿ‹ƒ È ÿÁ̓ ܛ™ÁÍ߅‹Ë
.˟Ÿ‚›œ

PrinterJob printJob=PrinterJob.getPrinterJob();

PrinterJob àƒ ‚ƒ printer ÿŸŒ PrinterJob ÎÁ setPrintable() ˅› ÎÁ à˂镅‹Á ‚ƒ Є‹
àé— Åé‹Á ÿéŸéŒ ނ雝 printer ÿŸŒ ڟ à— ËŸŒ‚ƒ à…ŒÁË à‡ß… .˟œ— (assign) ٚÔÁ
.Ë΂‹ÿ› ÁÍ Printable П•Í…œŸÁ

printJob.setPrintable(Painter);


.˟Ÿ‚›Í•ƒ ݟ՜… Painter ‚ƒ ÁÍ PageFormat ˟œÁ߅ÿ› à—œŸÁ ‚Ÿ

printJob.setPrintable(Painter, pageFormat);


.˟‚›œ ˂‡ŸÁ ÁÍ print() ˅› ˟‚ƒ Painter ÿŸŒ ݂‡œÁ͋ ß

public int print(Graphics g, PageFormat pageFormat int page)


ÞËÍé— render ÿÁ̓ ÞÀ ÎÁ à— Å‹Á graphics handle ͅ›Á͂„ ޟ…‹Šœ ‚‡œŸÁ ÍË
áÍ‚é‡ Å‚é‰• ÿÁ̓ ÞÀ ÎÁ à— Å‹Á ÿ…›Í• pageFormat .˟Ÿ‚›œÿ› à˂•…‹Á à‰•
ÞéŸÁ .ËßéŒ render ˟‚ƒ à— Å‹Á à‰• à͂›Œ ÿŸ‚žœ ͅ›Á͂„ ß Ëߌÿ› à˂•…‹Á
.ŕ͘ÿ› ÍÁ͖ à˂•…‹Á ËÍߛ ނ‹À È ڟ ÿÁ̓ ˟‚ƒ à— Ë߃ áÍߛÁ àŸ™—

‚›Œ ÿÁ̓ àß›‡› ޟÁ ÍË ‚› à— ÿ„‚ˆ Ã߈͂žˆ ͂— ÿ™Á Ã߈͂žˆ ̓ ÿÁ à›Ë–›
áÍ酌Ÿƒ ؂ԐœÁ ß Ë߃ ˝Áߊ ܖ…‹› 𛂗 Java Printing API ÎÁ ݟËÍßÀ Ë߇߃
àéƒ ÞÀ ͂酊‚‹ ß ÃŸ—Í… .ËÁË ËÁߊ ނŒœ ؙ…Š› ÿ‚žŸ‡ß͊ ˟™ß… ËÍߛ ÍË ÁÍ
ÎÁ à˂•…‹Á ގ .˟œ— ˂‡ŸÁ ÿ„‚ˆ ‚ŸŒÁ ß Å‚‰• ¬ÚÍÁ˛ à— ËË ÿ› à΂‡Á ‚›Œ
àéƒ ÁÍ Å‚é‰• à—Ÿ™‚‰ ÍË ÁÍ ÿ„‚ˆ ‚ŸŒÁ ŜŸÍ„ à— Å‹œÁ߅ ˟Áߊ ¬ÃŸ—Í… ޟÁ
ÿ‚éAPI ÎÁ ͘Á .˟Ÿ‚›œ à•‚ŽÁ ÞÀ ÎÁ à‰• ڟ àƒ ¬ËŸŸ‚›œÿ› à•‚ŽÁ ÿÁà˜ß̈́
àéƒ ÁÍ export ÿ‚éžéŸé˜ÏéŸß ÿé…é‰ÁÍ àéƒ Ë韜Á߅ÿ› ¬ËŸŸ‚›œÿ› à˂•…‹Á È
Íé…éœéŸÍé„ àéƒ ‚é›éŸé–…‹› à—œŸÁ ‚Ÿ ¬ËŸŸ‚›œ à•‚ŽÁ HTML ‚Ÿ PDF ÿ‚à˜ß̈́
àËéŒ Ä‚éˆ ÚÍÁËé› àéŸéž… ܉Á͛ ÞË͗ ނ‹À Ã߈͂žˆ ¬ÿ™Á ØË ‚›Á .˟…‹Í•ƒ
à‰• ڟ ‚ƒ Ԗ• ¬ËŸœ—ÿ› à˂•…‹Á È ÿ‚API ÎÁ È ݂˜œ ÍË ÿ…–ß .ˌ‚ƒÿ›
¬‚éžé•Á͘Á͂„ ݟ‚•› ޟœˆ› .ˌ ˟Áߊ ß̓ßÍ ¬ÞÀ ÿßÍ ÝŸ‹Í… ÿÁ̓ ڟ•Á͘
ÁÍéŸÎ ¬ËœÍÁ˜ Ëß‡ß ¬headers/footers ‚Ÿ ‚ž™ßˇ ¬‚ž—Ÿ•Á͘ ¬‚ž›‹Í ¬ÍŸß‚…
.ËéŸéœé— àƒ‹‚‰› ނ…Ëߊ ÁÍ Ä‚ˆ ܃‚– àËßˉ› ւ•…ÍÁ ß Ó͏ (x,y) Á˃› ˟‚ƒ
.ËÁË ËÁߊ ɟŽß… ÁÍ ØŽ Ԃ–œ ޟÁ ÿ›‚›… ‚› È Ã߈͂žˆ

á͟˜ à‡Ÿ…œ
¬áÍéŸé˜ àÎÁ˜Á ÿ‚Ë‰Áß àƒ .ݟËÁË ÉŸŽß… ÁÍ ÿ›ž› ͂Ÿ‹ƒ łŸì· ъƒ ޟÁ ÍË
ÍéÕéœ ‚éžéƒ‚…— ß (Printable ß Pageable) rendering ÿߘ™Á ßË ¬à‰• ߗͅ
àé›é…‚éŠ API È à‚ƒÍË Éß͌› ͟‹•… ڟ ‚ƒ "‚…‡Ÿ…œ ß ÝŸËߛœ ÿ‹Í̓ ß àË͗
Îé—Í雅 ͂— ݂‡œÁ އ ÿ•‚— ޟ͛… ‚ƒ ß Ë— ÿßÍ "‚•͍ áːƒ ś‹– ÍË .ݟËÁË
ËËéé…é› ÿ‚éÝÍé•é…š„ ÍË Ä‚ˆ ݂˜œ ÍË à— ÿŸ‚à™‚–› àƒ ‚œ›Ž .Ë͗ ݟÁߊ
ÎÁ ÜéŸéé•… àƒ ³ ъƒ ÍË .Ëߛœ ݟÁߊ ÿ‹Í̓ ß à˜—•Á Í՜ ¬ÝŸœ—ÿ› ËÍߊ̓
.Ëߛœ ݝÁߊ Ɖƒ Ã߈͂žˆ ˂‡ŸÁ ß ÉÍÔ

à˜‹Ÿßœ ÿ•͐›
܂‹ ÍË ÁÍ Infocom ÿß .ŋÁ Á߂‡ Í߂Œ› ڟ Jean-Pierre Dube
¬Ë韙߅ ܛ‚Œ à— Å‹Á ÿÁà…•ÍŒŸ„ ÿ‚à›‚œÍƒ ÿÁÍÁË Infocom .Ëߛœ П‹‚… ±¹¹ž
àƒÍ‡… ÿÁÍÁË Jean-Pierre .ˌ‚ƒÿ› ş͟˛ Ԋ ÍË ‘Ÿ‹ß ЂŸ–› ÍËÚÍÁ˛ ş͟˛
ËßéŠ Í‚é— á͋ ޟÁ ÿß .ˌ‚ƒÿ› Á߂‡ ß C ¬Visual basic ÍË ÿÁàËͅ‹˜ ß ‘Ÿ‹ß
.ŋÁ àËߛœ Á˝Á ¬ÅŒÌ˜ ÍË à™‚–› ޟÁ ޅŒßœ ݂˜œ ÍË à— ÑÍ˂› àƒ ÁÍ



Resources
"Printing in Java," Jean-Pierre Dubé (JavaWorld)
Part 1: Acquaint yourself with the Java printing model
Part 2: Print your first page and render complex documents
Part 3: Jean-Pierre Dubé introduces the print framework that works on top of the Java Print API

You will find tons of books covering Java AWT, but none will cover this subject to the extent of this book. If you're writing GUIs, you must have this book next to your computer: Graphic Java 2, Mastering The AWT, Volume 1, David M. Geary (Prentice Hall, 1998):
http://www.amazon.com/exec/obidos/ASIN/0130796662/o/qid=970872039/sr=2-2/102-2403269-9106541

This book was helpful when Java 1.1 came out, and was the first to talk about printing in Java: Migrating from Java 1.0 to Java 1.1, Daniel I. Oshi and Pavel A. Vorobiev (Ventana Communications Group, 1997):
http://www.amazon.com/exec/obidos/ASIN/1566046866/o/qid=969489411/sr=8-1/ref=aps_sr_b_1_3/002-2488903-6332023

Probably the best book on Java 2D, this book covers all aspects of the 2D API and also provides a Graphics framework for advanced 2D compositions: Java 2D API Graphics, Vincent J. Hardy (Prentice Hall, 1999):
http://www.amazon.com/exec/obidos/ASIN/0130142662/qid=969489696/sr=1-1/002-2488903-6332023

An excellent introduction to the Java 2D API: "Getting Started with Java 2D," Bill Day (JavaWorld, July, 1998):
http://www.javaworld.com/javaworld/jw-07-1998/jw-07-media.html

A reference document on the 2D API: Programmer's Guide to the Java 2D API, Sun Microsystems:
ftp://ftp.java.sun.com/docs/j2se1.3/j2d-book.pdf


ÿ‡œ‹Í՜
ޟÁ ËÍߛ ÍË ÁÍ Ëߊ Í՜
:˟Ÿß˜ƒ ‚› àƒ Ã™Ô›

ÑÎÍÁ ‚ƒ ÿ™ŸŠ -
ÑÎÍÁ ‚ƒ -
ÑÎÍÁÿƒ -

ÿœ šßÔ ÿ™ŸŠ -
˂œ› -
à‚…ß— -

ÿŠ… ÿ™ŸŠ -
Ãߙԛ -
ŋŸœ ÿŠ… ÿ•‚— àÎÁ˜Á àƒ -


:݂œ

:ڟœßͅ—™Á ŋ„

: ŗ͌ ݂œ








Copyright 2001, PC WORLD Iran/ . All rights reserved.