Free Support Forum - aspose.com

Image orientation

Hi Team,

I am converting pdf file to single page tiff images using the below code.
But the image after conversion is showing the Landscape image.
Is there any way keep the original Orientation

 public static Image[] ConvertPDFtoMultiPageTiff(string OutputFolder, string FullInputFileName)
{
Image[] sourceImages = null;
        <span style="color:blue;">try</span>
        {

            <span style="color:#2b91af;">Document</span> pdfDocument = <span style="color:blue;">new</span> <span style="color:#2b91af;">Document</span>(FullInputFileName);
           
            <span style="color:green;">//create Resolution object</span>
            <span style="color:#2b91af;">Resolution</span> resolution = <span style="color:blue;">new</span> <span style="color:#2b91af;">Resolution</span>(300);
            <span style="color:green;">//create TiffSettings object</span>
            <span style="color:#2b91af;">TiffSettings</span> tiffSettings = <span style="color:blue;">new</span> <span style="color:#2b91af;">TiffSettings</span>();
            tiffSettings.Compression = <span style="color:#2b91af;">CompressionType</span>.CCITT4;

            tiffSettings.Depth = Aspose.Pdf.Devices.<span style="color:#2b91af;">ColorDepth</span>.Default;
            tiffSettings.Shape = <span style="color:#2b91af;">ShapeType</span>.Landscape;
            tiffSettings.SkipBlankPages = <span style="color:blue;">false</span>;


            <span style="color:#2b91af;">Stream</span> output = <span style="color:blue;">null</span>;
            sourceImages = <span style="color:blue;">new</span> <span style="color:#2b91af;">Image</span>[pdfDocument.Pages.Count];
            <span style="color:green;">//create TIFF device</span>
            <span style="color:#2b91af;">TiffDevice</span> tiffDevice = <span style="color:blue;">new</span> <span style="color:#2b91af;">TiffDevice</span>(resolution, tiffSettings);
           

            <span style="color:blue;">for</span> (<span style="color:blue;">int</span> page = 1; page <= pdfDocument.Pages.Count; page++)
            {

                output = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>();
                <span style="color:green;">//tiffDevice.Process(pdfDocument, page, page, Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), ".",page.ToString().PadLeft(3, '0'))));</span>

                tiffDevice.Process(pdfDocument, page, page, output);


                sourceImages[page - 1] = <span style="color:#2b91af;">Image</span>.FromStream(output);

                sourceImages[page - 1].Save(<span style="color:#2b91af;">Path</span>.Combine(OutputFolder, <span style="color:#2b91af;">String</span>.Concat(<span style="color:#2b91af;">Path</span>.GetFileNameWithoutExtension(FullInputFileName), <span style="color:#a31515;">"."</span>, page.ToString().PadLeft(3, <span style="color:#a31515;">'0'</span>))));

                output = <span style="color:blue;">null</span>;

            }

        }
        <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex)
        {
            sourceImages = <span style="color:blue;">null</span>;
            <span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">Exception</span>(<span style="color:#2b91af;">String</span>.Format(<span style="color:#a31515;">"Error in splitTiffPages: {0}"</span>, ex.Message));
        }


        <span style="color:blue;">return</span> sourceImages;
    }</pre><br>Regards<br>Anish<br>

Hi Team,



I given

tiffSettings.Shape = ShapeType.None;
Still i not getting the original image after converting.

I have attached the PDF also.

hi Team,

Can you please help me on this

Hi Anish,


Thanks for your inquiry. While using Aspose.Pdf for .net 7.7.0 and setting Shape property to None , I’m unable to reproduce the reported issue. Can you please download and try latest Aspose.Pdf API. Hopefully your issue will be resolved.

tiffSettings.Shape = ShapeType.None;

Please feel free to contact us for any further assistance.

Best Regards,