Find and Replace Text in Word Document | Avoid Extra Spacing during Converting DOCX to PDF using C# .NET

Hi, I have a problem converting .docx documents to .pdf. going through aspose creates the document with a ghost space at the bottom. any ideas.

private void AsposeDocument(string Ruta, string NombreDocumentoServidor, string NRadicadoSalida)
{
try
{
string Archivo = Path.Combine(Ruta, NombreDocumentoServidor);
License objLicencia = ObtenerLicencia();
Document AsposeDoc = new Document(Archivo);
string FechaActual = DateTime.Today.ToString(“d {0}MMMM {0}yyyy”);
FechaActual = string.Format(FechaActual, “de “);
AsposeDoc.Range.Replace(“CORR_FECHA_RAD”, FechaActual, new FindReplaceOptions(FindReplaceDirection.Forward));
AsposeDoc.Range.Replace(“Radicado: CORR_NUM_RAD”, string.Format(“Radicado: {0}”, NRadicadoSalida), new FindReplaceOptions(FindReplaceDirection.Forward));
AsposeDoc.Range.Replace(“CORR_NUM_RAD”, string.Format(”{0}{1}{0}”,"*",NRadicadoSalida), new FindReplaceOptions(FindReplaceDirection.Forward));
string ArchivoPdf = Path.Combine(Ruta, RenombrarDocumento(NombreDocumentoServidor, “pdf”, false));
AsposeDoc.Save(ArchivoPdf, SaveFormat.Pdf);
}
catch (FaultException ex)
{ throw ex; }
catch (Exception ex)
{ throw new FaultException(new UGPPExcepcion(Assembly.GetCallingAssembly().GetName().Name,
GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, false));
}
}

@Cisa,

Please ZIP and attach the following resources here for testing:

  • Your simplified input Word document you are trying to convert to PDF
  • Aspose.Words for .NET 20.11 generated output PDF file showing the undesired behavior
  • A screenshot highlighting the problematic area(s) in Aspose.Words generated output
  • Please also create a standalone simple Console application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your particular scenario/issue and provide you more information.