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

Font-size in em unit does not work #100

Closed
bernhardreiter opened this issue Jul 1, 2019 · 1 comment · Fixed by #112
Closed

Font-size in em unit does not work #100

bernhardreiter opened this issue Jul 1, 2019 · 1 comment · Fixed by #112
Labels
enhancement help wanted Help with creating a proper test-case, looking up the spec, or creating a pull request.

Comments

@bernhardreiter
Copy link
Contributor

When using the unit em to specify a font size, the result is much smaller as expected.
For example font-size="2em"

Expectation: Display similar to the browser.

@bernhardreiter
Copy link
Contributor Author

Example (place file ast test100.html in ./dist after building and copying jspdf.debug.js.)

<svg id="svg" width="100%" height="100%">
  <g class="main" transform="translate(30, 20)">                                
    <g fill="none" font-size="10" text-anchor="start">                          
      <g opacity="1" transform="translate(0,40)">                               
        <text fill="black" x="-25">3.50</text>                                  
      </g>                                                                      
      <g opacity="1" font-size="2em" transform="translate(0,10)">               
        <text fill="black" x="-25">5.00</text>                                  
      </g>                                                                      
    </g>                                                                        
  </g>                                                                          
</svg>                                                                          
<script src="./jspdf.debug.js"></script>                                        
<script src="./svg2pdf.js"></script>                                            
                                                                                
<script type="text/javascript">
    const svgElement = document.getElementsByTagName('svg')[0];
    const width = 200, height = 100;
    const pdf = new jsPDF('l', 'pt', [width, height]);
    svg2pdf(svgElement, pdf, {
        xOffset: 0,
        yOffset: 0,
        scale: 1
    });
    pdf.save('myPDF.pdf');
</script>

Screenshot from Chromium 73.0.3683.75 built on Debian 9.8, running on Debian 9.9
test100-browser

resulting PDF
test100-bad.pdf

Using svg2pdf 9a3ff91 (master)
Date: Fri Jun 28 15:00:39 2019 +0200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Help with creating a proper test-case, looking up the spec, or creating a pull request.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants