Class PdfAcroFormServiceImpl
java.lang.Object
ch.tocco.nice2.conversion.impl.PdfAcroFormServiceImpl
- All Implemented Interfaces:
PdfAcroFormService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfillAcroForm(File pdfFile, Map<String, String> fieldValues) Reads a pdf containing a AcroForm from the given input stream, sets all field values and returns the resulting PDF in the given OutputStream Fields are handled as follows: - if null is passed as value, the field is skipped - if the field is a PDCheckbox, the value is parsed as boolean, pass "true" to check it - if the field is a PDRadiobutton, the value is parsed as int (the index of the option to be selected) - else the string value is set as isvoidfindAcroFieldnames(File pdfFile) This is a helper function that can be used to find the FullyQualified field names of an AcroForm - logs all fieldnames with some type information - prints the fieldname of all textfields into the field itself This method should probably not be used in production code, but it is very handy when implementing an automatic AcroForm field mappingvoidoverlayImage(File pdfFile, String fieldname, byte[] image) Overlays an image over a PDF AcroForm Field The image is scaled as follows: - If the image is wider than the form field, the image is scaled down to the width of the field - If the shrinked image is higher than the form field, it is centered vertically over the form field and might overlapvoidremovePage(File pdfFile, int pageNumber) Removes a page from a pdf document
-
Constructor Details
-
PdfAcroFormServiceImpl
public PdfAcroFormServiceImpl(org.slf4j.Logger log)
-
-
Method Details
-
fillAcroForm
Description copied from interface:PdfAcroFormServiceReads a pdf containing a AcroForm from the given input stream, sets all field values and returns the resulting PDF in the given OutputStream Fields are handled as follows: - if null is passed as value, the field is skipped - if the field is a PDCheckbox, the value is parsed as boolean, pass "true" to check it - if the field is a PDRadiobutton, the value is parsed as int (the index of the option to be selected) - else the string value is set as is- Specified by:
fillAcroFormin interfacePdfAcroFormService- Parameters:
pdfFile- The file used to read the pdf and to save the resultfieldValues- a map of all field values to be replaced, use the FullyQualifiedName as key- Throws:
IOException
-
removePage
Description copied from interface:PdfAcroFormServiceRemoves a page from a pdf document- Specified by:
removePagein interfacePdfAcroFormService- Parameters:
pdfFile- The file used to read the pdf and to save the resultpageNumber- 0 based index of page to remove- Throws:
IOException
-
overlayImage
Description copied from interface:PdfAcroFormServiceOverlays an image over a PDF AcroForm Field The image is scaled as follows: - If the image is wider than the form field, the image is scaled down to the width of the field - If the shrinked image is higher than the form field, it is centered vertically over the form field and might overlap- Specified by:
overlayImagein interfacePdfAcroFormService- Parameters:
pdfFile- The file used to read the pdf and to save the resultfieldname- Fully qualified name of field where the image should be placedimage- The image (byte array)- Throws:
IOException
-
findAcroFieldnames
Description copied from interface:PdfAcroFormServiceThis is a helper function that can be used to find the FullyQualified field names of an AcroForm - logs all fieldnames with some type information - prints the fieldname of all textfields into the field itself This method should probably not be used in production code, but it is very handy when implementing an automatic AcroForm field mapping- Specified by:
findAcroFieldnamesin interfacePdfAcroFormService- Parameters:
pdfFile- The file used to read the pdf and to save the result- Throws:
IOException
-