github.com/unidoc/unidoc@v2.2.0+incompatible/pdf/extractor/extractor.go (about) 1 /* 2 * This file is subject to the terms and conditions defined in 3 * file 'LICENSE.md', which is part of this source code package. 4 */ 5 6 package extractor 7 8 import "github.com/unidoc/unidoc/pdf/model" 9 10 // Extractor stores and offers functionality for extracting content from PDF pages. 11 type Extractor struct { 12 contents string 13 resources *model.PdfPageResources 14 } 15 16 // New returns an Extractor instance for extracting content from the input PDF page. 17 func New(page *model.PdfPage) (*Extractor, error) { 18 contents, err := page.GetAllContentStreams() 19 if err != nil { 20 return nil, err 21 } 22 23 e := &Extractor{} 24 e.contents = contents 25 e.resources = page.Resources 26 27 return e, nil 28 }