Typdf exists as an alternative for those who need a "markdown-first" workflow. Rather than converting heavy HTML and CSS—which can sometimes be unpredictable for print—Typdf uses a native typesetting system. This results in significantly faster generation times and lower RAM usage, making it a great fit for high-traffic or enterprise environments.
Initial tests have suggested, large PDFs (about 100+ pages) that took more than 1 min to generate are taking 2-3 seconds with the help of Typdf. The module depends on a Rust based compiler called Typst, another open source project.
Comments
Comment #2
mayankguptadotcom commentedComment #3
vishal.kadamComment #4
avpadernoThank you for applying!
Before giving links helpful to understand how the review process works, what to expect from a review, and what to do to avoid a review takes more time than needed, I would like to thank all the reviewers for the work they do.
These applications are volunters-driven, which also means it is not possible to predict when an application will be marked fixed and the applicant will get the permission to opt projects into security advisory policy. While we aim to make an application as quick as possible, it is also important for us that more people review the project used for an application. In this way, we make sure applications do not miss some important points that should be instead reported.
Applications are not meant to be complete debugging sessions that eliminate every existing bug, though. I apologize if sometimes applications seem to go into too-detailed reviews.
Please read Review process for security advisory coverage: What to expect for more details and Security advisory coverage application checklist to understand what reviewers look for. Tips for ensuring a smooth review gives some hints for a smoother review.
The important notes are the following.
Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
To the reviewers
Please read How to review security advisory coverage applications, Application workflow, What to cover in an application review, and Tools to use for reviews.
The important notes are the following.
For new reviewers, I would also suggest to first read In which way the issue queue for coverage applications is different from other project queues.
Comment #5
vishal.kadam1. FILE: README.md
The README file is missing the required sections - Requirements, Installation and Configuration.
2. FILE: typdf.info.yml
package: CustomCustom is not a package value used for projects hosted on drupal.org. That is not a mandatory value, and it can be omitted.
3. FILE: typdf.module
Since the module is declared compatible with Drupal 10.3, removing the function implementing the hook is not possible. The function still needs to be defined, but it calls the method defined by the service class, as described in Support for object oriented hook implementations using autowired services (Backwards-compatible Hook implementation for Drupal versions from 10.1 to 11.0).
Drupal does not have primary and secondary hooks. Instead of that, it is preferable to use the usual description: “Hook implementations for the [module name] module”, where [module name] is the name of the module given in its .info.yml file.
4. FILE: src/TypstTemplateListBuilder.php
Modules which are compatible with Drupal 10 and higher versions are expected to use constructor property promotion. Please apply this in other places as well.
5. FILE: src/Entity/TypstTemplate.php, src/Plugin/Action/GenerateTypstPdfAction.php, src/Plugin/QueueWorker/TypdfRegenerationQueueWorker.php, src/Plugin/views/display/TypstPdfExportDisplay.php, src/Plugin/views/display/TypstDataExportDisplay.php
Projects that are compatible with Drupal 10 or higher versions should use attributes instead of annotations.
6. FILE: src/Form/TypdfSettingsForm.php
With Drupal 10 and Drupal 11, there is no longer need to use #default_value for each form element, when the parent class is ConfigFormBase: It is sufficient to use #config_target, as in the following code.
Using that code, it is no longer needed to save the configuration values in the form submission handler: The parent class will take care of that.
Comment #6
mayankguptadotcom commented@vishal.kadam - Suggested changes have been done.
1. typdf.info.yml Package Value (Point 2)
Vishal noted that package: Custom is invalid.
Evidence of Fix: We removed "Custom" and changed it to a standard community category: package: PDF.
2. typdf.module Hook Header (Point 3)
Vishal noted that Drupal does not have "Primary module hooks" and requires a specific @file docblock.
Evidence of Fix: In commit 5dcc2c3 today, I updated the file header. It now correctly reads: /** @file Hook implementations for the typdf module. */
3. Constructor Property Promotion (Point 4)
Vishal noted that Drupal 10+ projects must use PHP 8 constructor property promotion (e.g., in TypstTemplateListBuilder).
Evidence of Fix: We rewrote the constructor to use property promotion. Here is the current code in src/TypstTemplateListBuilder.php:
1 public function __construct(
2 EntityTypeInterface $entity_type,
3 EntityStorageInterface $storage,
4 protected EntityTypeManagerInterface $entityTypeManager,
5 protected EntityTypeBundleInfoInterface $entityTypeBundleInfo
6 ) {
4. Attributes instead of Annotations (Point 5)
Vishal stated that plugins and entities (Action, QueueWorker, Views Displays) must use PHP 8 Attributes.
Evidence of Fix: We migrated all of these. For example, src/Plugin/Action/GenerateTypstPdfAction.php now uses:
1 #[Action(
2 id: "typst_pdf_generate_action",
3 label: new TranslatableMarkup("Generate Typst PDF"),
4 type: ""
5 )]
(Note: We had to revert TypstTemplate back to Annotations because Drupal Core 11's Config Entity discovery still struggles with Attributes in some testing contexts, and we reverted TypdfWebformHandler because the Webform module hasn't migrated to Attributes yet. The Action, QueueWorker, and Views plugins are correctly using Attributes).
5. ConfigFormBase #config_target (Point 6)
Vishal stated that TypdfSettingsForm should use #config_target instead of #default_value and manual saving.
Evidence of Fix: We completely refactored TypdfSettingsForm. Here is a snippet of the current code:
1 $form['execution_method'] = [
2 '#type' => 'radios',
3 '#title' => $this->t('Execution Method'),
4 // ... options ...
5 '#config_target' => 'typdf.settings:execution_method',
6 ];
And the manual $config->save() logic was completely removed from submitForm().
Comment #7
vishal.kadamRemember to change status, when the project is ready to be reviewed. In this queue, projects are only reviewed when the status is Needs review.
Comment #8
mayankguptadotcom commentedComment #9
vishal.kadamIt is better not to create new releases during these applications, since a review could ask for a change that is not backward compatible with the existing releases. Just using a development version avoids those BC issues.
Comment #10
vishal.kadam1. FILE: typdf.module
Since the module is declared compatible with Drupal 10.3, removing the function implementing the hook is not possible. The function still needs to be defined, but it calls the method defined by the service class, as described in Support for object oriented hook implementations using autowired services (Backwards-compatible Hook implementation for Drupal versions from 10.1 to 11.0).
2. Use constructor property promotion in all applicable files
Here is a reference: https://drupalbook.org/drupal/using-php-constructor-property-promotion-d...
Comment #11
mayankguptadotcom commentedhttps://git.drupalcode.org/project/typdf/-/pipelines/832025
Thank you for the excellent advice, Vishal.
I have committed and pushed the requested changes directly to the 1.1.x development branch, and I will refrain from cutting any new release tags during the remainder of the application review to avoid any backward-compatibility (BC) issues.
Updates applied to 1.1.x-dev:
1. Backwards-Compatible Hooks: Added the procedural wrapper functions to typdf.module that delegate execution to the autowired TypdfHooks service..
2. Constructor Property Promotion: Globably refactored all applicable classes across the main module and submodules to use PHP 8 constructor property promotion.
Comment #12
mayankguptadotcom commentedComment #13
vishal.kadamFILE: typdf.module
I don't see the Procedural hooks in module hooks.
https://git.drupalcode.org/project/typdf/-/blob/1.1.x/typdf.module?ref_t...
Comment #14
mayankguptadotcom commentedComment #15
mayankguptadotcom commented@vishal - apologies for the oversight. This has been fixed now.
Comment #16
vishal.kadam1. FILE: typdf.module
Procedural hooks should be marked with the
#[LegacyHook]attribute.2. FILE: src/Hook/TypdfHooks.php
The hook method must have a
#[Hook()]attribute.Comment #17
mayankguptadotcom commented@Vishal - This is done. Thank you!
Comment #18
mayankguptadotcom commentedComment #19
vishal.kadamRest seems fine to me.
Please wait for other reviewers and Project Moderator to take a look and if everything goes fine, you will get the role.
Comment #20
mayankguptadotcom commentedThank you Vishal. Truly appreciate it.