Skip to content

Commit

Permalink
Reverting hot-fix for Text in PDF text areas appear blurry (browser) .
Browse files Browse the repository at this point in the history
[#182287388]
  • Loading branch information
EricMN35Johnson committed Jun 7, 2022
1 parent e410bc5 commit b010465
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 179 deletions.
Expand Up @@ -152,138 +152,4 @@ public Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldWithCAFHHSuppFiller
CAF, clientCafWdHouseholdSuppFiller )
);
}

@Bean
public PdfFieldFiller ramseyCaseworkerCafFiller(
@Value("classpath:ramsey-cover-pages.pdf") Resource coverPages,
@Value("classpath:caf-body.pdf") Resource cafBody
) {
return new PDFBoxFieldFiller(List.of(coverPages, cafBody));
}
@Bean
public PdfFieldFiller ramseyCaseworkerCafWdHouseholdSuppFiller(
@Value("classpath:ramsey-cover-pages.pdf") Resource coverPages,
@Value("classpath:caf-body.pdf") Resource cafBody,
@Value("classpath:caf-household-member-supplement.pdf") Resource cafBodyWdHouseholdSupp
) {
return new PDFBoxFieldFiller(List.of(
coverPages, cafBody,cafBodyWdHouseholdSupp
));
}

@Bean
public PdfFieldFiller ramseyClientCafFiller(
@Value("classpath:cover-pages.pdf") Resource coverPages,
@Value("classpath:caf-standard-headers.pdf") Resource standardHeaders,
@Value("classpath:caf-body.pdf") Resource cafBody,
@Value("classpath:caf-standard-footers.pdf") Resource standardFooters
) {
return new PDFBoxFieldFiller(List.of(
coverPages, standardHeaders, cafBody, standardFooters
));
}

@Bean
public PdfFieldFiller ramseyClientCafWdHouseholdSuppFiller(
@Value("classpath:cover-pages.pdf") Resource coverPages,
@Value("classpath:caf-standard-headers.pdf") Resource standardHeaders,
@Value("classpath:caf-body.pdf") Resource cafBody,
@Value("classpath:caf-household-member-supplement.pdf") Resource cafBodyWdHouseholdSupp,
@Value("classpath:caf-standard-footers.pdf") Resource standardFooters
) {
return new PDFBoxFieldFiller(List.of(
coverPages, standardHeaders, cafBody, standardFooters, cafBodyWdHouseholdSupp
));
}

@Bean
public PdfFieldFiller ramseyCaseworkerCcapFiller(
@Value("classpath:ramsey-cover-pages.pdf") Resource coverPages,
@Value("classpath:ccap-body-caseworker-page1.pdf") Resource ccapPage1,
@Value("classpath:ccap-body.pdf") Resource ccapBody,
@Value("classpath:ccap-body-perjury-and-general-declarations.pdf") Resource ccapDeclarations,
@Value("classpath:ccap-body-additional-room.pdf") Resource ccapAdditionalRoom
) {
return new PDFBoxFieldFiller(List.of(
coverPages, ccapPage1, ccapBody, ccapDeclarations, ccapAdditionalRoom
));
}

@Bean
public PdfFieldFiller ramseyClientCcapFiller(
@Value("classpath:cover-pages.pdf") Resource coverPages,
@Value("classpath:ccap-headers.pdf") Resource ccapHeaders,
@Value("classpath:ccap-body-client-page1.pdf") Resource ccapPage1,
@Value("classpath:ccap-body.pdf") Resource ccapBody,
@Value("classpath:ccap-body-authorize-info-sharing.pdf") Resource ccapInfoSharing,
@Value("classpath:ccap-body-perjury-and-general-declarations.pdf") Resource ccapDeclarations,
@Value("classpath:ccap-body-additional-room.pdf") Resource ccapAdditionalRoom,
@Value("classpath:ccap-footers.pdf") Resource ccapFooters
) {
return new PDFBoxFieldFiller(List.of(
coverPages, ccapHeaders, ccapPage1, ccapBody, ccapInfoSharing, ccapDeclarations,
ccapAdditionalRoom, ccapFooters
));
}

@Bean
public PdfFieldFiller ramseyCaseworkerCertainPopsFiller(
@Value("classpath:ramsey-cover-pages.pdf") Resource coverPages,
@Value("classpath:certain-pops.pdf") Resource certainPops
) {
return new PDFBoxFieldFiller(List.of(coverPages, certainPops));
}

@Bean
public PdfFieldFiller ramseyClientCertainPopsFiller(
@Value("classpath:cover-pages.pdf") Resource coverPages,
@Value("classpath:certain-pops.pdf") Resource certainPops
) {
return new PDFBoxFieldFiller(List.of(coverPages, certainPops));
}

