Logo 
Search:

Software Engineering Answers

Ask Question   UnAnswered
Home » Forum » Software Engineering       RSS Feeds
  Question Asked By: John Phlip   on Jul 23 In Software Engineering Category.

  
Question Answered By: Alex Smith   on Jul 23

If you're a .NET programmer,I suggest you use the below code snippet in C# to convert image to PDF..Details regarding the programming guide for image to PDF can be reached by -www.e-iceblue.com/.../...Convert-Image-to-PDF.html


// Create a pdf document with a section and page added.
PdfDocument doc = new PdfDocument();
PdfSection section = doc.Sections.Add();
PdfPageBase page = doc.Pages.Add();
//Load a tiff image from system
PdfImage image = PdfImage.FromFile(@"D:\images\bear.tif");
//Set image display location and size in PDF
float widthFitRate = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width;
float heightFitRate = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height;
float fitRate = Math.Max(widthFitRate, heightFitRate);
float fitWidth = image.PhysicalDimension.Width / fitRate;
float fitHeight = image.PhysicalDimension.Height / fitRate;
page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight);
//save and launch the file
doc.SaveToFile("image to pdf.pdf");
doc.Close();
System.Diagnostics.Process.Start("image to pdf.pdf");

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on How to Convert image to PDF Files? Or get search suggestion and latest updates.


Tagged: