Skip to content

Commit

Permalink
Feat/final pdf (#100)
Browse files Browse the repository at this point in the history
* changes for vaccination

* changes for test and recovery

* changes for test and recovery

* justify text in pdf

* rotated third page with block

* revised rotated justify block

* revised

* label for disease recovery is different from test and vaccination

* show certificate as table

* changed certificates from table view back to horizontal

Co-authored-by: Gordon Grund <[email protected]>
  • Loading branch information
fOppenheimer and ggrund-tsi authored Jun 17, 2021
1 parent 8b0d644 commit e7d50f0
Showing 1 changed file with 44 additions and 65 deletions.
109 changes: 44 additions & 65 deletions src/components/pdf-generater.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef
if (eudccProp) {
setEudcc(eudccProp);

const vacc : [VaccinationEntry] = eudccProp.v as [VaccinationEntry];
const test : [TestEntry] = eudccProp.t as [TestEntry];
const vacc: [VaccinationEntry] = eudccProp.v as [VaccinationEntry];
const test: [TestEntry] = eudccProp.t as [TestEntry];
const recovery: [RecoveryEntry] = eudccProp.r as [RecoveryEntry];

setVaccinationSet(vacc ? vacc[0] : undefined);
Expand Down Expand Up @@ -610,43 +610,43 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef

y = printDisease(xLeft, y, lineHeight, lblDisease, lblFrench);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfVaccineProphylaxis'),
french.translation.pdfVaccineProphylaxis,
getValueSetDisplay(vaccinationSet.vp, vaccines),
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfVaccineMedicalProduct'),
french.translation.pdfVaccineMedicalProduct,
getValueSetDisplay(vaccinationSet.mp, vacMedsData),
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfVaccineManufacturer'),
french.translation.pdfVaccineManufacturer,
getValueSetDisplay(vaccinationSet.ma, vaccineManufacturers),
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfNumberOfDoses'),
french.translation.pdfNumberOfDoses,
vaccinationSet.dn.toString() + ' / ' + vaccinationSet.sd.toString(),
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfDateOfVaccination'),
french.translation.pdfDateOfVaccination,
vaccinationSet.dt,
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfMemberStateOfVaccination'),
french.translation.pdfMemberStateOfVaccination,
vaccinationSet.co,
lineHeight, true);

printAsTableRow(xLeft, y,
printHorizontalBlock(xLeft, y,
t('translation:pdfCertificateIssuer'),
french.translation.pdfCertificateIssuer,
vaccinationSet.is,
Expand Down Expand Up @@ -718,43 +718,43 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef
lblDisease,
lblFrench);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfVaccineProphylaxis'),
french.translation.pdfVaccineProphylaxis,
getValueSetDisplay(vaccinationSet.vp, vaccines),
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfVaccineMedicalProduct'),
french.translation.pdfVaccineMedicalProduct,
getValueSetDisplay(vaccinationSet.mp, vacMedsData),
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfVaccineManufacturer'),
french.translation.pdfVaccineManufacturer,
getValueSetDisplay(vaccinationSet.ma, vaccineManufacturers),
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfNumberOfDoses'),
french.translation.pdfNumberOfDoses,
vaccinationSet.dn.toString() + ' / ' + vaccinationSet.sd.toString(),
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfDateOfVaccination'),
french.translation.pdfDateOfVaccination,
vaccinationSet.dt,
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfMemberStateOfVaccination'),
french.translation.pdfMemberStateOfVaccination,
vaccinationSet.co,
lineHeight, true);

printAsTableRowRotated(xLeft, y,
printHorizontalBlockRotated(xLeft, y,
t('translation:pdfCertificateIssuer'),
french.translation.pdfCertificateIssuer,
vaccinationSet.is,
Expand Down Expand Up @@ -788,49 +788,49 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef

y = printDisease(x, y, lineHeight, lblDisease, lblFrench);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfTypeOfTest'),
french.translation.pdfTypeOfTest,
getValueSetDisplay(testSet.tt, testTypeValueSet),
lineHeight, true);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfTestName'),
french.translation.pdfTestName,
testSet.nm,
lineHeight, true);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfTestManufacturer'),
french.translation.pdfTestManufacturer,
getValueSetDisplay(testSet.ma, testManufacturersValueSet),
lineHeight, true);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfDateSampleCollection'),
french.translation.pdfDateSampleCollection,
convertDateToOutputFormat(testSet.sc),
lineHeight, true);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfTestResult'),
french.translation.pdfTestResult,
getValueSetDisplay(testSet.tr, testResultValueSet),
lineHeight, true);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfTestingCentre'),
french.translation.pdfTestingCentre,
testSet.tc,
lineHeight, true);

