opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
50 stars 39 forks source link

PDF Generation from HTML #3232

Closed FikriMilano closed 1 month ago

FikriMilano commented 1 month ago

Describe the feature request. Create a feature to process HTML to a PDF

Additional context

Acceptance criteria

Area path A list of ordered steps in the app on usage of the feature to support anyone testing it e.g. Code reviewer, QA e.g.

  1. Use the HTML of the samples
  2. Pass it to the class that will generate a PDF
  3. Compare it w the PDF samples

Implementation plan (For Engineers)

  1. Create a class called PdfGenerator in org/smartregister/fhircore/engine/pdf
  2. On creation of PdfGenerator, define instance of WebView or PdfRendererBuilder(OpenPDF). By the time we want to generate a PDF, these instance are ready to use, and it should only be defined once
  3. Create a public function to launch the generator, that has htmlText as it's parameter. We will call this function on places like user interaction/on click/on submit questionnaire
FikriMilano commented 1 month ago

@pld feel free to review this ticket

pld commented 1 month ago

Can you please add details on how you will add the PDF generation, like

1) where in the package hierarchy 2) what will the facade look like for the external library (i.e. architect so if we start with webview and switch to openpdf we make minimal changes to the code

plus any other relevant details about the code implementation, thank you!

pld commented 1 month ago

cc @ellykits @ndegwamartin

FikriMilano commented 1 month ago

@pld thanks, the detailed plan has been added to the ticket. It's fairly simple, assuming the HTML is ready to print (i.e. values from Questionnaire Response has been populated to the HTML). The population from QR to HTML will happen outside of this class as there's no reason to make those 2 functionality tightly coupled.

Functionality that I mean:

  1. Populating answers from QR to HTML (https://github.com/opensrp/fhircore/issues/3257)
  2. Generate PDF using HTML (this ticket)

Hope that makes sense.

ellykits commented 1 month ago

@FikriMilano On the implementation plan:

Create a public function to launch the generator, that has htmlText as it's parameter. We will call this function on places like user interaction/on click/on submit questionnaire

Can this be implemented as new ApplicationWorkflow that can be triggered via any view actions.

FikriMilano commented 1 month ago

@ellykits yep, and it will happen in ticket https://github.com/opensrp/fhircore/issues/3235

pld commented 1 month ago

looks good!