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

Symbols #115

Merged
merged 29 commits into from Jul 16, 2020
Merged

Symbols #115

merged 29 commits into from Jul 16, 2020

Conversation

zenker981
Copy link
Contributor

Implement symbols an update -handling; closes #110

src/svg2pdf.js Outdated Show resolved Hide resolved
src/svg2pdf.js Outdated
@@ -279,6 +279,12 @@ SOFTWARE.
_pdf.beginFormObject(bBox[0], bBox[1], bBox[2], bBox[3], tfMatrix);
renderChildren(node, _pdf.unitMatrix, this, false, false, AttributeState.default());
_pdf.endFormObject(node.getAttribute("id"));
} else if (nodeIs(node, "symbol,svg")) {
// create unclipped and untransformed form object
var bBox = getUntransformedBBox(node);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably use a larger bBox here. At least in the svg case, this is the box determined by width/height or the viewBox.

src/svg2pdf.js Outdated Show resolved Hide resolved
src/svg2pdf.js Outdated
@@ -846,7 +871,7 @@ SOFTWARE.
];
}

if (!nodeIs(node, "marker,svg,g")) {
if (!nodeIs(node, "marker,svg,g")) { // TODO: and !symbol ???
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add symbol to the list ;)

src/svg2pdf.js Outdated
@@ -863,6 +888,20 @@ SOFTWARE.
return boundingBox;
};

var getBoundingBoxByChildren = function (node) {
boundingBox = [0, 0, 0, 0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var boundingBox = ...

src/svg2pdf.js Outdated Show resolved Hide resolved
@@ -0,0 +1,16 @@
<svg id="svgElement" width="500" height="500" xmlns="http://www.w3.org/2000/svg">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably add more cases:

  • different transforms (on the symbol, on the use, "around" the use, ...)
  • style inheritance from "around" the use element

@@ -0,0 +1,16 @@
<svg id="svgElement" width="500" height="500" xmlns="http://www.w3.org/2000/svg">
<symbol id="myDot" x="1" height="100" viewBox="0 0 80 100" >
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1px is really hard to see, make it e.g. 10px to really see an effect.

<circle cx="50" cy="50" r="50"/>
</symbol>

<use href="#myDot" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you could align the circles a little better and make them distinguishable, so it's immediately clear which circle is which.

zenker981 and others added 23 commits October 25, 2019 13:37
# Conflicts:
#	src/applyparseattributes.ts
#	src/context/referenceshandler.ts
#	src/nodes/geometrynode.ts
#	src/nodes/image.ts
#	src/nodes/renderednode.ts
#	src/nodes/svgnode.ts
#	src/nodes/text.ts
#	src/nodes/use.ts
#	src/utils/bbox.ts
#	src/utils/node.ts
#	test/common/tests.js
#	test/specs/complete-computer-network/reference.pdf
#	test/specs/image-svg-urls/reference.pdf
#	test/specs/references/reference.pdf
 - don't add line width to bounding boxes,
 - refactor referenced handler (externalize rendering of referenced elements)
 - fix <use> viewBox transformations
 - hotfix pattern x/y offset
@HackbrettXXX HackbrettXXX merged commit a8f1d07 into yWorks:master Jul 16, 2020
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

Successfully merging this pull request may close these issues.

SVG symbols not displaying in PDF
2 participants