Convert Tif to PDF using c# .net core 2.1 with Aspose.PDF - Parameter is invalid

Hi Team,

I am using licence version product of Aspose.

we are using .net core-2.1 c# and windows 10.

if we are using memory stream and bit map then some files only are converted (tif to pdf) successfully details as given below:
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
// Add a page to pages collection of document
Aspose.Pdf.Page page = doc.Pages.Add();
// Load the source image file to Stream object
FileStream fs = new FileStream(jpgImagePath, FileMode.Open, FileAccess.Read);
byte[] tmpBytes = new byte[fs.Length];
fs.Read(tmpBytes, 0, int.Parse(fs.Length.ToString()));

            MemoryStream mystream = new MemoryStream(tmpBytes);
            // Instantiate BitMap object with loaded image stream
            System.Drawing.Bitmap b = new System.Drawing.Bitmap(mystream)

But if we are using TiffImage class of Aspose then unable to load image details as given below:

//using (TiffImage image = (TiffImage)Image.Load(jpgImagePath))

Kindly suggest to me for best way to convert tiff(multiple pages also.) to pdf.

@docTestIndresh

Please try using following code snippet which can also convert a multipage TIFF image to PDF:

Document pdf1 = new Document();

MemoryStream ms = new MemoryStream();
new FileStream(dataDir + "test.tiff", FileMode.Open).CopyTo(ms);
Bitmap myimage = new Bitmap(ms);

FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
int frameCount = myimage.GetFrameCount(dimension);

for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
{
 Page sec = pdf1.Pages.Add();
 myimage.SelectActiveFrame(dimension, frameIdx);
 MemoryStream currentImage = new MemoryStream();
 myimage.Save(currentImage, ImageFormat.Tiff);
 if (myimage.Width > myimage.Height)
 {
  sec.PageInfo.IsLandscape = true;
 }
 else
 {
  sec.PageInfo.IsLandscape = false;
 }
 sec.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
 sec.PageInfo.Height = myimage.Height;
 sec.PageInfo.Width = myimage.Width;
 Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
 imageht.ImageStream = currentImage;
 sec.Paragraphs.Add(imageht);
}
pdf1.Save(dataDir + "TifftoPDF.pdf");

Hi Asad Ali,

Many Thanks for your update.

I have used same code as above i have shared, only some tiff file was converting not all.
can you suggest any other option if possible.

Regards
Indresh

@docTestIndresh

Would you kindly share those TIFF files with which the shared code snippet is not working. We will test the scenario in our environment and address it accordingly. Also, please share what type of issue you are facing.

Hi Asad,

Thanks for your update.

I am using .net core 2.1 and windows 10 i am using same code which i have shared by you.

But still some files unable to convert (tiff to pdf).

Please find my files which was not converting into pdf file.
Regards
IndreshtwoFile.zip (6.1 MB)

Issue:

We are getting error: Parameter is invalid.

@asad.ali,

Please answer me as above , i am waiting.

Hi @asad.ali

Hi Asad,

Thanks for your update.

I am using .net core 2.1 and windows 10 i am using same code which i have shared by you.

But still some files unable to convert (tiff to pdf).

Please find my files which was not converting into pdf file.
Regards
IndreshtwoFile.zip (6.1 MB)

Issue:

We are getting error: Parameter is invalid.

@docTestIndresh

Sorry for the delayed response.

We have tested the scenario in our environment using Aspose.PDF for .NET 20.9 and were able to notice similar exception that you have mentioned. Therefore, we have logged following issues in our issue tracking system for the sake of correction:

  • PDFNET-48799 (Figure 1_xyz490571ca029f0.tif)
  • PDFNET-48800 (Figure 2.tif)

We will further look into details of the logged issues and keep you informed about their rectification status. Please be patient and spare us some time.

We apologize for your inconvenience.

Hi @asad.ali,

Thanks for your update.

There are some question as given below:

1-Kindly share list of files here covering all the file, file extension and its limitations for pdf conversion.

2-About what files are and are not permitted? I don’t expect every file to be converted in every case, but if we know the basic requirements then we can tell users to format files correctly.

Because i am facing same issue with multiple extensions of file like( TIFF,BMP, PNG …etc).
I am using license version everything’s.

In any one contact directly like(meeting, call mail etc)that is more better for us.

Regards
Indresh

@docTestIndresh

You can find all supported file formats (import/export) by the Aspose.PDF in Supported File Formats section of the API documentation. Furthermore, we would like to share with you that we encourage providing support via our dedicated forums and in case you face any issue while processing any supported file format, please let us know by sharing the sample file. We will test the scenario in our environment and address the issue accordingly.

Hi @asad.ali,

Please provide any solution for those tiff files.

We have tested the scenario in our environment using Aspose.PDF for .NET 20.9 and were able to notice similar exception that you have mentioned. Therefore, we have logged following issues in our issue tracking system for the sake of correction:

  • PDFNET-48799 ( Figure 1_xyz490571ca029f0.tif )
  • PDFNET-48800 ( Figure 2.tif )

We will further look into details of the logged issues and keep you informed about their rectification status. Please be patient and spare us some time.

waiting from much time.

Thanks & Regards
Indresh

@docTestIndresh

We apologize for the inconvenience caused by the issues.

We regret to inform you that earlier logged tickets are not yet resolved. Please note that they were logged under free support model and will be investigated resolved on a first come first serve basis. We also regret that we cannot share any ETA at the moment as the investigation against them is not yet done. We will certainly inform you as soon as we make some definite progress towards their resolution. We request your patience in this matter.

We again apologize for the inconvenience.