Hello,
when i try to convert a specific string (html) to pdf, i get the following message “Specified argument was out of the range of valid values. Parameter name: count”
My C# code is as follow
protected Aspose.Pdf.MarginInfo setPageMargin(double top = -1, double bottom = -1)
{
Double _top = top == -1 ? header.Height + 30 : top;//; 30 = Margin Top Header
Double _left = 60;//70.87; // 25 mm * 25,4 / 72
Double _right = 30;//42.52; // 15 mm * 25,4 / 72
Double _bottom = bottom == -1 ? footer.Height : bottom;
if (header.HeaderType == 1)
{
_left = 51.02;
_right = 28.35;
}
Aspose.Pdf.MarginInfo _marginInfo = SetMarginInfo(_top, _left, _right, _bottom);
return _marginInfo;
}
private HtmlLoadOptions setHtmlLoadOptions(Aspose.Pdf.MarginInfo marginInfo)
{
HtmlLoadOptions loadoptions = new HtmlLoadOptions();
loadoptions.PageInfo.Width = Aspose.Pdf.PageSize.A4.Width;
loadoptions.PageInfo.Height = Aspose.Pdf.PageSize.A4.Height;
loadoptions.PageInfo.Margin = marginInfo;
loadoptions.InputEncoding = Encoding.UTF8.ToString();
loadoptions.PageInfo.DefaultTextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Arial");
loadoptions.IsEmbedFonts = true;
return loadoptions;
}
HtmlLoadOptions _htmlLoadOptions = setHtmlLoadOptions(setPageMargin());
private MemoryStream stringToMemoryStream(String htmlContent)
{
Byte[] _byteArray = System.Text.Encoding.UTF8.GetBytes(htmlContent);
MemoryStream _memoryStream = new MemoryStream(_byteArray);
return _memoryStream;
}
protected void NewAsposeDocument(String htmlContent, HtmlLoadOptions loadoptions)
{
MemoryStream _memoryStream = stringToMemoryStream(htmlContent);
asposeDocument = new Aspose.Pdf.Document(_memoryStream, loadoptions);
//asposeDocument.Flatten();
}
And this is the html document / string to be converted htmlToConvert.zip (3.0 MB)
Thank you for your help.