@Bean
public PdfFieldFiller ramseyUploadedDocCoverPageFilter(
@Value("classpath:uploaded-document-cover-page.pdf") Resource coverPage
) {
return new PDFBoxFieldFiller(List.of(coverPage));
}

@Bean
public Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldFillers(
PdfFieldFiller ramseyCaseworkerCafFiller,
PdfFieldFiller ramseyClientCafFiller,
PdfFieldFiller ramseyCaseworkerCcapFiller,
PdfFieldFiller ramseyClientCcapFiller,
PdfFieldFiller ramseyCaseworkerCertainPopsFiller,
PdfFieldFiller ramseyClientCertainPopsFiller,
PdfFieldFiller ramseyUploadedDocCoverPageFilter,
PdfFieldFiller ramseyClientCafWdHouseholdSuppFiller,
PdfFieldFiller ramseyCaseworkerCafWdHouseholdSuppFiller) {
return Map.of(
CASEWORKER, Map.of(
CAF, ramseyCaseworkerCafFiller,
CCAP, ramseyCaseworkerCcapFiller,
UPLOADED_DOC, ramseyUploadedDocCoverPageFilter,
CERTAIN_POPS, ramseyCaseworkerCertainPopsFiller
),
CLIENT, Map.of(
CAF, ramseyClientCafFiller,
CCAP, ramseyClientCcapFiller,
CERTAIN_POPS, ramseyClientCertainPopsFiller )
);
}

