Free Support Forum - aspose.com

Error while converting Tiff -> Pdf: Parameter is not valid. Using Aspose.Pdf, C#, Ubuntu

Hi,

I am converting a TIFF file to PDF using Aspose.PDF and I am getting an error.

Could you please tell me what might be causing this issue?

ОS: Ubuntu 18.04.3 LTS.
C# .net.
Project Target Framework: .NET Core 2.2.

I used the following code:

public static void TiffToPdf(string sourcePath, string targetPath)
{
  Console.WriteLine("Start convert Tiff To Pdf.");

  using (var inputStream = new MemoryStream())
  {
    using (var fileStream = File.Open(sourcePath, FileMode.Open, FileAccess.ReadWrite))
      fileStream.CopyTo(inputStream);

    var pdfDocument = new Aspose.Pdf.Document();
    var page = pdfDocument.Pages.Add();

    using (var img = System.Drawing.Image.FromStream(inputStream))
    {
      var image = new Aspose.Pdf.Image
      {
        ImageStream = inputStream,
        IsInNewPage = true,
        IsKeptWithNext = true,
        HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Center,
      };

      page.Paragraphs.Add(image);

      Console.WriteLine("Before save.");

      pdfDocument.Save(targetPath);

      Console.WriteLine("Convert Tiff To Pdf is success.");
    }
  }
}

Error message:

System.ArgumentException: Parameter is not valid.
   at System.Drawing.Image.get_PropertyIdList()
   at Aspose.Pdf.Image.#=zOVYCjv4=(Double& #=zqH43fAc=, Double& #=zFdOhPis=, Double& #=zTl_W1yY=, Boolean #=zI$TTpyYYF_Ly, MarginInfo #=z2WVhCSY=, Double #=zEMQLUqDGHFuI, Double #=zOJdbFUg=, Page #=zkNijddA=, List`1 #=zA1LvAyY=, Boolean #=zG5VRs8hgi9fI, Boolean #=zPYHX8_E8ruzu, Boolean #=zHP2AWQE=, Paragraphs& #=z3$MKG5ubRbeWOh7FrQ==, Double #=zO$ca$j8b3Wnbk3YrFw==, Double #=zGLjwz1U=, Int32 #=zsO$3UDl_giyO$SatGUMrY1I=)
   at #=z6Gu3oEMf_fwueis7IsEom1s=.#=zOVYCjv4=()
   at Aspose.Pdf.Page.#=z42oynO4=(Page #=zkNijddA=)
   at Aspose.Pdf.Page.#=zrrvWX49tTiYZoGeuVw==()
   at Aspose.Pdf.Document.ProcessParagraphs()
   at Aspose.Pdf.Document.#=zc987sPODI9gV(Stream #=zUBYR2bw=, SaveOptions #=zalZVzje3NyLF)
   at Aspose.Pdf.Document.#=z_Si59eYP6riT(String #=zRhmsRbJ2_iGd)
   at Aspose.Pdf.Document.Save(String outputFileName)
   at CorePdfConverter.AsposeExt.TiffToPdf(String sourcePath, String targetPath) in D:\Projects\master\RX\tools\PdfConverter\CorePdfConverter\AsposeExt.cs:line 43

The error occurs on the line:
pdfDocument.Save(targetPath);

The file I used: https://yadi.sk/d/AtYcRbm4FauTOg

@directum

Would you kindly make sure to use Aspose.PDF for .NET 20.10 at your side and in case issue still occurs, please let us know. We will further proceed to assist you accordingly.

I tried the version 20.10 and got the same problem. Looking forward for your assistance.

@directum

We have tested the scenario in our environment (CentOS 7 x64) and noticed a different Exception i.e. System.Ldi not found. Therefore, we have logged an investigation ticket as PDFNET-48908 in our issue management system for further analysis. We will look into details of this scenario and keep you posted with the status of ticket resolution. Please be patient and give us some time.

We are sorry for the inconvenience.