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

Free Support Forum - aspose.com

Convert TIFF to PDF in Linux using C# | Aspose.PDF for .NET | Conversion failed

Hi,
I try to convert Tiff to Pdf like this:

  using (var imageStream = File.OpenRead(inputFile))
  using (var image = Aspose.Imaging.Image.Load(imageStream))
  using (var document = new Aspose.Pdf.Document())
  {
    var page = document.Pages.Add();
    page.PageInfo.Margin.Bottom = 0;
    page.PageInfo.Margin.Top = 0;
    page.PageInfo.Margin.Left = 0;
    page.PageInfo.Margin.Right = 0;
    page.PageInfo.Width = image.Width;
    page.PageInfo.Height = image.Height;
    page.CropBox = new Aspose.Pdf.Rectangle(0, 0, image.Width, image.Height);
    var pdfImage = new Aspose.Pdf.Image();
    pdfImage.ImageStream = imageStream;
    page.Paragraphs.Add(pdfImage);
    document.Save(outputFile);
  }

and get error:

Unhandled Exception: System.ArgumentException: Parameter is not valid.
   at System.Drawing.Image.get_PropertyIdList()
   at Aspose.Pdf.Image.#=z6kYfUaA=(Double& #=zlXeKPFM=, Double& #=zEIOZhh4=, Double& #=zR1bzaHA=, Boolean #=zilRKKGdKogIa, MarginInfo #=zLbrFmc0=, Double #=zw7uIEcGvyUsX, Double #=zD2Bz1s8=, Page #=z97RnNUE=, List`1 #=zsLUpgps=, Boolean #=zHO$s$gZYlaL1, Boolean #=zDlgDC8mw1nUm, Boolean #=zWlxW3i8=, Paragraphs& #=zCd2vwYcIrYQh2Pcsjw==, Double #=zwn6IXVSdfrBKCr4Ldg==, Double #=zmH4W35I=, Int32 #=z_V8J3X4ZTOXtTj125LlQog4=)
   at #=z11tnCvcTNPOy$FsoWXXzdDw=.#=z6kYfUaA=()
   at Aspose.Pdf.Page.#=zB99WyEE=(Page #=z97RnNUE=)
   at Aspose.Pdf.Page.#=zMmMgvSVnYTOkxEqULQ==()
   at Aspose.Pdf.Document.ProcessParagraphs()
   at Aspose.Pdf.Document.#=zIgncJc8VsF3C(Stream #=zYpgNQcg=, SaveOptions #=zoR0TS01IZW9D)
   at Aspose.Pdf.Document.#=zp0nLFuDb7z1v(String #=zQHkKAjLXFS_l)
   at Aspose.Pdf.Document.Save(String outputFileName)
   at ConsoleApp15.Program.ConvertInternal(String inputFile, String outputFile) in C:\Users\saragulov_nr\source\repos\ConsoleApp15\ConsoleApp15\Program.cs:line 42
   at ConsoleApp15.Program.Main(String[] args) in C:\Users\saragulov_nr\source\repos\ConsoleApp15\ConsoleApp15\Program.cs:line 12
Aborted (core dumped)

This happends only on Ubuntu. On Windows, it works without errors. File: tiff.7z (1.0 MB)

@SaragulovNail

Can you please make sure that you are using 21.4 version of the API as it is always recommended to use the latest version. Furthermore, please make sure that libgdiplus package and all Microsoft Fonts are installed in the system as API requires these packages to produce correct results.

Please install:

  • libgdiplus package
  • package with Microsoft compatible fonts: ttf-mscorefonts-installer. (e.g. sudo apt-get install ttf-mscorefonts-installer) These fonts should be placed in “/usr/share/fonts/truetype/msttcorefonts” directory as Aspose.PDF for .NET scans this folder on Linux like operating systems. In case operating system has other default folder/directory for fonts, you should use following line of code before performing any operation using Aspose.PDF.
Aspose.Pdf.Text.FontRepository.Sources.Add(new FolderFontSource("<user's path to ms fonts>"));

In case you still face any issue, please share the Linux OS Name and Version with us so that we can further proceed to assist you accordingly.

@ asad.ali
Thank you for your answer!

libgdiplus and ttf-mscorefonts-installer (in /usr/share/fonts/truetype/msttcorefonts) are installed. I tried new 21.5 version but the error occurred.

Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-66-generic x86_64)

@SaragulovNail

We have logged an investigation ticket as PDFNET-49933 in our issue tracking system to further analyze your case. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We apologize for the inconvenience.