FormEditor size issue

Hi, I have a very strange issue with Aspose.PDF .Net Framework library.
I am using Document and FormEditor classes to add images, form fields and checkboxes to an existing pdf file. When testing on my local PC everything seems good. But when I deploy to Azure App Service the output file becomes huge. Testing with the same input file locally the output is around 500KB, while in Azure generated PDF is 8MB!
What could be reason?

@rinshwind

Can you please try optimizing the PDF file size before or after saving it to reduce the size. If issue still happens, please share sample source and both output PDFs (from local and server environments) with us along with the sample code snippet. We will test the scenario in our environment and address it accordingly.

Hi Ali,
Infact I tried pdfDocument.OptimizeResources(), but the effect was neglectable.
I am attaching the exact code I am debuggin locally and running in Azure. I am attaching the output PDFs as well.
The size issue comes after the use of FormEditor.
tt_azure.pdf (7.8 MB)
tt.pdf (609.4 KB)
code.zip (1.7 KB)

@rinshwind

We are checking it and will get back to you shortly.

@rinshwind

It looks like the copies of the PDF have been generated using evaluation versions of the API. Can you please try using a 30-days free temporary license and share the outputs with us? We will further proceed to assist you accordingly.

Hi Ali,
Now I am using a temp license but I am still not happy with the file size. I am attaching a very simple PDF created from a Word file and then after adding a few fields, the PDF grows to 773KB. Currently I added all optimizations as follows:

var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
optimizationOptions.RemoveUnusedObjects = true;
optimizationOptions.RemoveUnusedStreams = true;
optimizationOptions.AllowReusePageContent = true;
optimizationOptions.LinkDuplcateStreams = true;
optimizationOptions.UnembedFonts = true;
optimizationOptions.ImageCompressionOptions.CompressImages = true;
optimizationOptions.ImageCompressionOptions.ImageQuality = 50;
optimizationOptions.ImageCompressionOptions.ResizeImages = true;
optimizationOptions.RemovePrivateInfo = true;
editor.Document.OptimizeResources(optimizationOptions);
editor.Document.Optimize();
editor.Document.Save(@“C:\temp\416_FF1.pdf”);

416_FF1.pdf (773.7 KB)
416.pdf (254.3 KB)

@rinshwind

Is it the complete code snippet that you have used to optimize the PDF? We used below code snippet and optimized PDF looks different in our environment:

Document document = new Document(dataDir + "416.pdf");
Facades.FormEditor editor = new Facades.FormEditor(document);
var optimizationOptions = new Aspose.Pdf.Optimization.OptimizationOptions();
optimizationOptions.RemoveUnusedObjects = true;
optimizationOptions.RemoveUnusedStreams = true;
optimizationOptions.AllowReusePageContent = true;
optimizationOptions.LinkDuplcateStreams = true;
optimizationOptions.UnembedFonts = true;
optimizationOptions.ImageCompressionOptions.CompressImages = true;
optimizationOptions.ImageCompressionOptions.ImageQuality = 50;
optimizationOptions.ImageCompressionOptions.ResizeImages = true;
optimizationOptions.RemovePrivateInfo = true;
editor.Document.OptimizeResources(optimizationOptions);
editor.Document.Optimize();
editor.Document.Save(dataDir + "optimized" + DateTime.Now.Millisecond + ".pdf");

optimized795.pdf (4.5 KB)

Hi,
Can you try the other file, the one with the Form Fields?

Hi Ali,
I found the issue. I am using custom font Garamond for the form fields. When I changed to Arial even the version with the fields became 18KB after optimizaiton.

Thank you! For now I will be using standard True Type Fonts only.

@rinshwind

It is nice to hear that you were able to resolve your issue. Please feel free to create a new topic in case you need further assistance.