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

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

Closed
milkpirate opened this issue Sep 23, 2023 · 5 comments
Closed

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

milkpirate opened this issue Sep 23, 2023 · 5 comments
Assignees

Comments

@milkpirate
Copy link

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

@hhrutter
Copy link
Collaborator

Sounds like you need to combine your files like a zipper.

@milkpirate
Copy link
Author

Exactly.

@hhrutter
Copy link
Collaborator

Let me see, maybe we can integrate this as a special merging mode.

@hhrutter
Copy link
Collaborator

FYI This will be part of the upcoming release.

@hhrutter
Copy link
Collaborator

This is part of https://github.com/pdfcpu/pdfcpu/releases/tag/v0.6.0
See pdfcpu help merge.

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

No branches or pull requests

2 participants