Hello team,
The file that Aspose.Pdf generates is more than twice as big as the file that Aspose.Pdf.Generator generates.
This is my code.
private MemoryStream ConvertSingleImageToPdf()
{
var pdfStream = new MemoryStream();
// Instantiate the License class
var license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Total.lic");
var pdf = new Aspose.Pdf.Document();
using (var image = Image.FromStream(this._stream))
{
// PDFファイルにページを追加
var pdfPage = pdf.Pages.Add();
// ページの余白を0に、ページサイズを画像の大きさに設定
pdfPage.PageInfo.Margin.Top = 0;
pdfPage.PageInfo.Margin.Bottom = 0;
pdfPage.PageInfo.Margin.Left = 0;
pdfPage.PageInfo.Margin.Right = 0;
pdfPage.PageInfo.Width = image.Width;
pdfPage.PageInfo.Height = image.Height;
// PDFイメージオブジェクトを作成
var pdfImage = new Aspose.Pdf.Image()
{
FixWidth = image.Width,
FixHeight = image.Height,
ImageStream = this._stream,
};
pdfPage.Paragraphs.Add(pdfImage);
// PDF保存
pdf.Save(pdfStream);
}
return pdfStream;
}
Thank you,
PFU DSOL2