Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable to parse Typst-generated PDFs: def of non-name #42

Open
bfallik opened this issue Sep 19, 2024 · 0 comments
Open

unable to parse Typst-generated PDFs: def of non-name #42

bfallik opened this issue Sep 19, 2024 · 0 comments

Comments

@bfallik
Copy link

bfallik commented Sep 19, 2024

Great project, thanks for building and maintaining it.

If I create a very basic typist file:

test

and generate a PDF from it (./typst-x86_64-unknown-linux-musl/typst c test.typ), this package is unable to parse the resulting PDF file

I can reproduce using this code:

func readPdf(path string) (string, error) {
	f, r, err := pdf.Open(path)
	defer f.Close()
	if err != nil {
		return "", err
	}
	var buf bytes.Buffer
	b, err := r.GetPlainText()
	if err != nil {
		return "", fmt.Errorf("getplaintext: %v", err)
	}
	buf.ReadFrom(b)
	return buf.String(), nil
}

func main() {
        if _, err := readPdf("/path/to/pdf"); err != nil {
	        log.Fatalln(err)
        }
}

with the output:

2024/09/19 13:54:57 getplaintext: def of non-name
exit status 1

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant