How can I replace placeholder of a pdf document with another word document?

@panCognity Yes, if you convert your PDF document to flow DOCX documents, you will be able to replace the placeholder. But you should note that conversion of Fixed Page PDF document to Flow DOCX document might affect the original document layout due to the significant differences in these two document object models.

You refer to Mode, right? DocSaveOptions.RecognitionMode.Flow

@panCognity Yes, you are right. Also, you can use Aspose.Words to convert PDF to DOCX. Aspose.Words produces DOCX with flow document layout.

  public static bool ConvertPdfToDocx(Aspose.Pdf.Document pdfDoc, ref bool error)
  {
      try
      {
          using (pdfDoc)
          {
              DocSaveOptions saveOptions = new DocSaveOptions
              {
                  Format = DocSaveOptions.DocFormat.DocX,
                  Mode = Aspose.Pdf.DocSaveOptions.RecognitionMode.EnhancedFlow
              };
              string docxPath = Path.Combine(outputDirectory, $"{Path.GetFileNameWithoutExtension(pdfDoc.FileName)}.docx");
              pdfDoc.Save(docxPath, saveOptions);
 
              return false;
          }
      }
      catch (Exception ex)
      {
          Console.WriteLine($"Converion error in file {pdfDoc}|Reason: {ex.Message}");
          error = true;
          return true;
      }
  }

I have used Aspose.Pdf to convert pdf to word before in this issue. Would it be better to use Aspose.Words to do that?

@panCognity You should test with your document and see which product gives a better result. As I remember, you already tried using Aspose.Words for PDF to DOCX conversion and encountered several issues reported in this thread.

1 Like

I tried and I have the issues reported to the previous thread, as you already mentioned. That is tables are not consistent (cells have been moved) and in some lines of paragraphs words are united.

@panCognity We have logged the problems in our defect tracking system. We will keep you updated and let you know once they are resolved.