Converting pdf to multi tiff images

Hi ,

I am trying to convert a pdf file to tiff image by using aspose.pdf .

From that single pdf i am again converting it to multi tiff images.

But the tiff images which is having blue ink is not clear after conversion to multi tiff images.

Can you please help me is there any option to convert the pdf to tiff and again that single tiff image to multi tiff images ?

Please find the attached pdf file. Can you pls try to convert this to tiff and convert it again multi tiff images and provide me the code for that.

Regards
Anish

Hi Team,

Can anybody help me to convert a pdf file to multipage tiff image using aspose.pdf.

Regards
Anish

Hi Anish,


Thanks for using our products.

As per my understanding, you need to convert individual page of PDF file to separate TIFF image rather than the complete PDF is converted to a multipage TIFF. I have tested the scenario using following code snippet with Aspose.Pdf for .NET 7.7.0 and as per my observations, the blue ink is appearing in resultant images.

[C#]

//open document<o:p></o:p>

Document pdfDocument = new Document("c:/pdftest/ERIC'S+LTD+PAPER.pdf");

//create Resolution object

Resolution resolution = new Resolution(300);

//create TiffSettings object

TiffSettings tiffSettings = new TiffSettings();

tiffSettings.Compression = CompressionType.None;

tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;

tiffSettings.Shape = ShapeType.Landscape;

tiffSettings.SkipBlankPages = false;

//create TIFF device

TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);

for (int page = 1; page <= pdfDocument.Pages.Count; page++)

{

//convert a particular page and save the image to file

tiffDevice.Process(pdfDocument,page,page, "c:/pdftest/ERIC'S+LTD+PAPER_output"+page.ToString()+".tif");

}

Hi Nayyer Shahbaz

I tried to do the same way which you provided me.
But unfortunately i am not able to get the tiff file.
Please see the below code which i am using.

 Document pdfDocument = new Document(“E:/CO/Input/ERIC’S LTD PAPER.pdf”);
//create Resolution object
Resolution resolution = new Resolution(300);
//create TiffSettings object
TiffSettings tiffSettings = new TiffSettings();
tiffSettings.Compression = CompressionType.None;
tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Default;
tiffSettings.Shape = ShapeType.Landscape;
tiffSettings.SkipBlankPages = false;
            <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++)
            {<br>                 tiffDevice.Process(pdfDocument, page, page, <span style="color:#a31515;">"E:/CO/Output"</span> + page.ToString() + <span style="color:#a31515;">".tif"</span>);

            }<br><br>One more thing, Currently i am using Aspose.pdf for .NEt V 7.2.0.0<br>Is this cause any issue<br><br>Regards<br>Anish<br></pre><br>

Now i am able to generate the tiff images.

Thanks for your help.

Regards
Anish

anishvj:
Now i am able to generate the tiff images.
Hi Anish,

I am pleased to hear that your problem is resolved. Can you please confirm that, by using the latest release version, you managed to get the TIFF images or there have been some other reasons causing a problem during PDF to TIFF conversion. This information will help us in better/further understanding the problem that you have been facing.

Hi,



I was able to convert the pdf to tif image with Aspose only.

But now there is an issue.

I have a pdf file and which i am not able to convert to single page tiff. as it is not converting the full image in the pdf file.

I have attached the pdf file and a tiff file which is converted…
Can you please help me. This is a critical issue for me.
Regards
Anish

Hi Team,


I have a pdf file and which i am not able to convert to tiff images correctly.

I have attached the pdf file and a tiff file which is converted…
Can you please help me. This is a critical issue for me.
Regards
Anish

Hi Team,

Is there any update on this issue, Please
My customer is waiting for my reply.
They are asking me why pdf is not converting with Aspose.

Regards
Anish

Hi Team,

Can some one help me to fix this issue

Regards
Anish

Hi Anish,


Thanks for your inquiry. While testing the scenario with Aspose.Pdf for .NET 7.9, I’m afraid I’m unable to reproduce the issue, please find attached image. Please download and try latest Aspose.Pdf for .NET API. Hopefully it will fix the issue. If issue persist then please share your sample code here for further investigation.

Sorry for the inconvenience faced.

Best Regards,

Hi Anish,


Thanks for your inquiry. Please follow your query here.

Best Regards,

Hi,
I downloaded the Aspose.Pdf for .net 7.9
But still i am not able to convert the pdf file.

Please see the below code which i am using for convert.

 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>;
           
     

            <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>();
             
                <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] = System.Drawing.<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;
    }<br>Regards<br>Anish<br></pre><br>

Hi Team,
Is there any problem with my code?
Can you please help me.

Regards
Anish

Hi Team,

As it is very urgent and i need to fix this issue today itself , please help me.
I am not able to convert with new version of Aspose.pdf dll

Regards
Anish

Hi Anish,


Thanks for sharing source code. I’ve tested your source code, with slightly change in output file name code, as following. please find enclosed output files. Hopefully it will serve the purpose.

sourceImages[page - 1].Save(Path.Combine(OutputFolder, String.Concat(Path.GetFileNameWithoutExtension(FullInputFileName), page.ToString().PadLeft(3, ‘0’), “.”,“tiff”)));

Please feel free to contact us for any further assistance.

Best Regards,


Hi Tilal,
I had changed my code accordingly.
But still i am not able to generate the clear output.
Please see the attachment.

 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>;
           
     

            <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);
               
                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;
    }</pre><br>Regards<br>Anish <br>

Hi;

Still i am not able to convert the attached PDF to single page tiff images.
I tried all the way that you suggested.

Is there any other alternative to get this issue fixed. Please help me.

Regards
Anish

Hi Anish,


Thanks for using our products and sorry for the delayed response.

I
have tested the scenario and I am able to notice the same problem that resultant TIFF image is not correct (not identical to source PDF file). For the sake
of correction, I have logged this issue as PDFNEWNET-35225 in
our issue tracking system. We will further look into the details of this problem
and will keep you updated on the status of correction. Please be patient and
spare us little time. We are sorry for this inconvenience.<o:p></o:p>

Thanks for your reply.

For me this is a high priority issue and our customer is waiting for fix this.
Can you please help me to get an update quickly.

regards
Anish