@Bean
public Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldWithCAFHHSuppFillers(
PdfFieldFiller ramseyCaseworkerCafWdHouseholdSuppFiller,
PdfFieldFiller ramseyClientCafWdHouseholdSuppFiller) {
return Map.of(
CASEWORKER, Map.of(
CAF, ramseyCaseworkerCafWdHouseholdSuppFiller
),
CLIENT, Map.of(
CAF, ramseyClientCafWdHouseholdSuppFiller )
);
}
}
Expand Up @@ -49,8 +49,6 @@ public class PdfGenerator implements FileGenerator {
private final PdfFieldMapper pdfFieldMapper;
private final Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldFillerMap;
private final Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldWithCAFHHSuppFillersMap;
private final Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldFillerMap;
private final Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldWithCAFHHSuppFillersMap;
private final ApplicationRepository applicationRepository;
private final DocumentRepository documentRepository;
private final DocumentFieldPreparers preparers;
Expand All @@ -59,12 +57,9 @@ public class PdfGenerator implements FileGenerator {
private final FeatureFlagConfiguration featureFlags;
private final CountyMap<CountyRoutingDestination> countyMap;

@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
public PdfGenerator(PdfFieldMapper pdfFieldMapper,
Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldFillers,
Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldWithCAFHHSuppFillers,
Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldFillers,
Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldWithCAFHHSuppFillers,
ApplicationRepository applicationRepository,
DocumentRepository documentRepository,
DocumentFieldPreparers preparers,
Expand All @@ -82,8 +77,6 @@ public PdfGenerator(PdfFieldMapper pdfFieldMapper,
this.pdfWordConverter = pdfWordConverter;
this.featureFlags = featureFlagConfiguration;
this.pdfFieldWithCAFHHSuppFillersMap = pdfFieldWithCAFHHSuppFillers;
this.ramseyPdfFieldFillerMap = ramseyPdfFieldFillers;
this.ramseyPdfFieldWithCAFHHSuppFillersMap = ramseyPdfFieldWithCAFHHSuppFillers;
this.countyMap = countyMap;
}

Expand Down Expand Up @@ -123,18 +116,10 @@ private ApplicationFile generateWithFilename(Application application, Document d
recipient);
var houseHold = application.getApplicationData().getApplicantAndHouseholdMember();
PdfFieldFiller pdfFiller = pdfFieldFillerMap.get(recipient).get(document);
if(countyMap.get(application.getCounty()).getName().equals("Ramsey")) {
if(document.equals(Document.CAF) && (houseHold.size() > 5 && houseHold.size() <= 10)){
pdfFiller = ramseyPdfFieldWithCAFHHSuppFillersMap.get(recipient).get(document);
}else{
pdfFiller = ramseyPdfFieldFillerMap.get(recipient).get(document);
}
}else{
if(document.equals(Document.CAF) && (houseHold.size() > 5 && houseHold.size() <= 10)) {
pdfFiller = pdfFieldWithCAFHHSuppFillersMap.get(recipient).get(document);
}
if(document.equals(Document.CAF) && (houseHold.size() > 5 && houseHold.size() <= 10)) {
pdfFiller = pdfFieldWithCAFHHSuppFillersMap.get(recipient).get(document);
}

List<PdfField> fields = pdfFieldMapper.map(documentFields);
return pdfFiller.fill(fields, application.getId(), filename);
}
Expand Down Expand Up @@ -171,7 +156,7 @@ public ApplicationFile generateForUploadedDocument(UploadedDocument uploadedDocu
fileBytes = addCoverPageToPdf(coverPage, fileBytes);
}
String filename = uploadedDocument.getSysFileName();
filename = (filename == null || (!filename.contains(routingDest.getDhsProviderId())))
filename = (filename == null || (filename!=null && !filename.contains(routingDest.getDhsProviderId())))
? fileNameGenerator.generateUploadedDocumentName(application, documentIndex, extension, routingDest)
: uploadedDocument.getSysFileName();
return new ApplicationFile(fileBytes, filename);
Expand Down
Binary file modified src/main/resources/cover-pages.pdf
Binary file not shown.
Binary file removed src/main/resources/ramsey-cover-pages.pdf
Binary file not shown.
Expand Up @@ -8,8 +8,6 @@

import java.util.List;
import java.util.Map;

import org.codeforamerica.shiba.County;
import org.codeforamerica.shiba.CountyMap;
import org.codeforamerica.shiba.TribalNationRoutingDestination;
import org.codeforamerica.shiba.application.Application;
Expand Down Expand Up @@ -37,11 +35,9 @@ class PdfGeneratorTest {
private FilenameGenerator fileNameGenerator;
private Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldFillers;
private Map<Recipient, Map<Document, PdfFieldFiller>> pdfFieldWithCAFHHSuppFillers;
private Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldFillers;
private Map<Recipient, Map<Document, PdfFieldFiller>> ramseyPdfFieldWithCAFHHSuppFillers;
private FeatureFlagConfiguration featureFlags;
private CountyMap<CountyRoutingDestination> countyMap;
private CountyRoutingDestination defaultCountyRoutingDestination;

@BeforeEach
void setUp() {
pdfFieldMapper = mock(PdfFieldMapper.class);
Expand All @@ -50,20 +46,12 @@ void setUp() {
PdfFieldFiller clientCafWdHouseholdSuppFiller = mock(PdfFieldFiller.class);
PdfFieldFiller clientFiller = mock(PdfFieldFiller.class);
PdfFieldFiller ccapFiller = mock(PdfFieldFiller.class);

PdfFieldFiller ramseyClientCafWdHouseholdSuppFiller = mock(PdfFieldFiller.class);
PdfFieldFiller ramseyClientFiller = mock(PdfFieldFiller.class);
PdfFieldFiller ramseyCcapFiller = mock(PdfFieldFiller.class);
preparers = mock(DocumentFieldPreparers.class);
ApplicationRepository applicationRepository = mock(ApplicationRepository.class);
fileNameGenerator = mock(FilenameGenerator.class);
FileToPDFConverter pdfWordConverter = mock(FileToPDFConverter.class);
featureFlags = mock(FeatureFlagConfiguration.class);
countyMap = new CountyMap<>();
defaultCountyRoutingDestination = CountyRoutingDestination.builder()
.county(County.Anoka).phoneNumber("555-5555").build();
countyMap.setDefaultValue(defaultCountyRoutingDestination);



pdfFieldFillers = Map.of(
CASEWORKER, Map.of(Document.CAF, caseworkerFiller, Document.CCAP, ccapFiller),
Expand All @@ -75,16 +63,6 @@ void setUp() {
CLIENT, Map.of(Document.CAF, clientCafWdHouseholdSuppFiller)
);

ramseyPdfFieldFillers = Map.of(
CASEWORKER, Map.of(Document.CAF, caseworkerFiller, Document.CCAP, ramseyCcapFiller),
CLIENT, Map.of(Document.CAF, ramseyClientFiller, Document.CCAP, ramseyCcapFiller)
);

ramseyPdfFieldWithCAFHHSuppFillers = Map.of(
CASEWORKER, Map.of(Document.CAF, caseworkerCafWdHouseholdSuppFiller),
CLIENT, Map.of(Document.CAF, ramseyClientCafWdHouseholdSuppFiller)
);

application = Application.builder()
.id(applicationId)
.completedAt(null)
Expand All @@ -96,8 +74,6 @@ void setUp() {
pdfFieldMapper,
pdfFieldFillers,
pdfFieldWithCAFHHSuppFillers,
ramseyPdfFieldFillers,
ramseyPdfFieldWithCAFHHSuppFillers,
applicationRepository,
null,
preparers,
Expand Down

0 comments on commit b010465

Please sign in to comment.