ColorBlend Error converting PDF to HTML

We are currently using Aspose.Pdf and Aspose.Pdf.HTMLSaveOptions to convert PDF files to html and text.


A file that we have is not converting the orginial PDF file to HTML. Below is the error that is getting returned. What could be causing this?

LogLevel=ERROR Logger=DocumentConversion.WebService.Services.ConvertService Message="Failed to convert document from Pdf to Html." Exception="OTJ.Enterprise.Exceptions.ApplicationServiceException: Failed to convert documentfrom Pdf to Html. ---> System.ArgumentException: ColorBlend object that was set is not valid.Position's last element must be equal to 1.0. ColorBlend objects must be constructed with the same number of positions and color values. Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array.

at System.Drawing.Drawing2D.LinearGradientBrush._SetInterpolationColors(ColorBlend blend)

at .?\x81?.(?? )

at .???.\x8F(??? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at \x8F?.??.Accept(?? )

at \x8F?.???.Accept(?? )

at .???.?\x8F(?? , Graphics )

at ?.?.?(??? , \x81? )

at ??\x8D.?.\x8F(??? , Hashtable )

at \x9D..?(? )

at \x9D..?(? )

at \x8D.?.Convert(ArrayList , ? , ? )

at ?\x90.?\x90.Convert(String , ? , IList`1 , \x81 , ? )

at ?..?(Document , String , Stream , HtmlSaveOptions )

at Aspose.Pdf.Document.Save(String outputFileName, SaveOptions options)

Hi Brent,


Thanks for your inquiry. We will appreciate it if you please share your sample source document here, we will test the scenario and will provide you information accordingly.

We are sorry for the inconvenience.

Best Regards,

Hi Tilal,


The file that was returning the ColorBlend Error is now attached.

Thanks!
Brent

Hi Brent,

Thanks for sharing the resource file.

I have tested the scenario of PDF to HTML conversion using Aspose.Pdf for .NET 11.9.0 following code snippet and I am unable to notice any problem. As per my observations, the resultant HTML is properly being converted. For your reference, I have also attached the output generated over my end.

[C#]

// load PDF document
Document doc = new Document("c:/pdftest/peter_james_resume.pdf");
// save output as HTML format
doc.Save("c:/pdftest/peter_james_resume.html", SaveFormat.Html);

We updated to Aspose 11.9, and re-ran the tests.

The conversion on the attached document still fails. If I take out these save options, it works fine, but we are trying to save with the artifacts embedded.

We are using these html save options

var htmlOptions = new HtmlSaveOptions

{

// Enable option to embed all resources inside the HTML

PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml,

// This is just optimization for IE and can be omitted

LettersPositioningMethod = HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss,

RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground,

FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats

};

With this save call

var pdfIn = new Aspose.Pdf.Document(file);

pdfIn.Save(htmlOutPath, htmlOptions);

We get this error:

Attempting convert of C:\Users\cassy.healy\Documents\LINQPad Queries\ProblemPDFs\peter_james_resume.pdf to html.
C:\Users\cassy.healy\Documents\LINQPad Queries\ProblemPDFs\OUT\peter_james_resume.html FAILED. Message ColorBlend object that was set is not valid.Position's last element must be equal to 1.0. ColorBlend objects must be constructed with the same number of positions and color values. Positions must be between 0.0 and 1.0, 1.0 indicating the last element in the array. Stack Trace at System.Drawing.Drawing2D.LinearGradientBrush._SetInterpolationColors(ColorBlend blend)
at System.Drawing.Drawing2D.LinearGradientBrush.set_InterpolationColors(ColorBlend value)
at


.[1]( [1])

at


.[1]( [1])

at .


(ApsPath [1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsPath.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCanvas.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCanvas.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCanvas.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCanvas.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCanvas.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCanvas.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsCompositeNode.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at Aspose.Rendering.Aspose.Foundation5996002.ApsPage.fpyz9lhvvq79hapc3mstgrqrlusmz47y [1](

[1])

at .[1](ApsNode [1], Graphics


)

at .[1](ApsPage [1],


)

at .[1](ApsPage [1],



)

at

.[1](ApsCanvas [1], String


)

at

. [1](ApsCanvas [1], Dictionary`2


)

at . [1]( [1])

at . [1]( [1])

at

. [1]( [1])

at .[1](List`1 [1],


,

)

at .[1](String [1], [1]


, IList`1 , , )

at

.[1]([1] [1], String


, Stream , Boolean , HtmlSaveOptions )

at

.[1](Document [1], String


, Stream , HtmlSaveOptions )

at Aspose.Pdf.Document.Save(String outputFileName, SaveOptions options)

at UserQuery.RunUserAuthoredQuery() in c:\Users\cassy.healy\AppData\Local\Temp\LINQPad\_staldltr\query_baynbk.cs:line 68

C:\Users\cassy.healy\Documents\LINQPad Queries\ProblemPDFs\OUT\peter_james_resume.html Saved sucessfully in 0 seconds.

Hi Brent,


Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFNET-41342 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.