parent
dcc524e6c9
commit
776f76e8ab
|
@ -15,6 +15,7 @@ pub fn main() -> Result<(), DocxError> {
|
|||
.floating()
|
||||
.offset_x(300 * 9525)
|
||||
.offset_y(400 * 9525);
|
||||
|
||||
Docx::new()
|
||||
.add_paragraph(Paragraph::new().add_run(Run::new().add_image(pic)))
|
||||
.build()
|
||||
|
|
|
@ -104,16 +104,17 @@ impl BuildXML for Drawing {
|
|||
b = b.align(&x.to_string()).close();
|
||||
}
|
||||
}
|
||||
if let DrawingPosition::Offset(x) = p.position_h {
|
||||
let x = format!("{}", x as u32);
|
||||
b = b.pos_offset(&x).close();
|
||||
}
|
||||
|
||||
b = b.open_position_v(&format!("{}", p.relative_from_v));
|
||||
|
||||
if let DrawingPosition::Offset(y) = p.position_v {
|
||||
let y = format!("{}", y as u32);
|
||||
b = b.pos_offset(&y).close();
|
||||
match p.position_v {
|
||||
DrawingPosition::Offset(y) => {
|
||||
let y = format!("{}", y as u32);
|
||||
b = b.pos_offset(&y).close();
|
||||
}
|
||||
DrawingPosition::Align(a) => {
|
||||
b = b.align(&a.to_string()).close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -316,6 +317,69 @@ mod tests {
|
|||
</pic:pic></a:graphicData>
|
||||
</a:graphic>
|
||||
</wp:anchor>
|
||||
</w:drawing>"#
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_issue686() {
|
||||
use std::io::Read;
|
||||
|
||||
let mut img = std::fs::File::open("../images/cat_min.jpg").unwrap();
|
||||
let mut buf = Vec::new();
|
||||
let _ = img.read_to_end(&mut buf).unwrap();
|
||||
let pic = Pic::new(&buf)
|
||||
.size(320 * 9525, 240 * 9525)
|
||||
.floating()
|
||||
.offset_x(300 * 9525)
|
||||
.offset_y(400 * 9525);
|
||||
|
||||
let d = Drawing::new().pic(pic).build();
|
||||
assert_eq!(
|
||||
str::from_utf8(&d).unwrap(),
|
||||
r#"<w:drawing>
|
||||
<wp:anchor distT="0" distB="0" distL="0" distR="0" simplePos="0" allowOverlap="0" behindDoc="0" locked="0" layoutInCell="0" relativeHeight="190500">
|
||||
<wp:simplePos x="0" y="0" />
|
||||
<wp:positionH relativeFrom="margin">
|
||||
<wp:posOffset>2857500</wp:posOffset>
|
||||
</wp:positionH>
|
||||
<wp:positionV relativeFrom="margin">
|
||||
<wp:posOffset>3810000</wp:posOffset>
|
||||
</wp:positionV>
|
||||
<wp:extent cx="3048000" cy="2286000" />
|
||||
<wp:effectExtent b="0" l="0" r="0" t="0" />
|
||||
<wp:wrapSquare wrapText="bothSides" />
|
||||
<wp:docPr id="1" name="Figure" />
|
||||
<wp:cNvGraphicFramePr>
|
||||
<a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noChangeAspect="1" />
|
||||
</wp:cNvGraphicFramePr>
|
||||
<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
|
||||
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture"><pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
|
||||
<pic:nvPicPr>
|
||||
<pic:cNvPr id="0" name="" />
|
||||
<pic:cNvPicPr>
|
||||
<a:picLocks noChangeAspect="1" noChangeArrowheads="1" />
|
||||
</pic:cNvPicPr>
|
||||
</pic:nvPicPr>
|
||||
<pic:blipFill>
|
||||
<a:blip r:embed="rIdImage123" />
|
||||
<a:srcRect />
|
||||
<a:stretch>
|
||||
<a:fillRect />
|
||||
</a:stretch>
|
||||
</pic:blipFill>
|
||||
<pic:spPr bwMode="auto">
|
||||
<a:xfrm rot="0">
|
||||
<a:off x="0" y="0" />
|
||||
<a:ext cx="3048000" cy="2286000" />
|
||||
</a:xfrm>
|
||||
<a:prstGeom prst="rect">
|
||||
<a:avLst />
|
||||
</a:prstGeom>
|
||||
</pic:spPr>
|
||||
</pic:pic></a:graphicData>
|
||||
</a:graphic>
|
||||
</wp:anchor>
|
||||
</w:drawing>"#
|
||||
);
|
||||
}
|
||||
|
|
|
@ -24,5 +24,31 @@
|
|||
},
|
||||
"resolutions": {
|
||||
"**/serialize-javascript": "6.0.1"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/file-saver": "2.0.5",
|
||||
"@wasm-tool/wasm-pack-plugin": "1.6.0",
|
||||
"adm-zip": "0.5.10",
|
||||
"cpy-cli": "4.2.0",
|
||||
"file-saver": "2.0.5",
|
||||
"html-webpack-plugin": "5.5.3",
|
||||
"jest": "28.1.3",
|
||||
"npm-run-all": "4.1.5",
|
||||
"text-encoding": "0.7.0",
|
||||
"ts-loader": "9.4.2",
|
||||
"typescript": "4.9.3",
|
||||
"webpack": "4.46.0",
|
||||
"webpack-cli": "5.0.1",
|
||||
"webpack-dev-server": "3.11.3",
|
||||
"webpack-merge": "5.8.0"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"dist/web/pkg",
|
||||
"dist/node/pkg",
|
||||
"js/*"
|
||||
],
|
||||
"module": "dist/web/index.js",
|
||||
"types": "dist/web/index.d.ts",
|
||||
"dependencies": {}
|
||||
}
|
|
@ -10,7 +10,7 @@
|
|||
"noEmitOnError": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es6",
|
||||
"sourceMap": true,
|
||||
"lib": ["ES2017", "DOM"],
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist/web",
|
||||
"declaration": true
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"noEmitOnError": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es6",
|
||||
"lib": ["ES2017", "DOM"],
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist/node",
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
"noEmitOnError": true,
|
||||
"strictNullChecks": true,
|
||||
"target": "es6",
|
||||
"lib": ["ES2017", "DOM"],
|
||||
"sourceMap": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist/web",
|
||||
|
|
3235
docx-wasm/yarn.lock
3235
docx-wasm/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue