Comments (5)
from pikepdf.
Linux, specifically a Debian testing.
I compiled it by myself, but if fails also with the wheel.
With the wheel, it fails also with n = 3, but works with n <= 2
from pikepdf.
Okay, I can reproduce it. The point of failure will vary with memory layout.
Obvious this is not ideal, but you can work around it by holding an additional reference to the open pikepdf.Pdf object. The additional reference prevents premature garbage collection.
import pikepdf
def concatenate(number):
hold_open = []
print('concatenating same page', number, 'times')
output_pdf = pikepdf.Pdf.new()
for i in range(number):
print(i)
pdf_page = pikepdf.Pdf.open('tests/resources/graph.pdf')
hold_open.append(pdf_page)
output_pdf.pages.extend(pdf_page.pages)
output_pdf.save('_.pdf')
print('done')
concatenate(3) #works
concatenate(4) #works
from pikepdf.
Great, thank you! For the moment is fine 😊
from pikepdf.
With v1.2.0 you should be able to do this:
import pikepdf
def concatenate(number):
print('concatenating same page', number, 'times')
output_pdf = pikepdf.Pdf.new()
for i in range(number):
print(i)
with pikepdf.Pdf.open('tests/resources/graph.pdf') as pdf_page:
output_pdf.pages.extend(pdf_page.pages)
output_pdf.save('_.pdf')
print('done')
concatenate(3) #works
concatenate(4) #works
That is, it is no longer necessary to hold open.
from pikepdf.
Related Issues (20)
- 8.1.1: tests/test_image_access.py::test_image_palette2 - hypothesis.errors.Flaky HOT 1
- Bad link HOT 1
- Unable to install on alpine - dependency issue with qpdf HOT 7
- datetime.utcnow is deprecated in Python 3.12 HOT 1
- How to randomly shuffle the position of objects without affecting the display of content? HOT 1
- test_stack_depth fails on Python 3.12 HOT 3
- Docs are no longer in sdist
- Error: ‘writeQPDF’ is not a member of ‘QPDFJob’ HOT 1
- Calling check() after generate_appearance_streams()
- Add color output intent profile to PDF
- Add color output intent profile to PDF HOT 4
- Cannot save PDF opened from BytesIO on Windows
- PDF image extraction error: Not sure how to handle PDF image of this type HOT 3
- PDF.check() does not report warnings when qpdf --check does HOT 1
- UnsupportedImageTypeError('/CCITTFaxDecode with decode parameter /EndOfBlock not equal True') when converting PDF to image HOT 3
- Use the Job API's logging functions to redirect to logging rather than stdout/stderr
- Unable open RC4 encrypted pdf HOT 17
- Mypy implicit reexport HOT 2
- First tutorial example is unclear: new_pdf?
- The password param in method ‘open’ HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pikepdf.