[
https://issues.apache.org/jira/browse/PDFBOX-4216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16470849#comment-16470849
]
Maruan Sahyoun commented on PDFBOX-4216:
----------------------------------------
Could you run the following code, which prints the field values together with
the calculated string width:
{code:java}
String formTemplate = "test.pdf";
PDDocument pdfDocument = PDDocument.load(new File(formTemplate));
PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
PDFont cour =
acroForm.getDefaultResources().getFont(COSName.getPDFName("Cour"));
List<PDField> fieldList = acroForm.getFields();
for (PDField pdField : fieldList) {
String fieldValue = pdField.getValueAsString();
System.out.println("value: " + fieldValue + " width: " +
cour.getStringWidth(fieldValue));
}
pdfDocument.close();
{code}
On my system this prints
{noformat}
value: 64654.33 width: 4800.7812
value: 63.25 width: 3000.4883
value: width: 0.0
value: 663.44 width: 3600.586
value: TESTPDF ABC width: 6601.074
value: 99.55 width: 3000.4883
value: 56.89 width: 3000.4883
value: TESTPDF width: 4200.6836
value: syf width: 1800.293
value: 895.66 width: 3600.586
value: 55.22 width: 3000.4883
value: 965.36 width: 3600.586
value: 88.56 width: 3000.4883
value: 798.56 width: 3600.586
value: 45465.22 width: 4800.7812
value: 455.66 width: 3600.586
value: width: 0.0
value: width: 0.0
value: width: 0.0
value: width: 0.0
value: width: 0.0
value: 4654.56 width: 4200.6836
value: 545.13 width: 3600.586
value: 564.65 width: 3600.586
value: 89.22 width: 3000.4883
value: 56.65 width: 3000.4883
value: 789.45 width: 3600.586
value: 15.645 width: 3600.586
value: 13.456 width: 3600.586
value: 64.454 width: 3600.586
value: 63.56 width: 3000.4883
value: 89.12 width: 3000.4883
value: 63.45 width: 3000.4883
value: 89.15 width: 3000.4883
value: 54.25 width: 3000.4883
{noformat}
> PDFBox decimal value cutting off in Red Hat Enterprise 7.4
> ----------------------------------------------------------
>
> Key: PDFBOX-4216
> URL: https://issues.apache.org/jira/browse/PDFBOX-4216
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.9
> Environment: LINUX
> Reporter: Jim Halpert
> Priority: Major
> Attachments: Capture.PNG, pdfbox_issue.PNG,
> pdfbox_linux_issue-saved-AR.pdf, pdfbox_linux_issue-saved.pdf,
> pdfbox_linux_issue.pdf, test.pdf
>
>
> Facing issue with Pdf decimal value mapping in the pdffiled in LINUX
> environment, right side decimal values are cutting off, appreciate quick help
> on this.
> {code:java}
> PDDocument pdfDoc = PDDocument.load(new File("pdfbox_linux_issue.pdf"));
> PDDocumentCatalog docCatalog = pdfDoc.getDocumentCatalog();
> PDAcroForm acroForm = docCatalog.getAcroForm();
> Map m = new HashMap();
> m.put("amtPaidForUnit", "15,999.23");
> m.put("amtPubFreightFees", "22.55");
> m.put("amtPaidTotAccessories", "45612.12");
> m.put("dealerDocPrepFees", "55.22");
> m.put("amtDownTradeTotal", "56.89");
> m.put("amtPaidSalesTax", "99.55");
> m.put("amtSerContractTo", "895.66");
> m.put("amtSerContractAmt", "965.36");
> m.put("amtGapProtTo", "798.56");
> m.put("amtGapProtAmt", "64654.33");
> m.put("amtTireGuardTo", "45465.22");
> m.put("amtTireGuardAmt", "455.66");
> m.put("amtPaidOptExtWarr", "88.56");
> m.put("amtPaidOptExtWarrAmt", "663.44");
> m.put("amtPubTitleFees", "54.25");
> m.put("amtPubLicFees", "4654.56");
> m.put("amtPubRegFees", "545.13");
> m.put("amtPubLienFees", "89.22");
> m.put("amtPubFilingFees", "564.65");
> m.put("amtPubStampFees", "56.65");
> m.put("amtPubToAmt", "789.45");
> m.put("amtPubTo2Amt", "15.645");
> m.put("subtotalOfSectionsABC", "13.456");
> m.put("amtLenderOrigFeesAmt", "64.454");
> m.put("amtLender1FeesAmt", "63.56");
> m.put("subtotalOfSection2", "89.12");
> m.put("subtotalOfSection3", "63.45");
> m.put("subtotalOfSection4", "89.15");
> m.put("discAmtFinanced", "63.25");
> for (Object fieldObj : acroForm.getFields())
> {
> PDField field = (PDField) fieldObj;
> if (m.get(field.getFullyQualifiedName()) != null) // set value of
> map when map key and pdf key is matched
> {
>
> field.setValue(m.get(field.getFullyQualifiedName()).toString());
> }
> }
>
> pdfDoc.save(new File("pdfbox_linux_issue-saved.pdf"));
> {code}
> Works in Windows, Linux Mint, Ubuntu as expected. Issue is only with Red Hat
> Enterprise 7.4.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]