Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Markdown screenshot URL + Add headers to client call + Some renaming + Add metadata to files + Units in paper size #41

Merged
merged 8 commits into from
May 30, 2024

Conversation

Neirda24
Copy link
Contributor

@Neirda24 Neirda24 commented May 27, 2024

Resolves #38
Resolves #45

@Neirda24 Neirda24 changed the title [Draft] [FIX] Markdown screenshot URL + [FEATURE] Add headers to client call Fix Markdown screenshot URL + Add headers to client call + Some renaming + Add metadata to files + Units in paper size May 29, 2024
src/Builder/Pdf/AbstractChromiumPdfBuilder.php Outdated Show resolved Hide resolved
$splitAndParseStringWithUnit = static function (mixed $raw, callable $callback): void {
[$value, $unit] = sscanf((string) $raw, '%d%s') ?? throw new \InvalidArgumentException(sprintf('Unexpected value "%s", expected format is "%%d%%s"', $raw));

$callback((float) $value, Unit::tryFrom((string) $unit) ?? Unit::Inches);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could emit a log if the unit is invalid ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Will do in another PR where I will add several logs like this one.

@@ -377,7 +380,7 @@ private function addConfiguration(string $configurationName, mixed $value): void
'width' => $this->width($value),
'height' => $this->height($value),
'clip' => $this->clip($value),
'format' => $this->format($value),
'format' => $this->format(ScreenshotFormat::from($value)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the error handled if the format is not valid ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope it simply fails (in this case it will fail on clear-cache)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Maybe we should throw a InvalidBuilderConfiguration exception instead to make debug easier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. The Configuration class already handles this. I do not see a proper usecase for this exception at the moment.

src/Client/GotenbergClient.php Show resolved Hide resolved
src/Enum/Unit.php Outdated Show resolved Hide resolved
self::assertSame(['marginTop' => '1in'], $multipartFormData[3]);
self::assertSame(['marginBottom' => '1in'], $multipartFormData[4]);
self::assertSame(['marginLeft' => '1in'], $multipartFormData[5]);
self::assertSame(['marginRight' => '1in'], $multipartFormData[6]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since, in is the default one, we should add a test with an other one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. Several tests needs to be written actually

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will create a dedicated PR after #40 is merged to rework some of the tests to better reflect all usecases.

@Neirda24 Neirda24 requested a review from Jean-Beru May 29, 2024 16:13
@Neirda24 Neirda24 merged commit b3e6d6c into main May 30, 2024
@Neirda24 Neirda24 deleted the feature/fixes branch May 30, 2024 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implements set metadata when generating file using Chromium or LibreOffice Allow units in paper sizes
2 participants