Giter Site home page Giter Site logo

Comments (3)

yGuy avatar yGuy commented on July 4, 2024

I guess this is a short-coming in Chrome? Anyhow, if the SVG spec says that there should not be a stroke, even if one is specified with a zero width, then we should not write it to the PDF and then the proposed fix sounds like a simple solution.

Can someone confirm that there should never be a stroke visible with a stroke width of 0 in SVG? Maybe the SVG implementation is wrong, already?

from svg2pdf.js.

HackbrettXXX avatar HackbrettXXX commented on July 4, 2024

The SVG 2.0 spec states:

This property specifies the width of the stroke on the current object. A zero value causes no stroke to be painted.

https://svgwg.org/svg2-draft/painting.html#StrokeWidth

The PDF 1.7 spec states:

A line width of 0 shall denote the thinnest line that can be rendered at device resolution [...]

So, yes we shouldn't draw zero-width strokes. The proposal looks good to me.

from svg2pdf.js.

HackbrettXXX avatar HackbrettXXX commented on July 4, 2024

Actually, I think we should rather change

export function getTextRenderingMode(attributeState: AttributeState): TextRenderingMode {
let renderingMode: TextRenderingMode = 'invisible'
if (attributeState.fill && attributeState.stroke) {
renderingMode = 'fillThenStroke'
} else if (attributeState.fill) {
renderingMode = 'fill'
} else if (attributeState.stroke) {
renderingMode = 'stroke'
}
return renderingMode
}

to make it consistent with

protected async fillOrStroke(context: Context): Promise<void> {
if (context.withinClipPath) {
return
}
const fill = context.attributeState.fill
const stroke = context.attributeState.stroke && context.attributeState.strokeWidth !== 0
const fillData = fill ? await fill.getFillData(this, context) : undefined
const isNodeFillRuleEvenOdd =
getAttribute(this.element, context.styleSheets, 'fill-rule') === 'evenodd'
// This is a workaround for symbols that are used multiple times with different
// fill/stroke attributes. All paths within symbols are both filled and stroked
// and we set the fill/stroke to transparent if the use element has
// fill/stroke="none".
if ((fill && stroke) || context.withinUse) {
if (isNodeFillRuleEvenOdd) {
context.pdf.fillStrokeEvenOdd(fillData)
} else {
context.pdf.fillStroke(fillData)
}
} else if (fill) {
if (isNodeFillRuleEvenOdd) {
context.pdf.fillEvenOdd(fillData)
} else {
context.pdf.fill(fillData)
}
} else if (stroke) {
context.pdf.stroke()
} else {
context.pdf.discardPath()
}
}

from svg2pdf.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.