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

border:dashed renders as solid #210

Closed
TryAgainLater opened this issue May 15, 2013 · 20 comments · Fixed by #2531
Closed

border:dashed renders as solid #210

TryAgainLater opened this issue May 15, 2013 · 20 comments · Fixed by #2531
Labels

Comments

@TryAgainLater
Copy link

I'm using version 0.4 and all dashed borders are rendered as solid.

Tried your border test case (https://github.com/niklasvh/html2canvas/blob/master/tests/cases/border/dashed.html) and got the same result.

Tested in latest versions of FF/Chrome/Opera/IE.

@TryAgainLater
Copy link
Author

I have written email to you about this issue. Please answer as soon as possible.

@brcontainer
Copy link
Contributor

I reviewed and it really seems that there is nothing in the source code of the html2canvas about borderStyle (I could be wrong)

@navotgil
Copy link

Awesome lib!
Got the same problem as well.
Not sure if it's a feature or a bug
Thanks

@marquezmanu
Copy link

I have the same problem...

Anyone have a solution??

@Zaccheo
Copy link

Zaccheo commented Jun 12, 2015

I Got the same problem.
<div class="pd10" style="border:4px dashed #B9BFD1;">
dashed convert to solid style. Please.

@lgellert
Copy link

Same problem here.

@brcontainer
Copy link
Contributor

Maybe this link helps to create a pullrequest http://www.rgraph.net/blog/2013/january/html5-canvas-dashed-lines.html

@Rodris
Copy link

Rodris commented Jun 14, 2017

Solved by drawing the borders myself, over the canvas returned by html2canvas.

Here are the steps:

  1. Collect all border data in the HTML;
  2. Remove the borders from the HTML, so the html2canvas wont draw them;
  3. Call the html2canvas;
  4. In the onrendered callback, draw the borders and restore the borders in the HTML.

Here is a fiddle.

@eKoopmans
Copy link
Contributor

eKoopmans commented Jun 14, 2017

Nice @Rodris! Looks like a good solution as long as the borders are straight/rectangular.

I dug into the source code and worked out a way to fix things internally, see #1146. This works with non-rectangular borders as well (border-radius)! I haven't done too much testing but hopefully it solves the issue. You can grab a version of html2canvas with that merged in here.

@agrawroh
Copy link

@eKoopmans Thanks for the fix! It works great for the dashed borders but now my images seems a bit chopped from the bottom. Is there a way to fix this?

@eKoopmans
Copy link
Contributor

Can you give me an example?

@sadanandkenganal
Copy link

sadanandkenganal commented Jul 25, 2018

Hi @eKoopmans ,

Still border-radius is not working with latest release of html2canavs. I am using html2canvs in react app. Is there support for border-radious latest version ? Can you please suggest fix for this ?

@animesh84
Copy link

same problem here "boder: 2px dashed #9b9b9b" converted into solid. did any one got answer?

@eKoopmans
Copy link
Contributor

Hi, sorry the changes I spoke of in 2017 weren't merged. It would take someone reworking #1146 to work with the latest version of html2canvas.

@jasperplender
Copy link

Hi guys,

This is a dirty fix but I used this and it worked for me:

.whateveryouwant:before {
content: "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _";
letter-spacing: 4px;
}

@animesh84
Copy link

animesh84 commented Mar 27, 2019 via email

@bUbUsHeD
Copy link

bUbUsHeD commented Oct 22, 2020

I have experienced a more severe version of this problem with none of the above solutions working.

In the end I solved the issue by simply making a div full of dashes and cycling through a lot of fonts until I found a font for which the dashes would be rendered.

@johnray016
Copy link

I encountered the same problem.

it took me a while to solve it, instead of using dashed border, I remove the border of the div. Then I add polyline SVG and act as a border. Then it fix my problem

@nguyenminhtien1411
Copy link

I encountered the same problem.

it took me a while to solve it, instead of using dashed border, I remove the border of the div. Then I add polyline SVG and act as a border. Then it fix my problem

@johnray016 Nice it works. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

16 participants