@@ -114,17 +114,34 @@ class Exporter: NSObject {
114114 if documentObject. picture. isValid {
115115
116116 if let tiff = documentObject. picture. tiffRepresentation {
117- let string = tiff. base64EncodedString ( options: . lineLength64Characters)
118- // script = script.replaceFirstOccurrence(of: "#PICTURE#", with: string)
119- // currently commented out, need to test
120- script = script. replaceFirstOccurrence ( of: " #PICTURE# " , with: " " )
117+ let string = tiff. base64EncodedString ( )
118+
119+ var firstString = " "
120+ var secondString = " "
121+ var thirdString = " "
122+ let third = string. count / 3
123+
124+ let index = string. index ( string. startIndex, offsetBy: third)
125+ firstString = String ( string [ ..< index] )
126+ let startIndex = string. index ( string. startIndex, offsetBy: third)
127+ let endIndex = string. index ( startIndex, offsetBy: third)
128+ secondString = String ( string [ startIndex..< endIndex] )
129+ thirdString = String ( string [ endIndex..< string. endIndex] )
130+
131+ script = script. replaceFirstOccurrence ( of: " #FIRSTCHUNK# " , with: firstString)
132+ script = script. replaceFirstOccurrence ( of: " #SECONDCHUNK# " , with: secondString)
133+ script = script. replaceFirstOccurrence ( of: " #THIRDCHUNK# " , with: thirdString)
121134 }
122135 else {
123- script = script. replaceFirstOccurrence ( of: " #PICTURE# " , with: " " )
136+ script = script. replaceFirstOccurrence ( of: " #FIRSTCHUNK# " , with: " " )
137+ script = script. replaceFirstOccurrence ( of: " #SECONDCHUNK# " , with: " " )
138+ script = script. replaceFirstOccurrence ( of: " #THIRDCHUNK# " , with: " " )
124139 }
125140 }
126141 else {
127- script = script. replaceFirstOccurrence ( of: " #PICTURE# " , with: " " )
142+ script = script. replaceFirstOccurrence ( of: " #FIRSTCHUNK# " , with: " " )
143+ script = script. replaceFirstOccurrence ( of: " #SECONDCHUNK# " , with: " " )
144+ script = script. replaceFirstOccurrence ( of: " #THIRDCHUNK# " , with: " " )
128145 }
129146
130147 try script. write ( to: url, atomically: true , encoding: . utf8)
0 commit comments