Open vatsenko opened 3 months ago
side notes (minor bugs)
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.\
It would be nice to have multiline text options
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': ''}}
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.
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
PDF Form Template
output.pdf
Fixed Form
fixed.pdf
Screenshots (if applicable)