File Size increaseing

Hi Team,

I am converting a file into PDF from Word using Aspose.Word in .NET but the output file is quite larger than Microsoft Interop. This is happening only when the Word file contains images.

CODE:

program.cs

// --- Configuration ---
builder.Configuration
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    .AddEnvironmentVariables();
Config.Config.Data = builder.Configuration;
// --- Services ---
builder.Services.AddControllersWithViews(); 
builder.Services.AddRazorPages();  

// Swagger Setup (optional)
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// --- Middleware Setup ---
if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage(); 
    app.UseSwagger();
    app.UseSwaggerUI(); 
}

app.UseHttpsRedirection(); 
app.UseStaticFiles(); 
app.UseRouting(); 

app.UseAuthorization(); 

// --- Routing Setup ---
app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}"
);

app.Run();

convert code

private static void ConvertDOCXToPDF(string inputPath, string outputPath)
{
    try
    {
        var doc = new Aspose.Words.Document(inputPath);
        doc.Save(outputPath, SaveFormat.Pdf);
    }
    catch (Exception ex)
    {
        LoggerUtility.Logger.LogException(ex, "Aspose Conversion Error");
        throw;
    }
}

Template Test 0409_MS_Interop.pdf (562.6 KB)

Template Test 0409_Aspose.pdf (1.7 MB)

Template Test 0409.docx (1.8 MB)

@balbeer.y You can decrease the output PDF document size by adjusting image downsampling options. For example:

Document doc = new Document(@"C:\Temp\in.docx");

PdfSaveOptions opt = new PdfSaveOptions();
opt.DownsampleOptions.Resolution = 72;

doc.Save(@"C:\Temp\out.pdf", opt);

Hi Alexey,

Thanks for your reply. I have one more query.

We were conducting final load testing with 1,000 files in batches of 50 to 60 using a temporary license. Initially, the performance was good. However, when we checked all the files, we noticed that some random files had a red cross patch, even though processing those same files individually works perfectly fine.

What could be the cause of this behavior?

@balbeer.y This problem can occur if the input document contains a linked image, meaning the image is not embedded in the document itself. In this case, Aspose.Words attempts to load the image from the specified file path or URL. If the image is unavailable, a red cross is rendered instead.
You can use IResourceLoadingCallback to control how Aspose.Words loads external resource when importing a document.