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

Unable to resize EmbedPicture width or height #1215

Open
1 task
ericedmund opened this issue Nov 17, 2023 · 1 comment
Open
1 task

Unable to resize EmbedPicture width or height #1215

ericedmund opened this issue Nov 17, 2023 · 1 comment

Comments

@ericedmund
Copy link

ericedmund commented Nov 17, 2023

NPOI Version 2.6.0

File Type

  • DOCX

Upload the Excel File

test.docx

Reproduce Steps

        using (FileStream fs = new FileStream(exisDocPath, FileMode.Open, FileAccess.ReadWrite))
        {
            XWPFDocument doc = new XWPFDocument(fs);

            IList<XWPFParagraph> paragraphs = doc.Paragraphs;	//get all paragraphs

            for (int par = 0; par < paragraphs.Count; par++)
            {
                IList<XWPFRun> runs = a[par].Runs;			//get all paragraphs

                for (int runNum = 0; runNum < runs.Count; runNum++)		//get all runs in each paragraph
                {
                    if (runs[runNum].GetEmbeddedPictures().Count != 0)	//get picture 
                    {
                        List<XWPFPicture> pictures = runs[runNum].GetEmbeddedPictures();

                        pictures[0].GetCTPicture().spPr.xfrm.ext.cx = 360045 * 5;	//resize picture width
                        pictures[0].GetCTPicture().spPr.xfrm.ext.cy = 360045 * 5;	//resize picture height

                        using (FileStream imgWrite = File.OpenWrite(exisDocPath))
                        { doc.Write(imgWrite); }
		}
	     }
	 }
      }

Issue Description

the code above try to resize the Picture in docx file, while it doesn't seem to be effective

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants