chinapandaman / PyPDFForm

:fire: The Python library for PDF forms.
https://chinapandaman.github.io/PyPDFForm/
MIT License
381 stars 15 forks source link

PPF-711: Broken fields in unflatten mode #711

Open vatsenko opened 3 weeks ago

vatsenko commented 3 weeks ago

Version

PyPDFForm=1.4.32

Issue Description

I need to generate editable form (flatten=False) for printing on impact printer later after correction/populating data. In flatten mode all fields visible and populated as expected. When i try to use flatten=False or adobe_mode=True - the fields in generated pdf became invisible and unprintable.

When i open this file in adobe acrobat - i can see the data inside field when i focus on it. Pdf became fixed when i make dummy changes in the form (apply border color for all fields)

Code Snippet

from fpdf import FPDF
from PyPDFForm import PdfWrapper,FormWrapper
import io
import json
import textwrap
import math

pdf = FPDF(orientation="P", unit="mm", format="Letter")
# create blank page
pdf.add_page()
# graphics and text wrappers ommited

# read data for form
manifest = { "Generator_ID": "", "Manifest_Pages": "2", "ER_Phone_Number": "", "Tracking_Number": "143431134JJK", "Generator_Name": "Appalachia Facilites (G&P)", "Generator_Address": ",",
"Generator_Mailing_Address": "", "Generator_Phone": "", "Transporter_1_Name": "CLEAN HARBORS ENVIRONMENTAL SERVICES INC", "Transporter_1_ID": "MAD039322250", "Transporter_2_Name": 
  "CAMPBELL TRANSPORTATION CO, INC - CONGO OPERATIONS", "Transporter_2_ID": "WVD988786455", "Destination_Name": "TEST TSDF OF VA", "Destination_ID": "VAD000532119", 
  "Destination_Address": "123 MAIN ST,ARLINGTON,VA,22202", "Destination_Phone": "", "HM_1": "X", "HM_2": "X", "HM_3": "X", "HM_4": "", "Shipping_Description_1": 
    "RQ, NA3077, HAZARDOUS WASTE, SOLID, N.O.S. (F037, K048), 9, PG III", "Shipping_Description_2": "NA3077, Hazardous Waste, Solid, N.O.S. (K171, K172), 9, PG III", "Shipping_Description_3": 
      "NA3077, Hazardous Waste, Solid, N.O.S., (F037), 9, PG III",
"Shipping_Description_4": "Waste, Non-DOT Regulated", "Containers_No_1": "1", "Containers_No_2": "8", "Containers_No_3": "5", "Containers_No_4": "2", "Containers_Type_1": "CM",
"Containers_Type_2": "DF", "Containers_Type_3": "DF", "Containers_Type_4": "DF", "Total_Quantity_1": "19000", "Total_Quantity_2": "1000", "Total_Quantity_3": "10", "Total_Quantity_4": "2",
"Units_1": "P", "Units_2": "G", "Units_3": "EA", "Units_4": "EA", "Waste_Code1_1": "F037", "Waste_Code1_2": "D001", "Waste_Code1_3": "D003", "Waste_Code1_4": "", "Waste_Code2_1": "K048",
"Waste_Code2_2": "D005", "Waste_Code2_3": "", "Waste_Code2_4": "", "Waste_Code3_1": "K050", "Waste_Code3_2": "D006", "Waste_Code3_3": "", "Waste_Code3_4": "", "Waste_Code4_1": "",
"Waste_Code4_2": "D007", "Waste_Code4_3": "", "Waste_Code4_4": "", "Waste_Code5_1": "", "Waste_Code5_2": "D009", "Waste_Code5_3": "", "Waste_Code5_4": "", "Waste_Code6_1": "",
"Waste_Code6_2": "D021", "Waste_Code6_3": "", "Waste_Code6_4": "", "item_info_1": "1. TEST12367-1 CM, ERG:171;", "item_info_2": "2. CH63770-8 DF;", "item_info_3": "3. CH1258017B-5 DF;",
"item_info_4": "4. 044005-2 DF;", "Generator_Signature_Name": "", "Date_Generator_Shipped_Day": "28", "Date_Generator_Shipped_Month": "08", "Date_Generator_Shipped_Year": "2023",
"Transporter_1_Signature_Name": "", "Date_Transporter_1_Received_Material_Day": "28", "Date_Transporter_1_Received_Material_Month": "08", "Date_Transporter_1_Received_Material_Year": "2023",
"Transporter_2_Signature_Name": "", "Date_Transporter_2_Received_Material_Day": "", "Date_Transporter_2_Received_Material_Month": "", "Date_Transporter_3_Received_Material_Year": "",
"Management_Method_1": "H040", "Management_Method_2": "H010", "Management_Method_3": "H039", "Management_Method_4": "H010", "Destination_Signature_Name": "",
"Date_Destination_Received_Material_Day": "28", "Date_Destination_Received_Material_Month": "08", "Date_Destination_Received_Material_Year": "2023"}

