<commit_before># CombinePDF - the ruby way for merging PDF files
CombinePDF is a nifty model, written in pure Ruby, to parse PDF files and combine (merge) them with other PDF files, watermark them or stamp them (all using the PDF file format and pure Ruby code).

# Install

Install with ruby gems:
```
gem install combine_pdf
```

## Combine/Merge PDF files or Pages
To combine PDF files (or data):
```ruby
pdf = CombinePDF.new
pdf << CombinePDF.new("file1.pdf") # one way to combine, very fast.
pdf << CombinePDF.new("file2.pdf")
pdf.save "combined.pdf"
```
Or even a one liner:
```ruby
(CombinePDF.new("file1.pdf") << CombinePDF.new("file2.pdf") << CombinePDF.new("file3.pdf")).save("combined.pdf")
```
you can also add just odd or even pages:
```ruby
pdf = CombinePDF.new
i = 0
CombinePDF.new("file.pdf").pages.each do |page
  i += 1
  pdf << page if i.even?
end
pdf.save "even_pages.pdf"
```

notice that adding all the pages one by one is slower then adding the whole file.
## Add content to existing pages (Stamp / Watermark)
**has issues with specific PDF files - [please see the issue published here](https://github.com/boazsegev/combine_pdf/issues/2).**

To add content to existing PDF pages, first import the new content from an existing PDF file. After that, add the content to each of the pages in your existing PDF.

In this example, we will add a company logo to each page:
```ruby
company_logo = CombinePDF.new("company_logo.pdf").pages[0]
pdf = CombinePDF.new "content_file.pdf"
pdf.pages.each {|page| page << company_logo} # notice the << operator is on a page and not a PDF object.
pdf.save "content_with_logo.pdf"
```<commit_msg>fixed typo<commit_after># CombinePDF - the ruby way for merging PDF files
CombinePDF is a nifty model, written in pure Ruby, to parse PDF files and combine (merge) them with other PDF files, watermark them or stamp them (all using the PDF file format and pure Ruby code).

# Install

Install with ruby gems:
```
gem install combine_pdf
```

## Combine/Merge PDF files or Pages
To combine PDF files (or data):
```ruby
pdf = CombinePDF.new
pdf << CombinePDF.new("file1.pdf") # one way to combine, very fast.
pdf << CombinePDF.new("file2.pdf")
pdf.save "combined.pdf"
```
Or even a one liner:
```ruby
(CombinePDF.new("file1.pdf") << CombinePDF.new("file2.pdf") << CombinePDF.new("file3.pdf")).save("combined.pdf")
```
you can also add just odd or even pages:
```ruby
pdf = CombinePDF.new
i = 0
CombinePDF.new("file.pdf").pages.each do |page|
  i += 1
  pdf << page if i.even?
end
pdf.save "even_pages.pdf"
```

notice that adding all the pages one by one is slower then adding the whole file.
## Add content to existing pages (Stamp / Watermark)
**has issues with specific PDF files - [please see the issue published here](https://github.com/boazsegev/combine_pdf/issues/2).**

To add content to existing PDF pages, first import the new content from an existing PDF file. After that, add the content to each of the pages in your existing PDF.

In this example, we will add a company logo to each page:
```ruby
company_logo = CombinePDF.new("company_logo.pdf").pages[0]
pdf = CombinePDF.new "content_file.pdf"
pdf.pages.each {|page| page << company_logo} # notice the << operator is on a page and not a PDF object.
pdf.save "content_with_logo.pdf"
```
{'fraction_non_alphanumeric': 0.11620145631067962, 'fraction_numerical': 0.0054611650485436895, 'mean_word_length': 4.4405940594059405, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2029195', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1005, 'n_words': 433}