I've been trying to use a master pdf file to create a document adding pages dynamically but when I add pages, there seems to be a margin on top of my document's first page. (see image)
Let me know what I'm doing wrong...
- Code: Select all
public void AppendPage ( int sourcePageIndex ) {
if ( _baseDocument.Pages[ sourcePageIndex ] == null ) {
throw new Exception( "Unable to add page index " + sourcePageIndex );
}
var basePage = _baseDocument.Pages[ sourcePageIndex ];
var currentSize = basePage.Size;
var template = basePage.CreateTemplate();
template.Draw( _document.Pages.Add( currentSize, new PdfMargins( 0 ) ), 0, 0 );
/*
var newPage = _document.Pages.Add( currentSize, new PdfMargins( 0 ) );
newPage.Canvas.DrawTemplate( template, new PointF( 0, 0 ) );
*/
}
Thank you!