Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions src/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,19 @@ export class DrawingPad extends DrawingPadBase {
if (!this.nativeView.isEmpty()) {
const data: string = this.nativeView.getSignatureSvg();

// Append viewbox to the svg for correct scaling
const svgHeaderRegEx = /<svg (.*) height="(\d+)" width="(\d+)"(.*)>/i;
resolve(
data.replace(
svgHeaderRegEx,
`<svg $1 viewBox="0, 0, $3, $2" height="$2" width="$3"$4>`
)
);
// Append viewbox to the svg for correct scaling (IF NEEDED)
if (data.indexOf('viewBox') === -1) {
const svgHeaderRegEx = /<svg (.*) height="(\d+)" width="(\d+)"(.*)>/i;
resolve(
data.replace(
svgHeaderRegEx,
`<svg $1 viewBox="0, 0, $3, $2" height="$2" width="$3"$4>`
)
);
} else {
resolve(data);
}

} else {
reject('DrawingPad is empty.');
}
Expand Down