I’ve upgraded our version of Aspose PDF for .Net recently and am now seeing problems when converting a PDF document to HTML. This only happens for some PDF documents - the ones I have noticed it happening on are documents that have been scanned to PDF (i.e. full page images).
The exception is:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.ArgumentException: Parameter is not valid.
at System.Drawing.Bitmap…ctor(Int32 width, Int32 height, PixelFormat format)
at .?…ctor(Int32 , Int32 , Single , Single , PixelFormat )
at ?.?.?( , )
at ?.?.Convert( , ? )
at ??.a?.(? , Dictionary2 ) <br /> at ..?(? ) <br /> at ..?(? ) <br /> at ..?(? ) <br /> at .?.Convert(ArrayList , ? , ? ) <br /> at ?.?.Convert(String , ? , IList
1 , a , )
at ?..?(Document , String , Stream , HtmlSaveOptions )
at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options)
Does anyone have any pointers as to what may be needed to fix this. It used to work in the older version of the Aspose Library.
Our PDF to HTML conversion code is fairly boilerplate (snippet provided below):
var doc = new Document(source);
var borderStyle = new SaveOptions.BorderPartStyle
{
LineType = SaveOptions.HtmlBorderLineType.Dotted,
Color = System.Drawing.Color.Gray
};
var options = new HtmlSaveOptions
{
SpecialFolderForAllImages = _imagesDir,
SplitCssIntoPages = false,
SplitIntoPages = false,
CustomResourceSavingStrategy = SaveFontsAndImages,
CustomCssSavingStrategy = WriteCssToFolder,
CustomStrategyOfCssUrlCreation = GetCssUrl,
LettersPositioningMethod = HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss,
FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats,
HtmlMarkupGenerationMode = HtmlSaveOptions.HtmlMarkupGenerationModes.WriteAllHtml,
PageBorderIfAny = new SaveOptions.BorderInfo(borderStyle),
FixedLayout = true,
RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground
};
doc.Save(destination, options);
Hi Damon,
Here is a sample PDF that causes it.
I have found that it is pretty consistent that PDFs created by scanning cause it whilst others do not seem to.
Hi Damon,
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-38560. We
will investigate this issue in details and will keep you updated on the status
of a correction. <o:p></o:p>
We apologize for your inconvenience.
Do you have an update on this issue?
We cant release our next version of our software until this is fixed.
Hi Damon,
Has there been any progress on this issue. We cannot upgrade until it is fixed and it has been some time with no response.
Hi Damon,
We are sorry for the inconvenience caused.
Best Regards,
Hi Damon,