We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose Pdf- limiting page height to the image height

Hi Aspose-Team,

i would like to know, if it is possible to limit the pdf-page height to the image height via xslt dynamically. In my code i use fix value for pageHeight, what is not appropiate.
Here is my code snippet:

<xsl:variable name=“PageHeight” select="‘4cm’"/>

<xsl:template name=“Main” match=“node()”>





</xsl:template>

I don’t know, if it is even possible to load image in xslt and find out the image height which is going to be a page height.

Please can you give me a hint, how to solve my problem.

Thank you very much in advance!
Alex

Hi Alex,

Thanks for contacting support.

You cannot dynamically set/update the page height or get image dimensions when using XML/XSLT file. However you can specify Image file path and other information in XML/XSLT and while using the API, you can get individual objects of XML and update/set page/image dimensions. For further information, please visit

Hi Nayyer,

thank you very much for you replay. But it haven’t helped much so far. Image size measuared from c# code differs from the image size in xslt. I can approximately shrink the image width, what is very tricky solution and definetely optimal.
For you to undertand better what i mean imagine this situation. I load image in c# code and get a width of 500. I found out, that if the width of my image bigger than 480, so i have to set a FixWidth in xslt to 362, so i do scale my image and it fill the whole cell space. Probably it is because of resolution set for PDF, isn’t id?

Anyway thank you very much for your hints.

Best regards
Alex

Hi Alex,


Thanks for sharing the feedback.

As per my understanding, you are facing an issue while setting image width in XSLT. If the image width being returned in C# code is 500, then in order to achieve same dimensions using XSLT, you need to set the value of 362 in XSLT. So it appears to be an inconsistency in image dimensions when using two approaches. If so is the case, then please share some sample resource files i.e. Image, XLST, XML so that we can test the scenario at our end.

Or in case I have not properly understood the problem, please share some further details. We are sorry for this inconvenience