You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Im writing HTML to a temporary local file then loading that via unihtml.NewDocument() but after successfully creating a PDF from that HTML file and leaving that function, I'm unable to delete that temporary file straight away via os.Remove(). It's only after some time that the file lock is released (perhaps when GC cleans up?) that I can then delete the file.
Expected Behavior
I would like to be able to delete the file that is used by unihtml.NewDocument() after I'm done using it or a way to explictly Close() the unihtml.Document() returned from it
Actual Behavior
Steps to reproduce the behavior:
This is the code I'm running to generate the PDF from the HTML file.
funccreatePdfFromHtml(htmlPathstring) ([]byte, error) {
// Load the html document from diskhtmlDocument, err:=unihtml.NewDocument(htmlPath)
iferr!=nil {
returnnil, fmt.Errorf("html document error: %v\n", err)
}
// Make a new pdf creatorc:=creator.New()
// Draw the html documentiferr=c.Draw(htmlDocument); err!=nil {
returnnil, fmt.Errorf("draw error: %v\n", err)
}
// Write creator output to memory and return the bytes// rather than write to diskvarb bytes.Bufferbuf:=bufio.NewWriter(&b)
err=c.Write(buf)
iferr!=nil {
returnnil, fmt.Errorf("write error: %v\n", err)
}
returnb.Bytes(), nil
}
Following a call to this I attempt to delete the HTML file via os.Remove(htmlPath) but it can fail with:-
The process cannot access the file because it is being used by another process.
The text was updated successfully, but these errors were encountered:
Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/
Description
Im writing HTML to a temporary local file then loading that via unihtml.NewDocument() but after successfully creating a PDF from that HTML file and leaving that function, I'm unable to delete that temporary file straight away via os.Remove(). It's only after some time that the file lock is released (perhaps when GC cleans up?) that I can then delete the file.
Expected Behavior
I would like to be able to delete the file that is used by unihtml.NewDocument() after I'm done using it or a way to explictly Close() the unihtml.Document() returned from it
Actual Behavior
Steps to reproduce the behavior:
This is the code I'm running to generate the PDF from the HTML file.
Following a call to this I attempt to delete the HTML file via os.Remove(htmlPath) but it can fail with:-
The process cannot access the file because it is being used by another process.
The text was updated successfully, but these errors were encountered: