* **I'm submitting a:**
  - [ ] Vulnerability report -> **use the specific [form](https://github.com/podofo/podofo/security/advisories/new) instead!**
  - [ x] Bug report
  - [ ] Feature request/suggestion

* **[Bug report] What is the current behavior?**

I encounter this bug while using [Calibre](https://calibre-ebook.com/) to embed some metadata into a couple of PDFs. I reported the bug to the Calibre bug tracker, [Bug #2066529](https://bugs.launchpad.net/calibre/+bug/2066529). The Calibre dev said the issue needs to be reported here.

When applying metadata to the PDFs the go from less than 10MB to more than 100MB. There does seem to be something peculiar with the PDFs, because this issue does not occur when apply metadata to other PDFs.

The bug occurs with the two PDFs that can be found on this page: https://www.buddhism.hku.hk/publication-post/the-path-to-freedom-vimuttimagga/

The title of the two volume book is *The Path to Freedom Vimuttimagga*.

The Calibre dev says simply opening and saving the PDF (presumably with podofo via the Calibre UI) inflates the size of the PDFs.

* **[Bug report] What is the expected behavior?**

The expected behavior is for the PDFs to not grow significantly in size.

* **[Bug report] Please provide the steps to reproduce and if possible a minimal reproduction code of the problem**

I am not at all familiar with you project, so I can only describe how to reproduce the bug via Calibre.

- Import one the PDFs from the link about into a Calibre Library.
- Open the preferences menu.
  - Select 'Toolbars and menus'
  - Select 'The main toolbar' in the dropdown menu
  - Add 'Embed metadata' from the 'Available actions' column to the 'Current Actions' column.
  - Apply the changes and restart Calibre.
- Select the PDF
- Press the 'Embed metadata' button on the main menu bar.
- After the embedding metadata function is run the file size of the PDF is greatly inflated.

The Calibre dev said this command might show something meaningful `calibre-debug -c 'from calibre.utils.podofo import *; test_roundtrip("t.pdf", "x.pdf")'`

* **Please tell us about your environment:**

I am not at all familiar of the build environment in which your project is implemented in Calibre.

I have encountered this bug on Linux POP!_OS 22.04 with Calibre 7.10 and 7.11 installed via the supported Linux installation script. I  assume podofo is statically linked within the Calibre package.
PDF size greatly increases when resaving.
This is a GitHub Issue
repo:podofo
owner:podofo
Title : PDF size greatly increases when resaving.
Issue date:

--- start body ---
* **I'm submitting a:**
  - [ ] Vulnerability report -> **use the specific [form](https://github.com/podofo/podofo/security/advisories/new) instead!**
  - [ x] Bug report
  - [ ] Feature request/suggestion

* **[Bug report] What is the current behavior?**

I encounter this bug while using [Calibre](https://calibre-ebook.com/) to embed some metadata into a couple of PDFs. I reported the bug to the Calibre bug tracker, [Bug #2066529](https://bugs.launchpad.net/calibre/+bug/2066529). The Calibre dev said the issue needs to be reported here.

When applying metadata to the PDFs the go from less than 10MB to more than 100MB. There does seem to be something peculiar with the PDFs, because this issue does not occur when apply metadata to other PDFs.

The bug occurs with the two PDFs that can be found on this page: https://www.buddhism.hku.hk/publication-post/the-path-to-freedom-vimuttimagga/

The title of the two volume book is *The Path to Freedom Vimuttimagga*.

The Calibre dev says simply opening and saving the PDF (presumably with podofo via the Calibre UI) inflates the size of the PDFs.

* **[Bug report] What is the expected behavior?**

The expected behavior is for the PDFs to not grow significantly in size.

* **[Bug report] Please provide the steps to reproduce and if possible a minimal reproduction code of the problem**

I am not at all familiar with you project, so I can only describe how to reproduce the bug via Calibre.

- Import one the PDFs from the link about into a Calibre Library.
- Open the preferences menu.
  - Select 'Toolbars and menus'
  - Select 'The main toolbar' in the dropdown menu
  - Add 'Embed metadata' from the 'Available actions' column to the 'Current Actions' column.
  - Apply the changes and restart Calibre.
- Select the PDF
- Press the 'Embed metadata' button on the main menu bar.
- After the embedding metadata function is run the file size of the PDF is greatly inflated.

The Calibre dev said this command might show something meaningful `calibre-debug -c 'from calibre.utils.podofo import *; test_roundtrip("t.pdf", "x.pdf")'`

* **Please tell us about your environment:**

I am not at all familiar of the build environment in which your project is implemented in Calibre.

I have encountered this bug on Linux POP!_OS 22.04 with Calibre 7.10 and 7.11 installed via the supported Linux installation script. I  assume podofo is statically linked within the Calibre package.
--- end body ---
