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: 400x400 вращающаяся земля.zip — Yandex Disk