質問編集履歴

4

修正

2016/02/05 08:48

投稿

3buro
3buro

スコア29

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,11 @@
6
6
 
7
7
  コードに記述を追加しました。
8
8
 
9
- KGサイズの指定を行ているのですが、印刷ではやはりL版になってしまいます...
9
+ KGサイズの指定を行い、取得もできているのですが、
10
+
11
+ 実際に印刷すると下の方が少し切れてしまうので、
12
+
13
+ その対処法をご存知の方いらっしゃいませんか?
10
14
 
11
15
 
12
16
 
@@ -38,79 +42,79 @@
38
42
 
39
43
 
40
44
 
41
- let printInfo = UIPrintInfo.printInfo()
45
+ let letterData = NSData(data: UIImagePNGRepresentation(image!)!)
42
46
 
43
47
 
44
48
 
45
- printInfo.outputType = .Photo
49
+
46
50
 
51
+ if UIPrintInteractionController.canPrintData(letterData) {
52
+
53
+
54
+
47
- printInfo.jobName = "HAGAKI"
55
+ printController.delegate = self
48
56
 
49
57
 
50
58
 
51
- //追加
59
+ let printInfo = UIPrintInfo.printInfo()
52
60
 
53
- printInfo.orientation = .Portrait
61
+
54
62
 
63
+ printInfo.outputType = .Photo
64
+
65
+ printInfo.jobName = "HAGAKI"
66
+
67
+
68
+
69
+ //追加
70
+
71
+ printInfo.orientation = .Portrait
72
+
55
- if image.size.width > image.size.height {
73
+ if image.size.width > image.size.height {
56
74
 
57
75
  printInfo.orientation = .Landscape
58
76
 
59
- }
77
+ }
60
78
 
61
79
 
62
80
 
63
- printInfo.duplex = .None
81
+ printInfo.duplex = .None
64
82
 
65
83
 
66
84
 
67
- printController.printInfo = printInfo
85
+ printController.printInfo = printInfo
68
86
 
69
- printController.printingItems = [
87
+ printController.printingItems = [
70
88
 
71
- printInfo,
89
+ printInfo,
72
90
 
73
- image
91
+ letterData
74
92
 
75
- ]
93
+ ]
76
94
 
77
- printController.showsNumberOfCopies = true
95
+ printController.showsNumberOfCopies = true
78
96
 
79
97
  printController.showsPageRange = false
80
98
 
81
99
  printController.showsPaperSelectionForLoadedPapers = true
82
100
 
101
+
102
+
83
-
103
+ }
104
+
105
+
106
+
107
+ //printController.presentAnimated(true, completionHandler: nil)
84
108
 
85
109
 
86
110
 
87
- printController.presentAnimated(true, completionHandler: nil)
88
-
89
-
90
-
91
- }
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
- func printInteractionController(printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -> UIPrintPaper {
111
+ let activityViewController = UIActivityViewController(activityItems: printController.printingItems!, applicationActivities: nil)
100
-
101
-
102
-
103
- let custompapersize: CGSize = CGSizeMake(4 * 72.0, 6 * 72.0)
104
-
105
- let paper:UIPrintPaper = UIPrintPaper.bestPaperForPageSize(custompapersize, withPapersFromArray: paperList)
106
112
 
107
113
 
108
114
 
109
- print(paper)
115
+ presentViewController(activityViewController, animated: true, completion: nil)
110
116
 
111
117
 
112
-
113
- return paper
114
118
 
115
119
  }
116
120
 

3

コードの修正

2016/02/05 08:48

投稿

3buro
3buro

スコア29

test CHANGED
File without changes
test CHANGED
@@ -74,7 +74,11 @@
74
74
 
75
75
  ]
76
76
 
77
- printController.showsNumberOfCopies = false
77
+ printController.showsNumberOfCopies = true
78
+
79
+ printController.showsPageRange = false
80
+
81
+ printController.showsPaperSelectionForLoadedPapers = true
78
82
 
79
83
 
80
84
 

2

内容の修正

2016/02/05 07:58

投稿

3buro
3buro

スコア29

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,12 @@
1
1
  いつもお世話になっております。
2
+
3
+
4
+
5
+ ---2/5追記---
6
+
7
+ コードに記述を追加しました。
8
+
9
+ KGサイズの指定を行っているのですが、印刷ではやはりL版になってしまいます...
2
10
 
3
11
 
4
12
 
@@ -14,7 +22,11 @@
14
22
 
15
23
 
16
24
 
25
+ let printController = UIPrintInteractionController.sharedPrintController()
26
+
27
+
28
+
17
- UIGraphicsBeginImageContextWithOptions(self.letterSetView.bounds.size, self.letterSetView.opaque, 2.0)
29
+ UIGraphicsBeginImageContextWithOptions(self.letterSetView.bounds.size, self.letterSetView.opaque, 3.0)
18
30
 
19
31
  let context = UIGraphicsGetCurrentContext()
20
32
 
@@ -36,7 +48,25 @@
36
48
 
37
49
 
38
50
 
51
+ //追加
52
+
53
+ printInfo.orientation = .Portrait
54
+
55
+ if image.size.width > image.size.height {
56
+
57
+ printInfo.orientation = .Landscape
58
+
59
+ }
60
+
61
+
62
+
63
+ printInfo.duplex = .None
64
+
65
+
66
+
67
+ printController.printInfo = printInfo
68
+
39
- let printActivityItems: [AnyObject] = [
69
+ printController.printingItems = [
40
70
 
41
71
  printInfo,
42
72
 
@@ -44,17 +74,39 @@
44
74
 
45
75
  ]
46
76
 
77
+ printController.showsNumberOfCopies = false
78
+
47
79
 
48
80
 
49
81
 
50
82
 
51
- let activityViewController = UIActivityViewController(activityItems: printActivityItems, applicationActivities: nil)
83
+ printController.presentAnimated(true, completionHandler: nil)
52
84
 
53
-
85
+
54
86
 
87
+ }
88
+
89
+
90
+
91
+
92
+
93
+
94
+
55
- presentViewController(activityViewController, animated: true, completion: nil)
95
+ func printInteractionController(printInteractionController: UIPrintInteractionController, choosePaper paperList: [UIPrintPaper]) -> UIPrintPaper {
96
+
97
+
98
+
99
+ let custompapersize: CGSize = CGSizeMake(4 * 72.0, 6 * 72.0)
100
+
101
+ let paper:UIPrintPaper = UIPrintPaper.bestPaperForPageSize(custompapersize, withPapersFromArray: paperList)
56
102
 
57
103
 
104
+
105
+ print(paper)
106
+
107
+
108
+
109
+ return paper
58
110
 
59
111
  }
60
112
 

1

タイトル編集

2016/02/05 04:59

投稿

3buro
3buro

スコア29

test CHANGED
@@ -1 +1 @@
1
- 【swift】はがき・KGサイズへの印刷方法
1
+ 【swift】AirPrintではがきサイズへの印刷方法
test CHANGED
File without changes