Image Title Size

Is there a way to know how big the image title will be when converting an image to PDF?

I need to make space for it when resizing an image to fit the page size.

BTW…I discovered it is possible to hide the image title by setting it to null. Setting it to “” will not hide it.

Hi Dwight,


Thanks for contacting support.

You can set the width of title as long as you want. However you can get image dimensions using Width / Height property of image class and set the title width accordingly. In case I have not properly understood your requirement, please share some further details, so we may reply accordingly.

I would like to resize an image to fit a page. When I do and the image has a title I’m getting two pages where the title is showing at the top of the second page.



In my calculation for the image resize I would like to factor in the size of the image title so that it doesn’t go to a second page.



// Width

ImageInfo.FixWidth = PageWidth - Margin.Left - Margin.Right



// Height

ImageInfo.FixHeight = PageHeight - Margin.Top - Margin.Bottom - ImageTitleHeight



How do I calculate the ImageTitleHeight?

Hi Dwight,


Thanks for sharing the details.

In order to get the dimensions for Title of Image file, please try using following code snippet. In case you still face any issue, please share your sample Image file and code snippet which you are using, so that we can test the scenario in our environment.

[C#]

Document pdfDocument = new Document();<o:p></o:p>

Aspose.Pdf.Image image = new Aspose.Pdf.Image();

image.Title = new TextFragment("Large Title for Image file ");

Console.WriteLine("Title Height = " +image.Title.Rectangle.Height + ", Title Width = " + image.Title.Rectangle.Width );

image.File = "c:/pdftest/Screen Shot 2013-11-18 at 9.23.20 PM.png";

pdfDocument.Pages.Add();

pdfDocument.Pages[1].Paragraphs.Add(image);

pdfDocument.Save(@“C:\pdftest\ImageFileTEst.pdf”);