Hi Adam,
Thanks for supplying your input documents. The issue is occuring because the image is being inserted into the same paragraph as the title. This title is styled with Heading 1 style which has spacing before. This spacing pushes the image down. An easy way to avoid this is to insert a new paragraph and reset any style or line spacing. Please see the fix to the code below.
// Insert a blank paragraph<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
builder.Writeln();
builder.MoveToDocumentStart();
// Reset paragraph format on this paragraph.
builder.CurrentParagraph.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
builder.CurrentParagraph.ParagraphFormat.SpaceBefore = 0;
builder.CurrentParagraph.ParagraphFormat.SpaceAfter = 0;
// Insert image as inline
builder.InsertImage(image, ps.PageWidth, ps.PageHeight);
builder.InsertBreak(BreakType.SectionBreakContinuous);
Also note that you should do something with this part of your code below or else you will insert an unneeded page break. You can either remove these lines or move the builder.InsertBreak(BreakType.SectionBreak) line to here instead. Remember the break type must be a section break in order to separate the different margins.
if (strBookCoverFileName != null)
{
docbuilder.InsertBreak(BreakType.PageBreak);
samplebuilder.InsertBreak(BreakType.PageBreak);
}
Thanks,