Hi we are using Aspose.Pdf for creating a pdf. The input image resolution is 300 DPI. But after creating the PDF, the DPI becomes 96. Is there any way to set the DPI as 300.
We did not find any property for setting resolution in Aspose.Pdf.Generator.Pdf , Aspose.Pdf.Generator.Section , Aspose.Pdf.Generator.Image
Below is the code snippet we are using:
string tempLocalPDFPath = System.IO.Path.GetTempFileName();
tempLocalPDFPath = tempLocalPDFPath.Replace(".tmp", ".pdf");
MemoryStream mystream = null;
try
{
Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();
foreach (byte[] image in ImageArray)
{
try
{
Aspose.Pdf.Generator.Section sect1 = new
Aspose.Pdf.Generator.Section(pdf1);
mystream = new MemoryStream(image);
Bitmap bitmap = new Bitmap(mystream);
sect1.PageInfo.Margin.Top = 5;
sect1.PageInfo.Margin.Bottom = 5;
sect1.PageInfo.Margin.Left = 5;
sect1.PageInfo.Margin.Right = 5;
sect1.PageInfo.PageWidth = (bitmap.Width / bitmap.HorizontalResolution) * 72;
sect1.PageInfo.PageHeight = (bitmap.Height / bitmap.VerticalResolution) * 72;
pdf1.Sections.Add(sect1);
Aspose.Pdf.Generator.Image image2 = new
Aspose.Pdf.Generator.Image(sect1);
image2.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Tiff;
sect1.Paragraphs.Add(image2);
image2.ImageInfo.ImageStream = mystream;
image2.ImageScale = 0.95F;
}
catch (Exception e) {
throw e;
}
}
pdf1.Save(tempLocalPDFPath);