Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,34 @@ func (this *Importer) ImportPage(pageno int, box string) int {
return tplN
}

func (this *Importer) ImportPageWithError(pageno int, box string) (int, error) {
// If page has already been imported, return existing tplN
pageNameNumber := fmt.Sprintf("%s-%04d", this.sourceFile, pageno)
if _, ok := this.importedPages[pageNameNumber]; ok {
return this.importedPages[pageNameNumber]
}

res, err := this.GetWriter().ImportPage(this.GetReader(), pageno, box)
if err != nil {
return 0, err
}

// Get current template id
tplN := this.tplN

// Set tpl info
this.tplMap[tplN] = &TplInfo{SourceFile: this.sourceFile, TemplateId: res, Writer: this.GetWriter()}

// Increment template id
this.tplN++

// Cache imported page tplN
this.importedPages[pageNameNumber] = tplN

return tplN
}


func (this *Importer) SetNextObjectID(objId int) {
this.GetWriter().SetNextObjectID(objId)
}
Expand Down