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

Images with a default value but no input value render in the Viewer, but not in the generated PDF #412

Open
Marnixvdb opened this issue Jan 24, 2024 · 3 comments
Labels
bug Something isn't working @pdfme/schemas

Comments

@Marnixvdb
Copy link

Describe the bug

When you include an image field in the template, and provide a sample image, the behaviour in the Viewer and the Generator is different. If no input value is defined for the image, the viewer renders the sample image while the generator doesn't render the image.

Looking at how other plugins behave, I expect the behaviour we see in the Generator: don't display the image when no input value is provided.

I love the project by the way, thanks for the great work!

To Reproduce

  • define template with image field. Either use the default sample image, or upload one.
  • use the viewer with the templat and do not provide input data for the field. The sample image is displayed.
  • use the generator with the template and do not provide input data for the field. The sample image is not displayed.

Expected behavior

The expected behavior is 1) consistency between viewer end generator and 2) that sample data is not rendered in either, unless explicitly provided as input.

Your Environment

- pdfme package(@pdfme/generator or @pdfme/ui): 
  - both, including @pdfme/schemas
- pdfme version: 
  - 3.2.1
- Operating system: 
  - MacOs
- Node.js version or Browser name & version: 
  - NodeJS 18.18.2. 
  - Chrome: Version 120.0.6099.234 (Official Build) (arm64)

Your Error Log

no error logs

Additional context

No response

@Marnixvdb
Copy link
Author

What is the desired behaviour from your perspective? I could make the change and submit a PR if you want.

It could either be an easy fix: change the image plugin to stop displaying the sample image in the Viewer.

Or it could be a bit more elaborate, by additionally implementing an option in both the viewer and the generator that determines whether the sample data should be used for fields without input data.

@hand-dot hand-dot added bug Something isn't working @pdfme/schemas labels Jan 25, 2024
@hand-dot
Copy link
Collaborator

Hey @Marnixvdb,

Thank you for the report.
This is a clear bug.

The fix should meet the following conditions:

  • For the same input, the appearance of the viewer, form, and generated PDF must match.
    • The viewer should display nothing if the image value is not set.
    • The form should behave like a placeholder with sample data if the image value is not set.

@hand-dot
Copy link
Collaborator

It's uncertain, but this fix might be related.

#380

FYI @peteward

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working @pdfme/schemas
Projects
None yet
Development

No branches or pull requests

2 participants