Skip to content

Merge odd/even pages together (im-mem) #716

@milkpirate

Description

@milkpirate

Hey,

I have a scanner that can scan to PDF @ FTP but that only single sided. What I now have is an in-mem FTP server (with a virtual system) that receives two PDF, one with all even pages one with all odd pages. I want to combine them correctly into one PDF and send the result by mail or put it back to (FTP) file system. The part thats missing is the PDF processing.

I coded up something but it does not work, the PDF comes out broken:

	target, err := memFs.Create("out.pdf")
	defer target.Close()

	for page := 1; page <= oddPageCount; page++ {
		pages := []string{fmt.Sprintf("%d", page)}
		err = pdfapi.InsertPages(oddReader, target, pages, false, nil)
		err = pdfapi.InsertPages(evenReader, target, pages, false, nil)
	}

I also tried to pre-create a empty PDF, and the merge stuff in, but I cant figure out the JSON part. So if there is an option to place a empty PDF in a reader/writer without JSON I would be happy about that:

	err = pdfapi.Create(nil, strings.NewReader("{}"), target, nil)

I also saw CreatePDFFile() which seems to do what I want, but uses os.Open() which would not be my in-mem FS.

If you could hint me to the right code or propose a better option I would be really glad!

Thanks in advance

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions