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

Picture not shown #373

Closed
majiabin opened this issue Jun 10, 2020 · 4 comments
Closed

Picture not shown #373

majiabin opened this issue Jun 10, 2020 · 4 comments
Labels
bug docx file_error file format generation/writing issue
Milestone

Comments

@majiabin
Copy link

           XWPFDocument doc = new XWPFDocument();    
            XWPFParagraph p1 = doc.CreateParagraph();
            var r0 = p1.CreateRun();
            using (var stream = new FileStream(Server.MapPath("/123.png"), FileMode.Open, FileAccess.Read))
            {
                r0.AddPicture(stream, (int)NPOI.XWPF.UserModel.PictureType.PNG, "23.png", 1000000, 1000000);
                var docPr = (( (NPOI.OpenXmlFormats.Dml.WordProcessing.CT_Drawing) r0.GetCTR().Items[0]).inline[0].docPr);
                docPr.id = 1000;
            }

            using (var stream = new FileStream("E:/Demo/NPOI_Demo/NPOI_Demo/" + DateTime.Now.ToString("yyyyMMddHHmmss") + "docName.doc", FileMode.Create, FileAccess.Write))
            {
                doc.Write(stream);
            }
            return;
@majiabin
Copy link
Author

version:2.5.1

@dmitriymudrak
Copy link

@majiabin please downgrade to 2.4.1
I had the same issue and it helps

@tonyqus tonyqus added this to the NPOI 2.5.2 milestone Jun 25, 2020
@tonyqus tonyqus added the bug label Jun 25, 2020
@tonyqus tonyqus added the file_error file format generation/writing issue label Jul 4, 2020
@tonyqus
Copy link
Member

tonyqus commented Sep 25, 2020

This is a bug introduced by this PR.
tonyqus@82d894f#diff-55809e8faf1695de2858d457985cc83a

@tonyqus
Copy link
Member

tonyqus commented Sep 25, 2020

Also may be caused by this commit
tonyqus@7d3f0ae

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docx file_error file format generation/writing issue
Projects
None yet
Development

No branches or pull requests

3 participants