PDF To Tiff convertion image size issue

I am using the latest aspose dlls for converting pdf to tiff, but for one of the PDF the created tiff width increased . PDF is of 8.27*11.69 in size but the created tiff looks like in Landscape, its height= 595.2,width =841.92. I tested with another PDF with same page size and for that it is created correctly with height=841.8898 and width =595.2756 . Below is the code and also attaching the PDF, since this is a production file, please use it for internal testing only
using (Document document = new Document(filePath))
{
// Get page collection
PageCollection pageCollection = document.Pages;
for (int i = 0; i < document.Pages.Count; ++i)
{
int pageNumber = i + 1;
// Get particular page
Page pdfPage = pageCollection[pageNumber];

                double height = (pdfPage.MediaBox.Height / 72) * conversionSetting.Resolution;
                double width = (pdfPage.MediaBox.Width / 72) * conversionSetting.Resolution;
                TiffDevice tiffDevice = new TiffDevice((int)width,(int)height,resolution, tiffSettings);
                //TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
                string destinationPath = GetDestinationPath(filePath, destinationDirectory, i);
                try
                {
                    using (FileStream fileStream = new FileStream(destinationPath, FileMode.Create))
                    {
                        ((DocumentDevice)tiffDevice).Process(document, i + 1, i + 1, (Stream)fileStream);
                        stringList.Add(destinationPath);
                    }
                }
                catch (Exception ex)
                {
                    document.FreeMemory();
                    foreach (string path in stringList)
                    {
                        if (File.Exists(path))
                            File.Delete(path);
                    }
                    throw ex;
                }
            }
            document.FreeMemory();
        }

TiffIssue.pdf (161.8 KB)

@sreenath2020

Can you please share the value of resolution and other variables used in your code snippet so that we can try to execute it without any errors? Also, it looks like the PDF has rotation set for its pages so you can calculate the height width as following:

double height = (pdfPage.GetPageRect(true).Height / 72) * conversionSetting.Resolution;
double width = (pdfPage.GetPageRect(true).Width / 72) * conversionSetting.Resolution;

Please let us know in case above code does not help.

Resolution is 300. Also can we use the above code for all pdfs as we have issue only for certain PDFs, 90% is working fine

@sreenath2020

Yes, you can use above code snippet for any PDF. However, you can share with us in case you face any issues.

HI @asad.ali,

its seems okay for the pdf having the issue and will process couple more PDFs

thanks

@sreenath2020

Please take your time to test the case with other PDFs as well and feel free to let us know in case you face any issues.