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

Print weird behavior on different domain #438

Open
Nebulis opened this issue Oct 29, 2019 · 7 comments
Open

Print weird behavior on different domain #438

Nebulis opened this issue Oct 29, 2019 · 7 comments

Comments

@Nebulis
Copy link
Contributor

Nebulis commented Oct 29, 2019

Description

I noticed the behavior of printing is dependent on where the renderer is hosted. For instance on dev.opencerts.io, printing the default cert results in:
image

However from https://opencerts-development.netlify.com/ the result is different:
image

=> Background disappears for no reason

Things get worse if you check/uncheck Header and Footers or Background graphics:
image

My guess is that it depends whether the renderer is deployed under the same domain. For instance the same thing happens for tradetrust demo certificate (the demo renderer is hosted on a different domain)

Proposed solution

I suggest that we delegate printing to the renderer:

  1. application post a message to print
  2. renderer prints (just run window.print)

A renderer printing itself is available there => OpenCerts/acra-decentralized-renderer#1

After some tests it looks that the printed document is clean and as displayed on the application.

Pros

  • delegate printing (and styling) to renderer
  • document printed is cleaner

Cons

  • cannot automatically add the overlay (I actually don't think it's bad but at least it won't be automatic anymore)
  • every renderer needs to implement the action (if people use the component we created then no issue)
  • we probably need to display a message if the renderer doesn't support the action

Alternate solution

Create a proxy frame. I found this while looking for solution, but there is no certainty that it will solve our styling issues and it will makes the communication with renderer more complex.

@yehjxraymond
Copy link
Contributor

Actually think that delegating overlay to the renderer is a good idea also, can be the issuer's job to determine what kind of overlay message (if any) to go on top:

  • If they don't care/don't need one, it's not so much of our business to force on on top
  • If they wanted one, and maybe even customise it, they can

On top of that, it makes the decentralised renderer even more "decentralised" it doesn't have to be called through specific sites, ie opencerts.io, to display "correctly". When 3rd party app implementing the iframe prints, they also get the nice overlay by the issuer.

@rjchow
Copy link
Contributor

rjchow commented Oct 30, 2019

Shitty issue, am a bit worried about two things:

  1. what about existing template renderers that we have no way of knowing whether they exist or communicate with them this change?
  2. not sure about leaving it to them because it is actually our business to educate both issuers and recipients that a paper copy is not trustworthy

But then again I don't know how we can solve this alternatively

@Nebulis
Copy link
Contributor Author

Nebulis commented Oct 30, 2019

On opencerts I think it wouldn't be a problem to detect if the renderer is able to handle such an action (basically just check if the print method is exposed when connecting the iframe). In that case we can default to either the current behavior, either displaying an alert saying printing is not available

However using the new version of the renderer, it wouldnt be possible to detect this (everything going through the same function)

@rjchow
Copy link
Contributor

rjchow commented Oct 30, 2019

However using the new version of the renderer, it wouldnt be possible to detect this (everything going through the same function)

Should we have a iframe api version response?

@Nebulis
Copy link
Contributor Author

Nebulis commented Oct 30, 2019

It's doable, can also share the list of supported actions

@rjchow
Copy link
Contributor

rjchow commented Oct 30, 2019

Ok that solves 1), do you have an opinion on 2)? If not it's just me and @yehjxraymond and we have opposite views on this.

@Nebulis
Copy link
Contributor Author

Nebulis commented Oct 30, 2019

I have no solution on this unfortunately (we discussed about it yesterday)

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

No branches or pull requests

3 participants