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.

Project link

https://www.drupal.org/project/typdf

Comments

mayankguptadotcom created an issue. See original summary.

mayankguptadotcom’s picture

Title: [1.1.x-dev] Typdf » [1.1.x] Typdf
vishal.kadam’s picture

Issue summary: View changes
avpaderno’s picture

Thank 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.

  • If you have not done it yet, you should enable GitLab CI for the project and fix the PHP_CodeSniffer errors/warnings it reports.
  • For the time this application is open, only your commits are allowed.
  • The purpose of this application is giving you a new drupal.org role that allows you to opt projects into security advisory coverage, either projects you already created, or projects you will create. The project status will not be changed by this application; once this application is closed, you will be able to change the project status from Not covered to Opt into security advisory coverage. This is possible only 14 days after the project is created.

    Keep in mind that once the project is opted into security advisory coverage, only Security Team members may change coverage.
  • Only the person who created the application will get the permission to opt projects into security advisory coverage. No other person will get the same permission from the same application; that applies also to co-maintainers/maintainers of the project used for the application.
  • We only accept an application per user. If you change your mind about the project to use for this application, or it is necessary to use a different project for the application, please update the issue summary with the link to the correct project and the issue title with the project name and the branch to review.

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.

  • It is preferable to wait for a project moderator before posting the first comment on newly created applications. Project moderators will do some preliminary checks that are necessary before any change on the project files is suggested.
  • Reviewers should show the output of a CLI tool only once per application.
  • It may be best to have the applicant fix things before further review.

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.

vishal.kadam’s picture

Status: Needs review » Needs work

1. FILE: README.md

The README file is missing the required sections - Requirements, Installation and Configuration.

2. FILE: typdf.info.yml

package: Custom

Custom 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).

/**
 * @file
 * Primary module hooks for Typst PDF Engine module.
 *
 * Most hooks have been migrated to src/Hook/TypdfHooks.php using
 * modern Drupal 11 Object-Oriented #[Hook] attributes.
 */

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

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The entity type bundle info.
   *
   * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface
   */
  protected $entityTypeBundleInfo;

  /**
   * {@inheritdoc}
   */
  public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, EntityTypeManagerInterface $entity_type_manager, EntityTypeBundleInfoInterface $entity_type_bundle_info) {
    parent::__construct($entity_type, $storage);
    $this->entityTypeManager = $entity_type_manager;
    $this->entityTypeBundleInfo = $entity_type_bundle_info;
  }

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.

    $form['image_toolkit'] = [
      '#type' => 'radios',
      '#title' => $this->t('Select an image processing toolkit'),
      '#config_target' => 'system.image:toolkit',
      '#options' => [],
    ];

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.

mayankguptadotcom’s picture

@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().

vishal.kadam’s picture

Remember to change status, when the project is ready to be reviewed. In this queue, projects are only reviewed when the status is Needs review.

mayankguptadotcom’s picture

Status: Needs work » Needs review
vishal.kadam’s picture

It 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.

vishal.kadam’s picture

Status: Needs review » Needs work

1. 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...

mayankguptadotcom’s picture

https://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.

mayankguptadotcom’s picture

Status: Needs work » Needs review
vishal.kadam’s picture

Status: Needs review » Needs work

FILE: 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...

mayankguptadotcom’s picture

Status: Needs work » Needs review
mayankguptadotcom’s picture

@vishal - apologies for the oversight. This has been fixed now.

vishal.kadam’s picture

Status: Needs review » Needs work

1. 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.

mayankguptadotcom’s picture

@Vishal - This is done. Thank you!

mayankguptadotcom’s picture

Status: Needs work » Needs review
vishal.kadam’s picture

Rest 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.

mayankguptadotcom’s picture

Thank you Vishal. Truly appreciate it.