Hi Team,
I am trying to convert word to pdf using aspose.
While converting some images are moving to next page in the converted pdf, due to which the doc structure changed.
Can you please help on this?
I am using below code
public bool WordToPdf(Aspose.Words.Document doc, string outPdfPath, out string errorMessage)
{
bool res = false;
errorMessage = string.Empty;
try
{
Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
options.DmlRenderingMode = Aspose.Words.Saving.DmlRenderingMode.Fallback;
options.UpdateFields = true;
options.DmlEffectsRenderingMode = Aspose.Words.Saving.DmlEffectsRenderingMode.Simplified;
// options.Compliance = Aspose.Words.Saving.PdfCompliance.PdfA1b;
options.UseBookFoldPrintingSettings = true;
options.ImageCompression = Aspose.Words.Saving.PdfImageCompression.Auto;
options.ZoomBehavior = Aspose.Words.Saving.PdfZoomBehavior.FitPage;
options.UseHighQualityRendering = true;
options.OptimizeOutput = true;
options.MemoryOptimization = true;
//options.UpdateSdtContent = true;
doc.AcceptAllRevisions();
doc.Revisions.AcceptAll();
RemoveComments(doc);
doc.UpdateFields();
doc.Save(outPdfPath, options);
// doc.Save(outPdfPath + ".docx");
res = true;
}
catch (Exception ex)
{
errorMessage = ex.Message;
try
{
Aspose.Words.Saving.PdfSaveOptions options = new Aspose.Words.Saving.PdfSaveOptions();
options.DmlRenderingMode = Aspose.Words.Saving.DmlRenderingMode.DrawingML;
options.ImageCompression = Aspose.Words.Saving.PdfImageCompression.Auto;
//options.MemoryOptimization = true;
options.TempFolder = Path.Combine(Path.GetTempPath(), "astmp");
try
{
Directory.CreateDirectory(options.TempFolder);
}
catch
{
}
doc.AcceptAllRevisions();
doc.Revisions.AcceptAll();
RemoveComments(doc);
doc.Save(outPdfPath, options);
res = true;
}
catch (Exception e)
{
}
}
return res;
}