Skip to content

Commit

Permalink
NiFi: updated test file generation for ingestion.
Browse files Browse the repository at this point in the history
  • Loading branch information
vladd-bit committed Dec 7, 2023
1 parent b0cc5af commit b905479
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions nifi/user-scripts/tests/generate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import uuid
import random

from pathlib import Path
from reportlab.pdfgen import canvas

path = "../../../data/ingestion/2022/"

str_file_name = "ex1.pdf"
Expand Down Expand Up @@ -32,3 +35,29 @@

with(open(os.path.join(day_dir_path, "metadata.csv"), "w+")) as csv_file:
csv_file.write(metadata_csv)


def create_long_pdf_over_char_limit(file_path, text):
c = canvas.Canvas(file_path)
# Set font and size
c.setFont("Helvetica", 12)

# Set margin
margin = 50
width, height = c._pagesize

# Split the text into lines
lines = [text[i:i + 100] for i in range(0, len(text), 100)] # Adjust line length as needed

# Write lines to PDF
y = height - margin
for line in lines:
c.drawString(margin, y, line)
y -= 12 + 2 # Adjust spacing between lines as needed

c.save()

# this is a string over the int limit (for testing the built in jackson XML parser)
over_char_text = "a" * 2147483647

#create_long_pdf_over_char_limit(path + "long_pdf.pdf", over_char_text)

0 comments on commit b905479

Please sign in to comment.