We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Size of document multiplied after convert jpg to pdf

Hi,


After convertion of a jpg file type to pdf file , size multiplied.

Example: two files as an attachment as follows:

jpg file before convertion with 277 Ko
pdf file after convertion with 1596 Ko

Thank you in advance.


Hi,


I think you have posted your query in the wrong forum. Your query might involve Aspose.Pdf product, so I am moving your thread to Aspose.Pdf forum where one of my fellow colleagues would help you soon.

Have a good day!

Hi Sofiane,


Thanks for your inquriy. I am afraid the source JPG image is not attached properly, Please share it again we will look into the issue and will guide you accordingly.

We are sorry for the inconvenience.

Best Regards,

Hi,


I attached jpg file, but this is just an example because I have the problem for all jpg files.

Regards,

Hi,


I attached jpg file, but this is just an example because I have the problem for all jpg files.

Regards,

Hi Sofiane,


Thanks for sharing your sample image. I have converted image to PDF using new DOM approach and noticed that it creates a PDF of 507 KB. However if you to reduce PDF file size further then you can decrease the image quality using OptimizeResources() method. Please check following code snippet for reference. Hopefully it will help you to accomplish the task.

// Instantiate Document Object<o:p></o:p>

Document doc = new Document();

// Add a page to pages collection of document

Aspose.Pdf.Page page = doc.Pages.Add();

// Create an image object

Aspose.Pdf.Image image1 = new Aspose.Pdf.Image();

// Add the image into paragraphs collection of the section

page.Paragraphs.Add(image1);

// Set the image file stream

image1.File = myDir + "40Nda733a45pvN92.jpg";

doc.ProcessParagraphs();

// Optimzie the file size by removing unused objects

doc.OptimizeResources(new Document.OptimizationOptions()

{

LinkDuplcateStreams = true,

RemoveUnusedObjects = true,

RemoveUnusedStreams = true,

CompressImages = true,

ImageQuality = 80

});

// Save resultant PDF file

doc.Save(myDir+"Image2PDF_DOM.pdf");


Please feel free to contact us for any further assistance.

Best Regards,