We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Strange error concatenating documents

Hi,

I’m trying to concatenate two documents

The first is a new Document containing a JPG image.
The second one is a ODT document (Only one page).

When I concatenate those two documents, it appears that they are in the same page…
The image is over the ODT document.

When I try with DOC, RTF or DOCX file it works well…

To load the DOC/ODT/RTF/DOCX file, I use :

Document doc = new Document(,, string.Empty);

Why does it work with all load formats expect ODT ?

Thanks for your help.

Q.

Hi

Thanks for your inquiry. Could you please show me your code and attach your input and output documents here for testing? I will investigate the problem on my side and provide you more information.

Best regards,

Stream imageStream = File.Open(@“C:\input_JPG.jpg”, FileMode.Open);

Document doc = new Document();

DocumentBuilder docBuilder = new DocumentBuilder(doc);

docBuilder.PageSetup.PaperSize = PaperSize.A4;

docBuilder.MoveToDocumentStart();

Aspose.Words.Drawing.Shape shape = docBuilder.InsertImage(imageStream);

shape.WrapType = WrapType.None;

shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.HorizontalAlignment = HorizontalAlignment.Center;

shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
shape.VerticalAlignment = VerticalAlignment.Center;

doc.AppendDocument(new Document(@“C:\input_ODT.odt”, LoadFormat.Odt, string.Empty), ImportFormatMode.KeepSourceFormatting);

doc.Save(@“C:\output_jpg_odt.docx”);

Thanks for your help.

Q.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You should just set SectionStart = SectionStart.NewPage for the first section of the ODT document. Please try using the following code:

Stream imageStream = File.Open(@"Test\input_JPG.jpg", FileMode.Open);

Document doc = new Document();

DocumentBuilder docBuilder = new DocumentBuilder(doc);

docBuilder.PageSetup.PaperSize = Aspose.Words.PaperSize.A4;

docBuilder.MoveToDocumentStart();

Shape shape = docBuilder.InsertImage(imageStream);

shape.WrapType = WrapType.None;

shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;

shape.HorizontalAlignment = HorizontalAlignment.Center;

shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;

shape.VerticalAlignment = VerticalAlignment.Center;

Document subDoc = new Document(@"Test\input_ODT.odt", LoadFormat.Odt, string.Empty);

subDoc.FirstSection.PageSetup.SectionStart = SectionStart.NewPage;

doc.AppendDocument(subDoc, ImportFormatMode.KeepSourceFormatting);

doc.Save(@"Test\output_jpg_odt.doc");

Best regards,

It works :slight_smile:

Thanks for your fast help !