y = printAsTableRow(x, y,
y = printHorizontalBlock(x, y,
t('translation:pdfStateOfVaccination'),
french.translation.pdfStateOfVaccination,
testSet.co,
lineHeight, true);

printAsTableRow(x, y,
printHorizontalBlock(x, y,
t('translation:pdfCertificateIssuer'),
french.translation.pdfCertificateIssuer,
testSet.is,
Expand Down Expand Up @@ -864,49 +864,49 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef
lblDisease,
lblFrench);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfTypeOfTest'),
french.translation.pdfTypeOfTest,
getValueSetDisplay(testSet.tt, testTypeValueSet),
lineHeight, true);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfTestName'),
french.translation.pdfTestName,
testSet.nm ? testSet.nm : ' ',
lineHeight, true);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfTestManufacturer'),
french.translation.pdfTestManufacturer,
getValueSetDisplay(testSet.ma, testManufacturersValueSet),
lineHeight, true);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfDateSampleCollection'),
french.translation.pdfDateSampleCollection,
convertDateToOutputFormat(testSet.sc),
lineHeight, true);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfTestResult'),
french.translation.pdfTestResult,
getValueSetDisplay(testSet.tr, testResultValueSet),
lineHeight, true);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfTestingCentre'),
french.translation.pdfTestingCentre,
testSet.tc,
lineHeight, true);

y = printAsTableRowRotated(x, y,
y = printHorizontalBlockRotated(x, y,
t('translation:pdfStateOfVaccination'),
french.translation.pdfStateOfVaccination,
testSet.co,
lineHeight, true);

printAsTableRowRotated(x, y,
printHorizontalBlockRotated(x, y,
t('translation:pdfCertificateIssuer'),
french.translation.pdfCertificateIssuer,
testSet.is,
Expand Down Expand Up @@ -943,30 +943,30 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef

y = printDisease(xLeft, y, lineHeight, lblDisease, lblFrench);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfDatePositiveTestResult'),
french.translation.pdfDatePositiveTestResult,
recoverySet.fr);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfStateOfTest'),
french.translation.pdfStateOfTest,
recoverySet.co,
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfCertificateIssuer'),
french.translation.pdfCertificateIssuer,
recoverySet.is,
lineHeight, true);

y = printAsTableRow(xLeft, y,
y = printHorizontalBlock(xLeft, y,
t('translation:pdfValidFrom'),
french.translation.pdfValidFrom,
recoverySet.df,
lineHeight, true);

printAsTableRow(xLeft, y,
printHorizontalBlock(xLeft, y,
t('translation:pdfValidTo'),
french.translation.pdfValidTo,
recoverySet.du,
Expand Down Expand Up @@ -1005,59 +1005,38 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef
lblDisease,
lblFrench);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfDatePositiveTestResult'),
french.translation.pdfDatePositiveTestResult,
recoverySet.fr);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfStateOfTest'),
french.translation.pdfStateOfTest,
recoverySet.co,
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfCertificateIssuer'),
french.translation.pdfCertificateIssuer,
recoverySet.is,
lineHeight, true);

y = printAsTableRowRotated(xLeft, y,
y = printHorizontalBlockRotated(xLeft, y,
t('translation:pdfValidFrom'),
french.translation.pdfValidFrom,
recoverySet.df,
lineHeight, true);

printAsTableRowRotated(xLeft, y,
printHorizontalBlockRotated(xLeft, y,
t('translation:pdfValidTo'),
french.translation.pdfValidTo,
recoverySet.du,
lineHeight, true);
}
}

// const printSplittedLine = (x: number, y: number, lblLeft: any, lblLeftFrench: any): number => {
// let result = 0;

// if (pdf) {
// pdf.setFont('arial', 'bold');
// lblLeft = pdf.splitTextToSize(lblLeft, lblLength);
// pdf.text(lblLeft, x, y);

// pdf.setFont('arial', 'normal');

// const lineheight = lblLeft.length > 2 ? params.lineHeight10 + 1 : params.lineHeight10;
// y += (lineheight * lblLeft.length) + params.space;
// lblLeftFrench = pdf.splitTextToSize(lblLeftFrench, lblLength);
// pdf.text(lblLeftFrench, x, y);

// result = y + params.lineHeight10 * lblLeftFrench.length;
// }

// return result;
// }

const printVerticalBlock = (x: number, y: number, lbl: any, lblFrench: any, value?: string, lineHeight?: number, isItalic?: boolean): number => {
const printHorizontalBlock = (x: number, y: number, lbl: any, lblFrench: any, value?: string, lineHeight?: number, isItalic?: boolean): number => {
let result = y;
lineHeight = lineHeight ? lineHeight : params.lineHeight;

Expand Down Expand Up @@ -1154,7 +1133,7 @@ const usePdfGenerator = (qrCodeCanvasElementProp: any, eudccProp: EUDCC1 | undef
return result;
}

const printVerticalBlockRotated = (x: number, y: number, lbl: any, lblFrench: any, value?: string, lineHeight?: number, isItalic?: boolean): number => {
const printHorizontalBlockRotated = (x: number, y: number, lbl: any, lblFrench: any, value?: string, lineHeight?: number, isItalic?: boolean): number => {
let result = y;
lineHeight = lineHeight ? lineHeight : params.lineHeight;

Expand Down

0 comments on commit e7d50f0

Please sign in to comment.