Free Support Forum - aspose.com

PngDevice Process Parameter is not valid

Hi,


I’m using Aspose PDF 10.5.1.0
In the code below if you use it in parallel mode you get.

Exception on page 130
Parameter is not valid.
at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
at ?:spades::bangbang:.:slight_smile::bangbang:…ctor(?:spades::bangbang: , :arrow_up_down::spades::bangbang: )
at ?:clubs::bangbang:.:heart::spades::bangbang:.:clubs::slight_smile:§(?:spades::bangbang: , :arrow_up_down::spades::bangbang: )
at ?:bangbang::bangbang:.?:bangbang::bangbang:…ctor(:arrow_up_down::clubs::bangbang: , §◄:bangbang: , ?:spades::bangbang: )
at ?:bangbang::bangbang:.§☼.Process(:arrow_up_down::clubs::bangbang: document, §◄:bangbang: page, ?:spades::bangbang: device, ?:bangbang::bangbang:& context)
at ?⌂↓.?:heart:♫.??¶(?:bangbang::bangbang:& context)
at Aspose.Pdf.Devices.ImageDevice.??¶(Page )
at Aspose.Pdf.Devices.PngDevice.Process(Page page, Stream output)
at ConsoleApplication3.Program.ProcessPage(Int32 page) in d:\temp\ConsoleApplication3\Program.cs:line 21

Page number change each time you run it.
In linear mode no problems.
Reproduced on Windows 7 and 2013 Server R2.
Attached project + PDF file

static string m_file;
static void ProcessPage(int page)
{
try
{
using (Aspose.Pdf.Document doc = new Aspose.Pdf.Document(m_file))
{
using (System.IO.FileStream ms2 = System.IO.File.Create(string.Format(“out{0:000}.png”, page)))
{
Aspose.Pdf.Devices.PngDevice png = new Aspose.Pdf.Devices.PngDevice((int)(21f * 300f / 2.54f), (int)(29.7f * 300f / 2.54f), new Aspose.Pdf.Devices.Resolution(300));
png.Process(doc.Pages[page], ms2);
}
}
}
catch (Exception ex)
{
Console.WriteLine(“Exception on page {0}”, page);
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
throw ex;
}
}

static void Main(string[] args)
{
if (args.Length == 2)
{
new Aspose.Pdf.License().SetLicense(new System.IO.MemoryStream(Properties.Resources.Aspose_Total));
m_file = args[1];
DateTime start = DateTime.Now;
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(m_file);
int pageCount = doc.Pages.Count;
doc.Dispose();

if (args[0] == “l”)
{
for (int i = 0; i < pageCount; i++)
ProcessPage(i + 1);
}
else if (args[0]==“p”)
Parallel.For(1, pageCount + 1, ProcessPage);

Console.WriteLine((DateTime.Now - start).TotalSeconds);
}
else
Console.WriteLine(“test.exe [p|l] pdfFile”);
}

I did try with lastest version and got the same problem.

Hi Remi,


Thanks
for using our API’s.<o:p></o:p>

I have tested the scenario and I am able to reproduce the same problem. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-39011. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.