Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add basic support for adding SVG pictures to docx files#1343

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
takis wants to merge0 commits intopython-openxml:masterfromtakis:master

Conversation

takis
Copy link

See issues#351,#651,#659.

This replaces this pull request from two years ago:
#1107

Naltharial reacted with thumbs up emojiKladdy and sonovice reacted with heart emoji
@takis
Copy link
Author

This is the simple code I've been testing with:

importdatetimefromdocximportDocumentSVG="""<svg version="1.1"     width="300" height="200"     xmlns="http://www.w3.org/2000/svg">  <rect width="100%" height="100%" fill="red" />  <circle cx="150" cy="100" r="80" fill="green" />  <text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text></svg>"""svg_filename="drawing.svg"withopen(svg_filename,"w")asf:f.write(SVG)document=Document()now=datetime.datetime.now()document.add_heading("Document Title",0)document.add_heading(f"{now}",0)document.add_picture(svg_filename)document.save("demo.docx")

@mzaanen
Copy link

Thank you so much for this fix. I just could not get QR codes sharp in a docx document.

First I used .png files using segno and did "add_picture" in python-docx. The .png images are sharp, but the add_picture resizes and blurs it all. Result is a rescaled and blurred image in the .docx.

Now I make .svg files using segno and I use your branch (https://github.com/takis/python-docx.git, master) to do the add_picture and it is now spot on; no blurring, sharp as anything.

You saved my day ! Thanks again.

@michaelarfreedmichaelarfreed mentioned this pull requestApr 24, 2024
@michaelarfreed
Copy link

I'd love to see this PR approved! It is a great fix for a feature that windows supports. I need this feature for code I'm developing, and can't rely on a branch outside of the main branch, so would love to see the PR approved !!

mzaanen reacted with thumbs up emoji

@takis
Copy link
Author

I've just created new pull request replacing this one:
#1386

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@takis@mzaanen@michaelarfreed

[8]ページ先頭

©2009-2025 Movatter.jp