hello,
when we create doc file and insert pdf file inside doc and convert into pdf then PDF file is disctorting.
As we are using below code.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
Aspose.Words.Drawing.Shape headerLogo = builder.InsertImage(System.Web.HttpContext.Current.Server.MapPath("logopath"));
string reportFontName = "Arial";
headerLogo.Width = 100;
headerLogo.Height = 50;
headerLogo.WrapType = WrapType.None;
headerLogo.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
headerLogo.RelativeVerticalPosition = RelativeVerticalPosition.Page;
headerLogo.Left = (builder.PageSetup.PageWidth - headerLogo.Width) / 2;
headerLogo.Top = 10;
builder.Writeln();
builder.Writeln();
builder.MoveToDocumentStart();
DateTime currentDateTime = DateTime.Now;
builder.Font.Name = reportFontName;
builder.Font.Size = 10;
builder.Font.Bold = true;
builder.Writeln($"Source Input {currentDateTime.ToString("dd-MM-yy HH:mm:ss")}");
builder.Writeln();
if (model.doctype == "file")
{
string filepath = CommonFunctions.SanitizePath(Server.MapPath("~/TempFiles/"), model.filePath);
string extension = System.IO.Path.GetExtension(filepath).ToLower();
if (!string.IsNullOrEmpty(filepath) && System.IO.File.Exists(filepath))
{
else if (extension == ".pdf")
{
using (MemoryStream mst = new MemoryStream())
{
var pdf = new Aspose.Pdf.Document(filepath);
pdf.Save(mst, Aspose.Pdf.SaveFormat.DocX);
mst.Position = 0;
Document pdfDoc = new Document(mst);
builder.InsertDocument(pdfDoc, ImportFormatMode.KeepSourceFormatting);
}
builder.InsertBreak(BreakType.PageBreak);
}
}
}
builder.Writeln();
builder.Font.Size = 10;
builder.Font.Bold = true;
builder.Writeln($"Here is the tested data of the text: ");
builder.Writeln();
builder.Writeln($"tested pdf data");
builder.Writeln();
builder.Font.Size = 10;
builder.Font.Bold = false;
builder.Writeln("test data");
doc.Save(pdfpath, SaveFormat.Pdf);
please see below screen shot. inserted pdf file is override with header logo. So, please suggest how can fix it.