# read field configuration i.e
hazardous_waste_manifest = { "Generator_ID": { "page": 1, "x": 119, "y": 720.5, "width": 160, "height": 11, "font": 7 }, "Manifest_Pages": { "page": 1, "x": 280, "y": 720.5, "width": 37, "height": 11, "font": 7 },
"ER_Phone_Number": { "page": 1, "x": 317, "y": 720.5, "width": 109, "height": 11, "font": 7 }, "Tracking_Number": { "page": 1, "x": 426, "y": 720.5, "width": 109, "height": 16, "font": 12 },
"Generator_Name": { "page": 1, "x": 37, "y": 702, "width": 269, "height": 11, "font": 7 }, "Generator_Address": { "page": 1, "x": 37, "y": 682, "width": 269, "height": 21, "font": 7,
"wrap":70 }, "Generator_Mailing_Address": { "page": 1, "x": 307, "y": 682, "width": 269, "height": 21, "font": 7, "wrap":70 }, "Generator_Phone": { "page": 1, "x": 87, "y": 672, "width": 218,
"height": 11, "font": 7 }, "Transporter_1_Name": { "page": 1, "x": 37, "y": 653, "width": 385, "height": 11, "font": 7 }, "Transporter_1_ID": { "page": 1, "x": 423, "y": 653, "width": 120,
"height": 11, "font": 7 }, "Transporter_2_Name": { "page": 1, "x": 37, "y": 629, "width": 385, "height": 11, "font": 7 }, "Transporter_2_ID": { "page": 1, "x": 423, "y": 629, "width": 120,
"height": 11, "font": 7 }, "Destination_Name": { "page": 1, "x": 37, "y": 607, "width": 385, "height": 11, "font": 7 }, "Destination_ID": { "page": 1, "x": 423, "y": 607, "width": 120,
"height": 11, "font": 7 }, "Destination_Address": { "page": 1, "x": 37, "y": 587, "width": 385, "height": 21, "font": 7 }, "Destination_Phone": { "page": 1, "x": 87, "y": 577, "width": 218,
"height": 11, "font": 7 }, "HM__LN": { "page": 1, "x": 37, "y": 517, "width": 18, "height": 37, "font": 7 }, "Shipping_Description__LN": { "page": 1, "x": 62, "y": 517, "width": 277,
"height": 37, "font": 7, "wrap":80 }, "Containers_No__LN": { "page": 1, "x": 339, "y": 517, "width": 45, "height": 37, "font": 7 }, "Containers_Type__LN": { "page": 1, "x": 383, "y": 517,
"width": 34, "height": 37, "font": 7 }, "Total_Quantity__LN": { "page": 1, "x": 416, "y": 517, "width": 45, "height": 37, "font": 7 }, "Units__LN": { "page": 1, "x": 461, "y": 517, "width":
29, "height": 37, "font": 7 }, "Waste_Code1__LN": { "page": 1, "x": 490, "y": 535, "width": 31, "height": 18, "font": 7 }, "Waste_Code2__LN": { "page": 1, "x": 522, "y": 535, "width": 31,
"height": 18, "font": 7 }, "Waste_Code3__LN": { "page": 1, "x": 553, "y": 535, "width": 31, "height": 18, "font": 7 }, "Waste_Code4__LN": { "page": 1, "x": 490, "y": 517, "width": 31,
"height": 18, "font": 7 }, "Waste_Code5__LN": { "page": 1, "x": 522, "y": 517, "width": 31, "height": 18, "font": 7 }, "Waste_Code6__LN": { "page": 1, "x": 553, "y": 517, "width": 31,
"height": 18, "font": 7 }, "item_info__LC2": { "page": 1, "x": 37, "y": 387, "width": 135, "height": 11, "font": 7 }, "Generator_Signature_Name": { "page": 1, "x": 37, "y": 302.5, "width":
267, "height": 11, "font": 7 }, "Date_Generator_Shipped_Day": { "page": 1, "x": 511, "y": 302.5, "width": 25, "height": 11, "font": 7 }, "Date_Generator_Shipped_Month": { "page": 1, "x": 536,
"y": 302.5, "width": 24, "height": 11, "font": 7 }, "Date_Generator_Shipped_Year": { "page": 1, "x": 560, "y": 302.5, "width": 24, "height": 11, "font": 7 }, "Transporter_1_Signature_Name": {
"page": 1, "x": 37, "y": 242.5, "width": 267, "height": 11, "font": 7 }, "Date_Transporter_1_Received_Material_Day": { "page": 1, "x": 511, "y": 242.5, "width": 25, "height": 11, "font": 7 },
"Date_Transporter_1_Received_Material_Month": { "page": 1, "x": 536, "y": 242.5, "width": 24, "height": 11, "font": 7 }, "Date_Transporter_1_Received_Material_Year": { "page": 1, "x": 560,
"y": 242.5, "width": 24, "height": 11, "font": 7 }, "Transporter_2_Signature_Name": { "page": 1, "x": 37, "y": 218.5, "width": 267, "height": 11, "font": 7 },
"Date_Transporter_2_Received_Material_Day": { "page": 1, "x": 511, "y": 218.5, "width": 25, "height": 11, "font": 7 }, "Date_Transporter_2_Received_Material_Month": { "page": 1, "x": 536,
"y": 218.5, "width": 24, "height": 11, "font": 7 }, "Date_Transporter_3_Received_Material_Year": { "page": 1, "x": 560, "y": 218.5, "width": 24, "height": 11, "font": 7 },
"Management_Method__LC4": { "page": 1, "x": 37, "y": 80, "width": 135, "height": 11, "font": 7 }, "Destination_Signature_Name": { "page": 1, "x": 37, "y": 40, "width": 267, "height": 11,
"font": 7 }, "Date_Destination_Received_Material_Day": { "page": 1, "x": 511, "y": 40, "width": 25, "height": 11, "font": 7 }, "Date_Destination_Received_Material_Month": { "page": 1, "x":
536, "y": 40, "width": 24, "height": 11, "font": 7 }, "Date_Destination_Received_Material_Year": { "page": 1, "x": 560, "y": 40, "width": 24, "height": 11, "font": 7 } }

