Appending Documents Loses Quality

Hello,
I’m having trouble when appending a PDF to an Aspose.Words (.NET v23.4.0.0) document and then saving the whole thing as a PDF. The resulting PDF output leaves the appended PDF at a significant loss of PDF quality. It’s very pixelated and fuzzy.

When I use your tool here to attempt the merge, the output is the same as my code (poor), but when I use this tool to do the same thing, it works as expected and produces a nice, high resolution output.

My question is what is the difference between your 2 online tools and what do I need to do differently to preserve the output quality of my PDF?

Here are 2 PDFs you can use to test using your online tools: FloorPlanMerge1.pdf (175.0 KB)
FloorPlanMerge2.pdf (980.3 KB)

Here’s the code I’m using: Program.cs

Thanks!

@kgrems Please note, Aspose.Words is designed to work with MS Word documents. MS Word documents are flow documents and they have structure very similar to Aspose.Words Document Object Model. On the other hand PDF documents are fixed page format documents . While loading PDF document using such code, Aspose.Words converts Fixed Page Document structure into the Flow Document Object Model. Then, in your scenario the flow DOM is converted back to fixed-page - PDF. Unfortunately, such conversion does not guaranty 100% fidelity.
You can use Aspose.PDF to merge PDF documents to get accurate result:
https://docs.aspose.com/pdf/net/merge-pdf-documents/

@alexey.noskov
Thank you for the reply. My question now is how does this code do it? As you can see in the URL, it’s using the Words API and does exactly what I need it to. My question is how can I do the same thing in my code?
Kevin

@kgrems You can try merging PDF documents without loading them into the Aspose.Words DOM. Please see the following code:

Aspose.Words.Pdf2Word.FixedFormats.PdfFixedRenderer pdfFixedRenderer = new Aspose.Words.Pdf2Word.FixedFormats.PdfFixedRenderer();

using (FileStream pdf1 = File.OpenRead(@"C:\Temp\1.pdf"))
using (FileStream pdf2 = File.OpenRead(@"C:\Temp\2.pdf"))
{
    using (Stream resultStream = pdfFixedRenderer.MergePdf(pdf1, pdf2))
    using (FileStream resultFile = File.Create(@"C:\Temp\out.pdf"))
        resultStream.CopyTo(resultFile);
} 

But as I can see In this case format is also damaged.
As I can see the App uses Aspose.PDF for merging PDF documents.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25383

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@alexey.noskov
Using the code you provided does indeed maintain the high resolution of the resulting PDF, so thank you for that. As you mentioned, unfortunately the resulting PDF is definitely full of problems.

For your reference here are some example files:
FloorPlanMerge1.pdf (175.0 KB)
FloorPlanMerge2.pdf (980.3 KB)
output.pdf (953.9 KB)

If the online App I mentioned above actually uses Aspose.PDF for merging those documents online, I would highly recommend changing the URL to reflect this. That online app was partly what we used to determine if Aspose.Words would meet our needs or not.

I can appreciate your offer of paid support services, however if the issues are bugs in your libraries, I don’t feel that this will be necessary.

We will be waiting for your fix to this merging code.

Thanks again.

@kgrems Yes, I get the same output PDF document on my side. We will keep you updated and let you know once the issue is resolved. Also we will update the words apps so that they use only Aspose.Words features.

1 Like

@alexey.noskov I appreciate your reply. Do you have any idea as to when the fix for this issue might be released?

@kgrems The issue is currently in development. If everything goes smoothly the fix will be available in 23.7 version of Aspose.Words. We will keep you informed and let you know once the issue is resolved.

1 Like

@alexey.noskov Thanks

1 Like

The issues you have found earlier (filed as WORDSNET-25383) have been fixed in this Aspose.Words for .NET 23.6 update also available on NuGet.

@alexey.noskov One issue has been fixed. The combined PDF no longer has the strange lines, but the quality of the second PDF in the combined document is significantly degraded.

Original PDF 1 - FloorPlanMerge1.pdf (175.0 KB)
Original PDF 2 - FloorPlanMerge2.pdf (980.3 KB)
Combined PDF - output.pdf (947.2 KB)

@kgrems
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25497

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

By the way in 23.6 version we have introduced LowCode concept in Aspose.Words. You can now use the following code to merge PDF or other documents with only one line of code:

Aspose.Words.LowCode.Merger.Merge(@"C:\Temp\out.pdf", new string[] { @"C:\Temp\FloorPlanMerge1.pdf", @"C:\Temp\FloorPlanMerge2.pdf" });

@alexey.noskov Thank you for opening another ticket on this. I’ll be waiting for the update. I appreciate the prompt response.

Also, cool, I’ll give the low-code solution a try!

1 Like

@alexey.noskov just making sure that progress is continuing on this issue. Thanks!

@kgrems The issue is already resolved in the current codebase. The fix will be included into the next 23.7 version of Aspose.Words. We will be sure to let you know once it is released.

1 Like

@alexey.noskov Wonderful! Thanks!

1 Like

The issues you have found earlier (filed as WORDSNET-25497) have been fixed in this Aspose.Words for .NET 23.7 update also available on NuGet.

1 Like

@alexey.noskov
Looks like that did the trick. Thanks again!

1 Like