Hey,
Hi,
Ok perfect thank you.
Hi Luc,
Hi Luc,
Thank you for being patient. We manage to download your source documents.
Your code execution flow converts a PDF to DOCX, and then pass its byte array to the Aspose.Pdf.Document class, since it shows an invalid PDF file format error with additional information as: “Startxref not found”.
We have tested your source documents against the Aspose.Words (version: 17.2.0) and Aspose.PDF (version: 17.2.0) APIs and also simplified your code as below. We’re unable to notice misplaced numbers as shown in your screenshots. We have attached output Word document to this reply for your kind reference.
[.NET, C#]
// Aspose Word Document we are going to use as assembled, file output
Aspose.Words.Document doc = new Aspose.Words.Document(@"C:\AD\test901\Documents\Model_FO.dotx");
// DocumentBuilder used to insert the fields (paragraph, section, …) in the merge doc
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
Aspose.Words.Document word = new Aspose.Words.Document(@"C:\AD\test901\Documents\01_communiqué de presse.docx");
//Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(@"C:\AD\test901\Documents\01_Bureau_vote_Neuchatel_FO22.pdf");
Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(@"C:\AD\test901\FO04_06_ACE_DEF_Annexe_Grille_Horaire_SEO_2017.pdf");
Aspose.Pdf.DocSaveOptions saveOptions = new Aspose.Pdf.DocSaveOptions { Format = Aspose.Pdf.DocSaveOptions.DocFormat.DocX };
MemoryStream ms = new MemoryStream();
pdf.Save(ms, saveOptions);
Aspose.Words.Document pdfDocx = new Aspose.Words.Document(ms);
builder.ParagraphFormat.StyleIdentifier = Aspose.Words.StyleIdentifier.Heading1;
builder.Writeln("Titre 1");
InsertNoticeTitle(ref builder, "Titre de mon annonce");
builder.ParagraphFormat.StyleIdentifier = Aspose.Words.StyleIdentifier.Normal;
builder.InsertDocument(word, ImportFormatMode.KeepSourceFormatting);
if (pdfDocx != null)
{
builder.Document.AppendDocument(pdfDocx, Aspose.Words.ImportFormatMode.KeepSourceFormatting);
}
InsertNoticeReference(ref builder);
InsertLine(ref builder, doc.Document);
doc.Save(@"C:\AD\test901\Final.docx", Aspose.Words.SaveFormat.Docx);