PdfWrapper.register_font("Arial Narrow", "./source/arialnarrow.ttf")
new_form = PdfWrapper(io.BytesIO(pdf.output()))
# this is full dictionary for all fields in form
fill = {}
def insert_key(kk,config,wordwrap=0):  
    global  fill
    #if value exist check the length of text and put in fill, otherwise put empty string
    if (kk in manifest.keys()):
        val = str(manifest[kk])
        if (wordwrap > 0 ):
          wrapper = textwrap.TextWrapper(width =wordwrap)
          lines = wrapper.wrap(val)
          fill[kk] = "\n".join(lines)
        else:
          fill[kk] = val
    else:
        fill[kk]=""

    new_form.create_widget(
        widget_type="text",
        name = kk,
        page_number=config["page"],
        x=config["x"],
        y=config["y"],
        #font = "Arial Narrow",
        width=config["width"],  # optional
        height=config["height"],  # optional
        font_size=config["font"],   # optional
        border_color=(1, 1, 1), # optional
        border_width=1,  # optional
        font_color=(0, 0, 0),  
        bg_color=(1, 1, 1), # optional
    )
    # direct assignment not works for custom fonts
    new_form.widgets[kk].font = "Arial Narrow"
    return
# iterate through the key and put on page

for key in hazardous_waste_manifest:
      #get field config
      fl = hazardous_waste_manifest[key]
      # need word wrap ?
      word_wrap = 0 if ("wrap" not in fl.keys()) else fl["wrap"] 
      # distribute waste lines  __LN -> _1,_2,_3,_4
      if (key.endswith("__LN")):
        for i in range(4):
          subst_key = key.replace("__LN", "_"+str(i+1))
          fl2 = fl.copy()
          fl2['y'] = fl2['y'] - 36.0*i
          insert_key(subst_key,fl2,word_wrap)
      # distribute waste description   __LC2 -> _1,_2,_3,_4 
      elif (key.endswith("__LC2")):
        for i in range(4):
          subst_key = key.replace("__LC2", "_"+str(i+1))
          fl2 = fl.copy()
          fl2['x'] = fl2['x'] + i % 2 * 274
          fl2['y'] = fl2['y'] - math.floor(i/2) * 10
          insert_key(subst_key,fl2,word_wrap)     
      # distribute waste management method   __LC4 -> _1,_2,_3,_4       
      elif (key.endswith("__LC4")):
        for i in range(4):
          subst_key = key.replace("__LC4", "_"+str(i+1))
          fl2 = fl.copy()
          fl2['x'] = fl2['x'] + i % 4 * 137
          insert_key(subst_key,fl2,word_wrap)    
      else:  
        insert_key(key,fl,word_wrap)
