DocX
DocX copied to clipboard
Align Picture in paragraph to the right.
I cannot align picture to the right. The below is the code that take from example project in this DocX project. ` // Get the upper right Paragraph in the layout_table. //Paragraph upper_right_paragraph = layout_table.Rows[0].Cells[1].Paragraph; Paragraph upper_right_paragraph = layout_table.Rows[0].Cells[1].InsertParagraph();
// Add a template logo image to this document.
Novacode.Image logo = document.AddImage(assembly.GetManifestResourceStream("Novacode.Resources.logo_template.png"));
// Insert this template logo into the upper right Paragraph.
//Picture picture_logo = upper_right_paragraph.InsertPicture(logo.Id, "", "");
Picture picture_logo = logo.CreatePicture();
upper_right_paragraph.InsertPicture(picture_logo);
upper_right_paragraph.Alignment = Alignment.right;
`
Hi, @pagnax ,
Did you found the solution for this?
Thank you, Andrei
Hi,
Just to make sure, you want to insert an image in a cell of a table and align it to the right of that cell ? Will there be any text in the paragraph containing the image ?
Thank you.
Bump???
This is still broken.
var h = document.Headers.Odd.InsertParagraph();
h.Alignment = Alignment.right;
h.InsertPicture(img.CreatePicture(30, 30));
Above code does not produce header paragraph with picture aligned to right!
Hi,
this issue is now fixed. The fix will be in the next release. In the meantime, if you have access to code, you can go in file : Xceed.Document.NET/Src/Paragraph.cs, In method : InsertPicture( Picture p, int index = 0 ) and replace
Xml.AddFirst( p.Xml );
// Extract the picture back out of the DOM. p_xml = ( XElement )Xml.FirstNode;
with:
var pPr = this.Xml.Element( XName.Get( "pPr", Document.w.NamespaceName ) ); if( pPr != null ) { pPr.AddAfterSelf( p.Xml ); p_xml = (XElement)pPr.NextNode; } else { this.Xml.AddFirst( p.Xml ); p_xml = (XElement)this.Xml.FirstNode; }
Thank you