Overlaid Two PDFs and Part Is Missing? Check the Page Boxes
The CropBox modifies the display area, not the page content itself. If a stamp becomes invisible after being overlaid on the right side of the page, first check
If you overlay a stamp or a second PDF onto a page and part of it disappears, the page content is often fine. The problem is usually the page's visible area. This guide is for anyone merging PDFs with Python who needs to find out why content on the right side of a page is not showing.
The main cause is the CropBox, which controls the display area of a page. Changing it does not change the content itself. Before you resize anything, you need to check the target page's CropBox and the actual drawing coordinates of the stamp.
Here you will learn how to pick the right target page size, merge and verify content, and decide whether to expand the visible area or move the stamp. You will also see why cropping is not the same as removing sensitive information.
This paper uses synthetic samples to demonstrate the processing method. Before processing important files, keep the original copies and verify them against the boundaries and acceptance criteria in this guide.
Why is my stamp invisible after merging? The short answer
Check the target page's CropBox and the stamp's drawing coordinates first, then decide whether to expand the visible area. Do not reset all page boxes straight away, because the original cropping may have been set on purpose.
| Your situation | What to do | Why |
|---|---|---|
| The stamp is invisible on the right side of the page | Check the target page's CropBox and the drawing coordinates | The CropBox changes the display area, not the content |
| The stamp is in the wrong place | Check the coordinate units, origin and rotation | Position problems often come from these settings |
| The original page was cropped on purpose | Keep the finished trim size and adjust the stamp's position or size | The delivery requirement for the finished product decides the size |
| The text extracts correctly but the preview looks wrong | Check the font, opacity and actual rendering | A text check alone does not confirm what is visible |
| The page contains sensitive information | Run a separate process for deleting content and verifying the result | Cropping does not remove content from the file |
Understanding what the CropBox does
The CropBox defines the visible area of a page. The MediaBox defines the full physical page. Content that falls outside the CropBox still exists in the file, but it is not shown.
- Cropping hides content. It does not delete it.
- Changing the CropBox does not move the stamp. It only changes the window you see.
- The original cropping may be intentional. Many documents are trimmed to a finished size before printing or delivery.
Deciding the target page size first
Before you merge, decide which page size the output needs. The right choice depends on your delivery agreement, and the library cannot make that decision for you.
Option A: use the full page
The example below uses a full two-hundred-point-wide page for output. This allows the target CropBox to be restored to the MediaBox, so the stamp on the right side becomes visible.
Option B: keep the original trim size
If the job requires the original finished trim size, do not expand the page. Instead, adjust the position or size of the stamp so it fits inside the existing visible area.
Merging and verifying with real content
Do not merge blank seals. Use authentic content for testing, so you can confirm that the stamp actually appears where you expect.
The example below creates a stamp with PyMuPDF using STAMP, then merges the source pages of the text with pypdf. Everything happens in memory, so no files are overwritten.
from io import BytesIO
import pymupdf
from pypdf import PdfReader, PdfWriter, Transformation
from pypdf.generic import RectangleObject
with pymupdf.open() as source:
page = source.new_page(width=60, height=40)
page.insert_text((5, 20), "STAMP", fontsize=8)
stamp_bytes = source.tobytes()
writer = PdfWriter()
base = writer.add_blank_page(width=200, height=100)
base.cropbox = RectangleObject((0, 0, 100, 100))
assert base.cropbox.right == 100
# Explicit delivery policy for this fixture: reveal the full media area.
base.cropbox = RectangleObject(base.mediabox)
stamp = PdfReader(BytesIO(stamp_bytes)).pages[0]
base.merge_transformed_page(stamp, Transformation().translate(tx=120, ty=30), expand=False)
out = BytesIO()
writer.write(out)
result = PdfReader(BytesIO(out.getvalue())).pages[0]
assert tuple(result.cropbox) == (0, 0, 200, 100)
assert "STAMP" in result.extract_text()
assert result.mediabox.right == 200
After merging, check the following:
- Confirm the text is intact. Extract it and compare it with the source.
- Confirm the page boxes match what you expect. Check the CropBox and MediaBox.
- Compare renderings. Visual position needs checking on rendered output, not only in code.
Knowing what expand does and does not do
The merge_page and merge_transformed_page methods both have an expand parameter. It controls whether the page boundary is extended. It does not automatically fix every CropBox, clipping, transparency or annotation problem.
In this example, the content stays inside the existing MediaBox because expand=False is set explicitly. The target visible area is set separately.
Choosing what to check based on the symptom
Use the table below to match what you see with the right check. It also shows the mistakes to avoid.
| Observation | What to check | What not to conclude |
|---|---|---|
| Content exists but is invisible | CropBox, transformations and content clipping | That the content has been deleted |
| The stamp is in the wrong position | Coordinate units, origin and rotation | That only the page width needs changing |
| The original page was cropped on purpose | The finished delivery size | That the whole MediaBox should be restored |
| Text extracts correctly but the preview looks wrong | Font, opacity and actual rendering | That the file passes based on text alone |
Cropping is not de-identification
Text that is clipped out of the visible area can still be present in the content stream. If your file contains sensitive information, you need a separate process to:
- delete the content,
- keep a record of what you retained, and
- re-extract the file to verify that the sensitive text is gone.
This guide only covers stacking pages and checking the visible area. It does not guarantee de-identification, and it does not assess whether a document is legally valid.
Keeping the same acceptance criteria before and after translation
If you translate PDFs with OmniDoc (Product Entry), add these checks to your acceptance list:
- Does the output keep the original cropping, or display the full page, as required?
- Is the text intact after translation?
- Are the images intact after translation?
OmniDoc provides an entry point for document translation. You should still cross-check the display range of the source page and the integrity of text and images, using the same sample. The code in this guide does not show how the platform works internally, so do not assume it uses the same method.
For the cropping and transformation methods used in pypdf, see the pypdf Cropping and Transformation documentation.
📊 At a glance
| Approach | Use it when | What happens |
|---|---|---|
| Expand the target page to the full page | Your job uses the full two-hundred-point-wide page | The target CropBox is restored to the MediaBox |
| Keep the original trim size and adjust the stamp | The finished trim size must be preserved | The stamp's position or size changes, and the page is not expanded |
🎯 Which approach fits you?
If you need the full page in the output
Use the full-page example, then check the result by rendering it.
If you must keep the finished trim size
Leave the page size alone and move or resize the stamp so it sits inside the visible area.
If your file contains sensitive content
Treat cropping as a display change only. Run a separate deletion and verification process.
❓ FAQ
1. Why is my stamp missing when the text is still there?
The stamp may fall outside the target page's CropBox. The content is still in the file, but it is not shown.
2. Does setting expand=True fix the problem?
Not always. expand only extends the page boundary. It does not fix every CropBox, clipping, transparency or annotation issue.
3. Should I reset all the page boxes?
No. The original cropping may have been set on purpose, so check the delivery requirements first.
4. Does cropping remove sensitive information?
No. Cropped content can remain in the content stream, so use a separate deletion and verification process.
📝 Summary
Check the target page's CropBox and the stamp's coordinates before you change the page size. Decide whether to expand the page or adjust the stamp based on your delivery requirements, then verify the result by rendering it.
Try it now: upload a document and get it translated with the layout intact


