-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
369789c
commit 1f5086d
Showing
14 changed files
with
107 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
generate -> avg: 8.58ms, executions: [8.58ms] | ||
add_row -> avg: 86.64ns, executions: [0.24μs, 0.09μs, 0.07μs, 0.03μs, 0.08μs, 0.02μs, 0.02μs, 0.02μs, 0.08μs, 0.02μs, 0.02μs, 0.02μs, 0.03μs, 2.07μs, 0.07μs, 0.06μs, 0.01μs, 0.06μs, 0.02μs, 0.02μs, 0.02μs, 0.06μs, 0.02μs, 0.02μs, 0.02μs, 0.02μs, 0.29μs, 0.05μs, 0.05μs, 0.02μs, 0.06μs, 0.02μs, 0.02μs, 0.02μs, 0.06μs, 0.02μs, 0.02μs, 0.01μs, 0.01μs, 0.21μs, 0.04μs, 0.06μs, 0.02μs, 0.06μs, 0.02μs, 0.01μs, 0.02μs, 0.05μs, 0.02μs, 0.02μs] | ||
merge_pdf -> avg: 1.21ms, executions: [1.21ms] | ||
file_size -> 274.55Kb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Merge PDF | ||
|
||
## Code Example | ||
[filename](../../assets/examples/mergepdf/v2/main.go ':include :type=code') | ||
|
||
|
||
## PDF Generated | ||
assets/pdf/mergepdfv2.pdf | ||
``` | ||
|
||
## Time Execution | ||
[filename](../../assets/text/mergepdfv2.txt ':include :type=code') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package merge | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
|
||
"github.com/pdfcpu/pdfcpu/pkg/api" | ||
) | ||
|
||
func Bytes(pdfs ...[]byte) ([]byte, error) { | ||
readers := make([]io.ReadSeeker, len(pdfs)) | ||
for i, pdf := range pdfs { | ||
readers[i] = bytes.NewReader(pdf) | ||
} | ||
|
||
var buf bytes.Buffer | ||
writer := io.Writer(&buf) | ||
err := mergePdfs(readers, writer) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return buf.Bytes(), nil | ||
} | ||
|
||
func mergePdfs(readers []io.ReadSeeker, writer io.Writer) error { | ||
conf := api.LoadConfiguration() | ||
conf.WriteXRefStream = false | ||
return api.MergeRaw(readers, writer, conf) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters