MCPcopy Create free account
hub / github.com/lxn/walk / Print

Method Print

src/pkg/walk/document.go:228–278  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

226}
227
228func (doc *Document) Print() (err os.Error) {
229 defer func() {
230 if x := recover(); x != nil {
231 err = toError(x)
232 }
233 }()
234
235 hdc := doc.pages[0].info.createDC()
236 defer DeleteDC(hdc)
237
238 var di DOCINFO
239 di.CbSize = int32(unsafe.Sizeof(di))
240 di.LpszDocName = syscall.StringToUTF16Ptr(doc.name)
241
242 if StartDoc(hdc, &di) <= 0 {
243 return newError("StartDoc failed")
244 }
245 defer func() {
246 if EndDoc(hdc) <= 0 {
247 err = newError("EndDoc failed")
248 }
249 }()
250
251 canvas, err := newCanvasFromHDC(hdc)
252 if err != nil {
253 return err
254 }
255 defer canvas.Dispose()
256
257 for i, page := range doc.pages {
258 if i > 0 {
259 // TODO: Only reset dc if required.
260 page.info.resetDC(hdc)
261 }
262
263 if StartPage(hdc) <= 0 {
264 return newError("StartPage failed")
265 }
266
267 err = page.Draw(canvas)
268 if err != nil {
269 return err
270 }
271
272 if EndPage(hdc) <= 0 {
273 return newError("EndPage failed")
274 }
275 }
276
277 return nil
278}

Callers 3

mainFunction · 0.95
RestoreStateMethod · 0.80
processErrorNoPanicFunction · 0.80

Calls 12

toErrorFunction · 0.85
DeleteDCFunction · 0.85
StartDocFunction · 0.85
newErrorFunction · 0.85
EndDocFunction · 0.85
newCanvasFromHDCFunction · 0.85
StartPageFunction · 0.85
EndPageFunction · 0.85
resetDCMethod · 0.80
DisposeMethod · 0.65
DrawMethod · 0.65
createDCMethod · 0.45

Tested by

no test coverage detected