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

Free Support Forum - aspose.com

IwarningCallback usage in pdf conversion

Hi Team,

Currently i am converting a PDF document to single page tiff images by using the below mentioned code.



public static System.Drawing.Image[] ConvertPDFtoMultiPageTiff(string OutputFolder, string FullInputFileName)
{
System.Drawing.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;
    
            
            <span style="color:blue;">if</span>(tiffSettings.Shape == <span style="color:#2b91af;">ShapeType</span>.Landscape)
            tiffSettings.Shape = <span style="color:#2b91af;">ShapeType</span>.Portait;
           
            tiffSettings.SkipBlankPages = <span style="color:blue;">false</span>;
            tiffSettings.Brightness = .40f;
     

            <span style="color:#2b91af;">Stream</span> output = <span style="color:blue;">null</span>;
            sourceImages = <span style="color:blue;">new</span> System.Drawing.<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>();

                tiffDevice.Process(pdfDocument, page, page, output);
                sourceImages[page - 1] = System.Drawing.<span style="color:#2b91af;">Image</span>.FromStream(output);
                <span style="color:green;">//sourceImages[page - 1].Save(Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), ".", page.ToString().PadLeft(3, '0'))));</span>
                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), page.ToString().PadLeft(3, <span style="color:#a31515;">'0'</span>), <span style="color:#a31515;">"."</span>, <span style="color:#a31515;">"tiff"</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;
    }<br><br><br>I read in the aspose site that by using IwarningCallback methode we can 

get the warning if there is a problem in the document. Can you please
help me how can i achieve this functionality in the above code?

Regards
Anish


Hi Anish,


Thanks for your inquiry. We are looking into it and will update you soon.

Best Regards,

Hi Anish,


Thanks for your patience. I’m afraid currently the subjected feature is not supported for PDF to Image conversions. However, I’ve logged an feature enhancement request as PDFNEWNET-35391 in our issue tracking system. We will notify you via this forum thread as soon as it gets available.

Sorry for the inconvenience faced.

Best Regards,