Hi,
I have using ASPOSE.Net Words to convert my word file into PDF. After converting the images are blur.
In the attached files “Generate_Using_ASPOSE.pdf” generate using ASPOSE and “SaveAs_PDF_Using_WORD.pdf” save as PDF using WORD.
Please suggest the fix for this.SaveAs_PDF_Using_WORD-Copy.pdf (31.7 KB)
Generate_Using_ASPOSE-Copy.pdf (106.2 KB)
@wefivesoft Could you please attach your input document here for testing? We will check the issue and provide you more information.
Hi alexey.noskov,
Thanks for your quick reply.
I’m attaching the document file. But I just want inform you I’m generating the PDF file using a dynamic word document having some merge fields and replace the image dynamically also.Bonafide Certificate Template (1)-Copy.docx (34.0 KB)
@wefivesoft Thank you for additional information. You can set the following option to improve quality of the image:
Document doc = new Document(@"C:\Temp\in.docx");
PdfSaveOptions opt = new PdfSaveOptions();
opt.JpegQuality = 100;
opt.UseAntiAliasing = true;
opt.DownsampleOptions.DownsampleImages = false;
doc.Save(@"C:\Temp\out.pdf", opt);
But still the quality of the image in the source document is poor and the result cannot be better than the source image quality.
I have tried with your suggestion but no luck. It’s showing still blur image. File attached.
The code I have used as per your suggestion:
public MemoryStream ConvertWordToPDF(MemoryStream stream)
{
MemoryStream pdfStream = new MemoryStream();
// Create a new memory stream.
MemoryStream outStream = new MemoryStream();
try
{
licenseAW.SetLicense(@"Aspose.Words.NET.lic");
AW.Document doc = new AW.Document(stream);
AW.Saving.PdfSaveOptions opt = new();
opt.SaveFormat = Aspose.Words.SaveFormat.Pdf;
opt.JpegQuality = 100;
opt.UseAntiAliasing = true;
opt.DownsampleOptions.DownsampleImages = false;
// Save the document to stream.
doc.Save(outStream, opt);
// Convert the document to byte form.
byte[] docBytes = outStream.ToArray();
// The bytes are now ready to be stored/transmitted.
// Now reverse the steps to load the bytes back into a document object.
pdfStream = new MemoryStream(docBytes);
//To see the pdf output
string base64String = Convert.ToBase64String(docBytes, 0, docBytes.Length);
}
catch (Exception ex)
{
_logger.LogError(ex, "ConvertWordToPDF");
}
finally
{
stream.Close();
outStream.Close();
}
return pdfStream;
}
@wefivesoft As I can see the document you have attached was produced or postprocessed by MS Office 365. If I convert your document to PDF using the code I have provided the image looks better. Please see the attached document: out.pdf (64.6 KB)