Merge different file formats into single PDF using Aspose.PDF for .NET

I’m wonderring if aspose can support merge the following file format into one pdf instead of convert to pdf first and then merge to one pdf.



.xls merge to PDF directly
.xlsx merge to PDF directly
.jpg merge to PDF directly
.msg merge to PDF directly
.jpeg merge to PDF directly
.bmp merge to PDF directly
.png merge to PDF directly
.csv merge to PDF directly
.docx merge to PDF directly
.doc merge to PDF directly
.xlsm merge to PDF directly
.pdfx merge to PDF directly
.pdf merge to PDF directly

all above file format should merge to one pdf directly, does it support?

Hi,


Thanks for contacting support.

Please note that we have separate API for specific file format so in order to generate the PDF file form above stated file formats, you need to individually convert each file to PDF format using specific API and then use Aspose.Pdf for .NET to Concatenate PDF Files.

However you can directly import raster images (.JPEG, .PNG, .BMP and .JPG) into PDF file and then use the same Document object for further concatenation. For more information, please visit Add Image to Existing PDF File

Another approach can be to combine related files into single resultant document and then perform the conversion to PDF format but still you need to have an output in PDF format, so that it can be read and further manipulated by Aspose.Pdf for .NET.

Should you have any further query, please feel free to contact.

Thanks for the quick answer, I also want to know that if aspose can control or set the output PDF file size to make sure its size less than a certain value, e.g. 2M

Hi,


Thanks for sharing the details.

I am afraid currently our API’s do not restrict the size of files being generated i.e.we cannot restrict the API to generate output of specific size as it depends upon the document structure, data and objects used in the document. However, when using Aspose.Cells to generate the output in PDF format, you may try using following code lines to optimize the size of resultant file.

[C#]
PdfSaveOptions options = new PdfSaveOptions();
options.OptimizationType = PdfOptimizationType.MinimumSize;

Aspose.Pdf for .NET also offers the feature to optimize the size of PDF document. Please follow the instructions specified over Optimize PDF File Size.

Also please note that we cannot restrict the API to generate output of specific size, as the output file is purely depended upon the contents, structure or other binary objects used in the file and suppose, we have large binary objects, charts or images in the input document, it may not be possible to make such file in less than 2MB. In case I have not properly understood your requirement or you have any further query, please feel free to contact.

Thanks codewarior, the pdf optimization code is really helpful. I also want to know if the aspose.image can support the feature that set the image convert rate to optimize the final picture size to convert to pdf. For example, if the image size is 5M, if I can convert or limit its size to 3M after convert to PDF, it seems the same requiremnt as word convert, but it’s for the image and only for png,jpg, jpeg,bmp, is it possible to do that during convert image to pdf or merge multiple image to one pdf?

Hi,


Thanks for sharing the details.

Aspose.Imaging provides the feature to compress image files. Once the image is compressed, you can convert it to PDF format using Aspose.Pdf for .NET.

Aspose.Imaging APIs can be used to set the Compression Levels for the PNG file format using the PngOptions class that has an int type CompressionLevel property. This property accepts a value from 0 to 9 where 9 is the maximum compression.

[C#]
//Load an image from file (or stream)
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(input))
{
//Loop over possible CompressionLevel range
for (int i = 0; i <= 9; i++)
{
//Create an instance of PngOptions for each resultant PNG
PngOptions options = new PngOptions();
//Set CompressionLevel
options.CompressionLevel = i;
//Save result on disk (or stream)
image.Save(i + “.png”, options);
}
}

Thanks codewarior, we have png,jpg,jpeg,bmp, aspose.imaging supports all of those formats?


For the compressionlevel,if it can ensure lossless image compression to make sure the image no quality changes or loss.

I note that image.replace method has a quality parameter, what does it mean,the socpe is 0~100? if I set its value as 10, the image quality will become worse?
linzi201719811001:
Thanks codewarior, we have png,jpg,jpeg,bmp, aspose.imaging supports all of those formats?
Hi,

Thanks for contacting support.

Aspose.Imaging supports above stated image formats. For further details, please take a look over Imaging.FileFormats.

linzi201719811001:
For the compressionlevel,if it can ensure lossless image compression to make sure the image no quality changes or loss.
Now concerning to this requirement, as per JPEG format standard, when we compress the image, the quality is decreased.

linzi201719811001:
I note that image.replace method has a quality parameter, what does it mean, the scope is 0~100? if I set its value as 10, the image quality will become worse?
Can you please share some details regarding this method, so that we can reply accordingly. If possible, please share the code snippet which you are using.