Thank you for porting this useful module into D8.

Can we inject the settings programmatically? and override the config values that are reading from UI?

I would love to override the settings because I have a custom PDF sizes that I have to generate under on specific conditions.

Thanks!

Comments

samaphp created an issue. See original summary.

Adon Irani’s picture

Not sure if this is the best way... but this is what i did:

in ConvertToPdfInterface.pdf
- function convert($html);
+ function convert($html,$override_settings);

in ConverttoPdf.php
- public function convert($html) {
- $this->settings = $this->getConfigValues();
+ public function convert($html,$override_settings) {
+ $this->settings = $this->getConfigValues();
+ if( !empty( $override_settings )) {
+ foreach( $override_settings as $key=>$value ) {
+ if( !empty( $this->settings[$key] )) $this->settings[$key] = $value;
+ }
+ }

You can then pass an array of settings to override (using the variables set in AdminSettingsForm.php)

If OK by product maintainer, I'd be happy to submit a patch.

samaphp’s picture

Thank you @Adon Irani,
I ended up using the MPDF library directly.

But I would love if you can create this patch so we can help the maintainer and test it to make it ready to be implemented in the next releases.

Thanks!

gauravjeet’s picture

Status: Active » Needs work

Thank you Adon Irani. Please submit a match.

Adon Irani’s picture

Apologies for the delay. Here is the patch.

To use: simply pass an array to the convert function with the desired settings to override, e.g. convert( $html, $override_settings ) where $override_settings["margin_top"] = "100";

gauravjeet’s picture

Status: Needs work » Fixed

This has been fixed in v2.1 of this module already!

Note:
This module space is deprecated and no more support will be given here. I'm going to close this issue and please do not re-open this here as the code been moved to the original project. Please refer the original project here pdf_using_mpdf version 8.x-2.1 for latest version of this module.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.