Hi,
i am using aspose.pdf.generator to convert an image file to pdf format. original bmp file is too large. after converting to pdf it scales image. but if i want to zoom in its quality and resolution is decreases.
that is the code i use in my project :
Aspose.Pdf.Generator.Pdf exportPdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section sectionPdf = exportPdf.Sections.Add();
Aspose.Pdf.Generator.Image modelImage = new Aspose.Pdf.Generator.Image(sectionPdf);
sectionPdf.Paragraphs.Add(modelImage);
modelImage.ImageInfo.SystemImage = this.modelMap.Model.GetModelPicture();
modelImage.ImageInfo.ImageFileType = Aspose.Pdf.Generator.ImageFileType.Bmp;
modelImage.ImageScale = 1;
exportPdf.IsLandscape = true;
exportPdf.Save(“d:\ConvertToPDF.pdf”);
Thanks,
Hi Ahmet,
Thanks for your inquiry. Please check following code snippet to scale image to page size. Hopefully it will serve the purpose.
// create a PDF object
Pdf pdf = new Pdf();
// create a section and add it to pdf document
Aspose.Pdf.Generator.Section MainSection = pdf.Sections.Add();
// create an image object
Aspose.Pdf.Generator.Image sample_image = new Aspose.Pdf.Generator.Image();
// specify the image file path information
string filename = myDir + “Test.bmp”;
sample_image.ImageInfo.File = filename;
sample_image.ImageInfo.IsAllFramesInNewPage = true;
// specify the image file type
sample_image.ImageInfo.ImageFileType = ImageFileType.Bmp;
// specify the image width information equal to page width
sample_image.ImageInfo.FixWidth = MainSection.PageInfo.PageWidth - MainSection.PageInfo.Margin.Left - MainSection.PageInfo.Margin.Right;
// specify the image Height information equal to page Height
sample_image.ImageInfo.FixWidth = MainSection.PageInfo.PageHeight - MainSection.PageInfo.Margin.Top - MainSection.PageInfo.Margin.Bottom;
// add image to paragraphs collection of section
MainSection.Paragraphs.Add(sample_image);
// save the resultant PDF
pdf.Save(myDir+“Image-to-PDF-Conversion.pdf”);
Please feel free to contact us for any further assistance.
Best Regards,