mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
feat(docker): update base images to Java 25, Spring 4, Jackson 3, Gradle 9 and optimize JVM options (Project Lilliput) (#5725)
Co-authored-by: Anthony Stirling <[email protected]>
This commit is contained in:
co-authored by
Anthony Stirling
parent
24128dd318
commit
1f9b90ad57
@@ -26,10 +26,18 @@ API_HEADERS = {"X-API-KEY": "123456789"}
|
||||
def step_generate_pdf(context, fileInput):
|
||||
context.param_name = fileInput
|
||||
context.file_name = "genericNonCustomisableName.pdf"
|
||||
writer = PdfWriter()
|
||||
writer.add_blank_page(width=72, height=72) # Single blank page
|
||||
# Generate a PDF with proper size and content (Letter size: 612x792 points)
|
||||
buffer = io.BytesIO()
|
||||
c = canvas.Canvas(buffer, pagesize=letter)
|
||||
width, height = letter
|
||||
# Add some text content so OCR and other tools can process it
|
||||
c.drawString(100, height - 100, "This is a test PDF document")
|
||||
c.showPage()
|
||||
c.save()
|
||||
|
||||
with open(context.file_name, "wb") as f:
|
||||
writer.write(f)
|
||||
f.write(buffer.getvalue())
|
||||
|
||||
if not hasattr(context, "files"):
|
||||
context.files = {}
|
||||
context.files[context.param_name] = open(context.file_name, "rb")
|
||||
@@ -52,11 +60,16 @@ def step_use_example_file(context, filePath, fileInput):
|
||||
|
||||
@given("the pdf contains {page_count:d} pages")
|
||||
def step_pdf_contains_pages(context, page_count):
|
||||
writer = PdfWriter()
|
||||
buffer = io.BytesIO()
|
||||
c = canvas.Canvas(buffer, pagesize=letter)
|
||||
width, height = letter
|
||||
for i in range(page_count):
|
||||
writer.add_blank_page(width=72, height=72)
|
||||
c.drawString(100, height - 100, f"Page {i + 1} of {page_count}")
|
||||
c.showPage()
|
||||
c.save()
|
||||
|
||||
with open(context.file_name, "wb") as f:
|
||||
writer.write(f)
|
||||
f.write(buffer.getvalue())
|
||||
context.files[context.param_name].close()
|
||||
context.files[context.param_name] = open(context.file_name, "rb")
|
||||
|
||||
@@ -64,11 +77,15 @@ def step_pdf_contains_pages(context, page_count):
|
||||
# Duplicate for now...
|
||||
@given("the pdf contains {page_count:d} blank pages")
|
||||
def step_pdf_contains_blank_pages(context, page_count):
|
||||
writer = PdfWriter()
|
||||
buffer = io.BytesIO()
|
||||
c = canvas.Canvas(buffer, pagesize=letter)
|
||||
width, height = letter
|
||||
for i in range(page_count):
|
||||
writer.add_blank_page(width=72, height=72)
|
||||
c.showPage()
|
||||
c.save()
|
||||
|
||||
with open(context.file_name, "wb") as f:
|
||||
writer.write(f)
|
||||
f.write(buffer.getvalue())
|
||||
context.files[context.param_name].close()
|
||||
context.files[context.param_name] = open(context.file_name, "rb")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user