with open("blank.pdf", "wb+") as output:
    output.write(new_form.read())

form = FormWrapper("blank.pdf")
#adobe_mode=True
form.fill(fill, adobe_mode=True)
with open("output.pdf", "wb+") as output:
    output.write(form.read())

PDF Form Template

output.pdf

Fixed Form

fixed.pdf

Screenshots (if applicable)

Screenshot 2024-08-21 at 12 17 45 Screenshot 2024-08-21 at 12 18 40
vatsenko commented 3 weeks ago

side notes (minor bugs)

  1. When i try to specify font directly in create_widget i've got an error

    in makeFont
    raise ValueError('form font name, %r, is not one of the standard 14 fonts' % fontName)
    ValueError: form font name, 'Arial Narrow', is not one of the standard 14 fonts

    however this works when i change font field directly.\

  2. It would be nice to have multiline text options

    Screenshot 2024-08-21 at 12 29 29
vatsenko commented 3 weeks ago

if it help to investigate the issue - i tried to read both files using pypdf when i call reader.get_fields() method - on produced file - it returns empty object. However when i tried to use same method on fixed file- it returns {'Generator_ID': {'/T': 'Generator_ID', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Manifest_Pages': {'/T': 'Manifest_Pages', '/FT': '/Tx', '/Ff': 0, '/V': '2', '/DV': ''}, 'ER_Phone_Number': {'/T': 'ER_Phone_Number', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Tracking_Number': {'/T': 'Tracking_Number', '/FT': '/Tx', '/Ff': 0, '/V': '143431134JJK', '/DV': ''}, 'Generator_Name': {'/T': 'Generator_Name', '/FT': '/Tx', '/Ff': 0, '/V': 'Appalachia Facilites (G&P)', '/DV': ''}, 'Generator_Address': {'/T': 'Generator_Address', '/FT': '/Tx', '/Ff': 0, '/V': ',', '/DV': ''}, 'Generator_Mailing_Address': {'/T': 'Generator_Mailing_Address', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Generator_Phone': {'/T': 'Generator_Phone', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Transporter_1_Name': {'/T': 'Transporter_1_Name', '/FT': '/Tx', '/Ff': 0, '/V': 'CLEAN HARBORS ENVIRONMENTAL SERVICES INC', '/DV': ''}, 'Transporter_1_ID': {'/T': 'Transporter_1_ID', '/FT': '/Tx', '/Ff': 0, '/V': 'MAD039322250', '/DV': ''}, 'Transporter_2_Name': {'/T': 'Transporter_2_Name', '/FT': '/Tx', '/Ff': 0, '/V': 'CAMPBELL TRANSPORTATION CO, INC - CONGO OPERATIONS', '/DV': ''}, 'Transporter_2_ID': {'/T': 'Transporter_2_ID', '/FT': '/Tx', '/Ff': 0, '/V': 'WVD988786455', '/DV': ''}, 'Destination_Name': {'/T': 'Destination_Name', '/FT': '/Tx', '/Ff': 0, '/V': 'TEST TSDF OF VA', '/DV': ''}, 'Destination_ID': {'/T': 'Destination_ID', '/FT': '/Tx', '/Ff': 0, '/V': 'VAD000532119', '/DV': ''}, 'Destination_Address': {'/T': 'Destination_Address', '/FT': '/Tx', '/Ff': 0, '/V': '123 MAIN ST,ARLINGTON,VA,22202', '/DV': ''}, 'Destination_Phone': {'/T': 'Destination_Phone', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'HM_1': {'/T': 'HM_1', '/FT': '/Tx', '/Ff': 0, '/V': 'X', '/DV': ''}, 'HM_2': {'/T': 'HM_2', '/FT': '/Tx', '/Ff': 0, '/V': 'X', '/DV': ''}, 'HM_3': {'/T': 'HM_3', '/FT': '/Tx', '/Ff': 0, '/V': 'X', '/DV': ''}, 'HM_4': {'/T': 'HM_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Shipping_Description_1': {'/T': 'Shipping_Description_1', '/FT': '/Tx', '/Ff': 0, '/V': 'RQ, NA3077, HAZARDOUS WASTE, SOLID, N.O.S. (F037, K048), 9, PG III', '/DV': ''}, 'Shipping_Description_2': {'/T': 'Shipping_Description_2', '/FT': '/Tx', '/Ff': 0, '/V': 'NA3077, Hazardous Waste, Solid, N.O.S. (K171, K172), 9, PG III', '/DV': ''}, 'Shipping_Description_3': {'/T': 'Shipping_Description_3', '/FT': '/Tx', '/Ff': 0, '/V': 'NA3077, Hazardous Waste, Solid, N.O.S., (F037), 9, PG III', '/DV': ''}, 'Shipping_Description_4': {'/T': 'Shipping_Description_4', '/FT': '/Tx', '/Ff': 0, '/V': 'Waste, Non-DOT Regulated', '/DV': ''}, 'Containers_No_1': {'/T': 'Containers_No_1', '/FT': '/Tx', '/Ff': 0, '/V': '1', '/DV': ''}, 'Containers_No_2': {'/T': 'Containers_No_2', '/FT': '/Tx', '/Ff': 0, '/V': '8', '/DV': ''}, 'Containers_No_3': {'/T': 'Containers_No_3', '/FT': '/Tx', '/Ff': 0, '/V': '5', '/DV': ''}, 'Containers_No_4': {'/T': 'Containers_No_4', '/FT': '/Tx', '/Ff': 0, '/V': '2', '/DV': ''}, 'Containers_Type_1': {'/T': 'Containers_Type_1', '/FT': '/Tx', '/Ff': 0, '/V': 'CM', '/DV': ''}, 'Containers_Type_2': {'/T': 'Containers_Type_2', '/FT': '/Tx', '/Ff': 0, '/V': 'DF', '/DV': ''}, 'Containers_Type_3': {'/T': 'Containers_Type_3', '/FT': '/Tx', '/Ff': 0, '/V': 'DF', '/DV': ''}, 'Containers_Type_4': {'/T': 'Containers_Type_4', '/FT': '/Tx', '/Ff': 0, '/V': 'DF', '/DV': ''}, 'Total_Quantity_1': {'/T': 'Total_Quantity_1', '/FT': '/Tx', '/Ff': 0, '/V': '19000', '/DV': ''}, 'Total_Quantity_2': {'/T': 'Total_Quantity_2', '/FT': '/Tx', '/Ff': 0, '/V': '1000', '/DV': ''}, 'Total_Quantity_3': {'/T': 'Total_Quantity_3', '/FT': '/Tx', '/Ff': 0, '/V': '10', '/DV': ''}, 'Total_Quantity_4': {'/T': 'Total_Quantity_4', '/FT': '/Tx', '/Ff': 0, '/V': '2', '/DV': ''}, 'Units_1': {'/T': 'Units_1', '/FT': '/Tx', '/Ff': 0, '/V': 'P', '/DV': ''}, 'Units_2': {'/T': 'Units_2', '/FT': '/Tx', '/Ff': 0, '/V': 'G', '/DV': ''}, 'Units_3': {'/T': 'Units_3', '/FT': '/Tx', '/Ff': 0, '/V': 'EA', '/DV': ''}, 'Units_4': {'/T': 'Units_4', '/FT': '/Tx', '/Ff': 0, '/V': 'EA', '/DV': ''}, 'Waste_Code1_1': {'/T': 'Waste_Code1_1', '/FT': '/Tx', '/Ff': 0, '/V': 'F037', '/DV': ''}, 'Waste_Code1_2': {'/T': 'Waste_Code1_2', '/FT': '/Tx', '/Ff': 0, '/V': 'D001', '/DV': ''}, 'Waste_Code1_3': {'/T': 'Waste_Code1_3', '/FT': '/Tx', '/Ff': 0, '/V': 'D003', '/DV': ''}, 'Waste_Code1_4': {'/T': 'Waste_Code1_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code2_1': {'/T': 'Waste_Code2_1', '/FT': '/Tx', '/Ff': 0, '/V': 'K048', '/DV': ''}, 'Waste_Code2_2': {'/T': 'Waste_Code2_2', '/FT': '/Tx', '/Ff': 0, '/V': 'D005', '/DV': ''}, 'Waste_Code2_3': {'/T': 'Waste_Code2_3', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code2_4': {'/T': 'Waste_Code2_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code3_1': {'/T': 'Waste_Code3_1', '/FT': '/Tx', '/Ff': 0, '/V': 'K050', '/DV': ''}, 'Waste_Code3_2': {'/T': 'Waste_Code3_2', '/FT': '/Tx', '/Ff': 0, '/V': 'D006', '/DV': ''}, 'Waste_Code3_3': {'/T': 'Waste_Code3_3', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code3_4': {'/T': 'Waste_Code3_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code4_1': {'/T': 'Waste_Code4_1', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code4_2': {'/T': 'Waste_Code4_2', '/FT': '/Tx', '/Ff': 0, '/V': 'D007', '/DV': ''}, 'Waste_Code4_3': {'/T': 'Waste_Code4_3', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code4_4': {'/T': 'Waste_Code4_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code5_1': {'/T': 'Waste_Code5_1', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code5_2': {'/T': 'Waste_Code5_2', '/FT': '/Tx', '/Ff': 0, '/V': 'D009', '/DV': ''}, 'Waste_Code5_3': {'/T': 'Waste_Code5_3', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code5_4': {'/T': 'Waste_Code5_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code6_1': {'/T': 'Waste_Code6_1', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code6_2': {'/T': 'Waste_Code6_2', '/FT': '/Tx', '/Ff': 0, '/V': 'D021', '/DV': ''}, 'Waste_Code6_3': {'/T': 'Waste_Code6_3', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Waste_Code6_4': {'/T': 'Waste_Code6_4', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'item_info_1': {'/T': 'item_info_1', '/FT': '/Tx', '/Ff': 0, '/V': '1. TEST12367-1 CM, ERG:171;', '/DV': ''}, 'item_info_2': {'/T': 'item_info_2', '/FT': '/Tx', '/Ff': 0, '/V': '2. CH63770-8 DF;', '/DV': ''}, 'item_info_3': {'/T': 'item_info_3', '/FT': '/Tx', '/Ff': 0, '/V': '3. CH1258017B-5 DF;', '/DV': ''}, 'item_info_4': {'/T': 'item_info_4', '/FT': '/Tx', '/Ff': 0, '/V': '4. 044005-2 DF;', '/DV': ''}, 'Generator_Signature_Name': {'/T': 'Generator_Signature_Name', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Date_Generator_Shipped_Day': {'/T': 'Date_Generator_Shipped_Day', '/FT': '/Tx', '/Ff': 0, '/V': '28', '/DV': ''}, 'Date_Generator_Shipped_Month': {'/T': 'Date_Generator_Shipped_Month', '/FT': '/Tx', '/Ff': 0, '/V': '08', '/DV': ''}, 'Date_Generator_Shipped_Year': {'/T': 'Date_Generator_Shipped_Year', '/FT': '/Tx', '/Ff': 0, '/V': '2023', '/DV': ''}, 'Transporter_1_Signature_Name': {'/T': 'Transporter_1_Signature_Name', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Date_Transporter_1_Received_Material_Day': {'/T': 'Date_Transporter_1_Received_Material_Day', '/FT': '/Tx', '/Ff': 0, '/V': '28', '/DV': ''}, 'Date_Transporter_1_Received_Material_Month': {'/T': 'Date_Transporter_1_Received_Material_Month', '/FT': '/Tx', '/Ff': 0, '/V': '08', '/DV': ''}, 'Date_Transporter_1_Received_Material_Year': {'/T': 'Date_Transporter_1_Received_Material_Year', '/FT': '/Tx', '/Ff': 0, '/V': '2023', '/DV': ''}, 'Transporter_2_Signature_Name': {'/T': 'Transporter_2_Signature_Name', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Date_Transporter_2_Received_Material_Day': {'/T': 'Date_Transporter_2_Received_Material_Day', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Date_Transporter_2_Received_Material_Month': {'/T': 'Date_Transporter_2_Received_Material_Month', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Date_Transporter_3_Received_Material_Year': {'/T': 'Date_Transporter_3_Received_Material_Year', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Management_Method_1': {'/T': 'Management_Method_1', '/FT': '/Tx', '/Ff': 0, '/V': 'H040', '/DV': ''}, 'Management_Method_2': {'/T': 'Management_Method_2', '/FT': '/Tx', '/Ff': 0, '/V': 'H010', '/DV': ''}, 'Management_Method_3': {'/T': 'Management_Method_3', '/FT': '/Tx', '/Ff': 0, '/V': 'H039', '/DV': ''}, 'Management_Method_4': {'/T': 'Management_Method_4', '/FT': '/Tx', '/Ff': 0, '/V': 'H010', '/DV': ''}, 'Destination_Signature_Name': {'/T': 'Destination_Signature_Name', '/FT': '/Tx', '/Ff': 0, '/V': '', '/DV': ''}, 'Date_Destination_Received_Material_Day': {'/T': 'Date_Destination_Received_Material_Day', '/FT': '/Tx', '/Ff': 0, '/V': '28', '/DV': ''}, 'Date_Destination_Received_Material_Month': {'/T': 'Date_Destination_Received_Material_Month', '/FT': '/Tx', '/Ff': 0, '/V': '08', '/DV': ''}, 'Date_Destination_Received_Material_Year': {'/T': 'Date_Destination_Received_Material_Year', '/FT': '/Tx', '/Ff': 0, '/V': '2023', '/DV': ''}}

chinapandaman commented 3 weeks ago

So this thread has 3 different questions so I will try to address each of them separately.

1) After filling using FormWrapper texts don't get rendered. Unfortunately I don't know what to do about this as of now. I have explained this issue more in depth here. In short, it works for some PDF viewing apps but not for the others and I don't know why. 2) When i try to specify font directly in create_widget i've got an error. The error is pretty self explanatory, Arial Narrow is not one of the standard fonts. It is probably bundled within your PDF editing app that's why you are able to change it directly there. But it's just not in the PDF standard that's why you need to register it. 3) It would be nice to have multiline text options. This is now implemented in the PR linked to this thread and will be released next bump.