I generate an html report by replacing the keys in the html file with dynamic values. When converting to a pdf file using Telerik this error is thrown. I have checked several times and I do not have any duplicated keys. The error is thrown when trying to import the html report.
JpegImageConverterBase customJpegImageConverter = new CustomJpegImageConverter();
FixedExtensibilityManager.JpegImageConverter = customJpegImageConverter;
HtmlFormatProvider htmlProvider = new HtmlFormatProvider();
PdfFormatProvider fixedProvider = new PdfFormatProvider();
//using flow provider to treat html content
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider flowProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
var itemDetailsDoc = htmlProvider.Import(htmlReport);
Hello Pandi,
I would be glad to help you resolve the issue you are experiencing but without having any resources to examine my assistance is very limited.
In order for me to get a better context and understanding of this case, would you be able to share with us the HTML content that reproduces this behavior? That way I can try to achieve the same scenario on my end, examine the resources, and get back to you with details and specifics.
Note: Please be aware that this is a Q&A Forum thread and any resources shared here are public and there is no confidentiality. With that in mind please make sure that you omit any sensitive information from the resources or replace it with dummy data as long as it can still be used to reproduce the issue.
Thank you in advance for your cooperation.
This is the html:
<table border="0" cellpadding="1" cellspacing="1" style="height:84px; width:1080.6px">
<tbody>
<tr>
<td style="width:1071px">
<p><span style="font-family:sans-serif; font-size:calc(var(--scale-factor)*9.00px)"><strong> <img src="{Logo}" alt="" style="height:44px; width:79px" /> <img src="{LogoReport}" alt="" style="height:44px; width:79px" /></strong></span></p>
</td>
</tr>
</tbody>
</table>
<br />
<p><span style="font-size:22px"><span style="font-family:sans-serif">Ordine di Servizio programmato: {Protocollo}</span></span></p>
<table border="0" cellpadding="1" cellspacing="1" style="height:151px; max-width:814px">
<tbody>
<tr>
<td style="max-width:181px"><span style="font-size:14px"><span style="font-family:sans-serif">Procedura</span></span></td>
<td style="max-width:148px"><span style="font-size:14px"><u><span style="font-family:sans-serif">{JobList}</span></u></span></td>
<td style="max-width:102px"><span style="font-size: 14px"><span style="font-family:sans-serif">Assegnatario</span></span></td>
<td style="max-width:385px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{Assegnatario}</span></u></span></td>
</tr>
<tr>
<td style="max-width:181px"><span style="font-size: 14px"><span style="font-family:sans-serif">Descrizione</span></span></td>
<td style="max-width:148px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{JobListDescrizione}</span></u></span></td>
<td style="max-width:102px"><span style="font-size: 14px"><span style="font-family:sans-serif">Periodicita</span></span></td>
<td style="max-width:385px"><u><span style="font-size: 14px"><span style="font-family:sans-serif">{PeriodicitaDescrizione}</span></span></u></td>
</tr>
<tr>
<td style="max-width:181px"><span style="font-size: 14px"><span style="font-family:sans-serif">Fornitore</span></span></td>
<td style="max-width:148px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{Fornitore}</span></u></span></td>
<td style="max-width:102px"><span style="font-size: 14px"><span style="font-family:sans-serif">Pianificato</span></span></td>
<td style="max-width:385px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{Pianificato}</span></u></span></td>
</tr>
<tr>
<td style="max-width:181px"><span style="font-size: 14px"><span style="font-family:sans-serif">Oggetto di servizio</span></span></td>
<td style="max-width:148px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{OggettoServizio}</span></u></span></td>
<td style="max-width:102px"><span style="font-size: 14px"><span style="font-family:sans-serif">Eseguito</span></span></td>
<td style="max-width:385px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{Eseguito}</span></u></span></td>
</tr>
</tbody>
</table>
<br />
<table cellpadding="1" cellspacing="1" style="height:29px; width:750px">
<tbody>
<tr>
<td style="text-align: center; width: 750px; background-color: #d6d6d6; "><span style="font-family: sans-serif; font-size: 14px;"><b>LOCALIZZAZIONE</b></span></td>
</tr>
</tbody>
</table>
<br />
<table border="0" cellpadding="1" cellspacing="1" style="height:151px; max-width:814px">
<tbody>
<tr>
<td style="max-width:181px"><span style="font-size:14px"><span style="font-family:sans-serif">Comprensorio</span></span></td>
<td style="max-width:148px"><span style="font-size:14px"><u><span style="font-family:sans-serif">{Comprensorio}</span></u></span></td>
<td style="max-width:102px"><span style="font-size: 14px"><span style="font-family:sans-serif">Piano</span></span></td>
<td style="max-width:385px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{Piano}</span></u></span></td>
</tr>
<tr>
<td style="max-width:181px"><span style="font-size: 14px"><span style="font-family:sans-serif">Edificio</span></span></td>
<td style="max-width:148px"><span style="font-size: 14px"><u><span style="font-family:sans-serif">{Immobile}</span></u></span></td>
<td style="max-width:102px"><span style="font-size: 14px"><span style="font-family:sans-serif">Vano</span></span></td>
<td style="max-width:385px"><u><span style="font-size: 14px"><span style="font-family:sans-serif">{Vano}</span></span></u></td>
</tr>
<tr>
<td style="max-width:181px"><span style="font-size: 14px"><span style="font-family:sans-serif">{IndirizzoImmobile}</span></span></td>
</tr>
</tbody>
</table>
<br />
<br />
{TabellaCodiceAssets}
<br />
<br />
{TabellaAttivita}
<br />
<table cellpadding="1" cellspacing="1" style="height: 29px; width: 750px; border-top: 1px solid #d6d6d6;">
<tbody>
<tr style="height: 29px;" id="oneAttivita">
<td style="width: 80px; border: 1px solid #d6d6d6;"><span style="font-size:14px"><span style="font-family:sans-serif">Controllato il:</span></span></td>
<td style="width: 140px; border: 1px solid #d6d6d6;"><span style="font-size:14px"><span style="font-family:sans-serif">{Controllato}</span></span></td>
<td style="width: 75px; border: 1px solid #d6d6d6;"><span style="font-size:14px"><span style="font-family:sans-serif">Da:</span></span></td>
<td style="width: 165px; border: 1px solid #d6d6d6;"><span style="font-size:14px"><span style="font-family:sans-serif">{UtenteControllo}</span></span></td>
<td style="width: 170px; border: none;"><span style="font-size:14px"><span style="font-family:sans-serif"> </span></span></td>
</tr>
</tbody>
</table>
<table cellpadding="1" cellspacing="1" style="width: 750px ">
<tbody>
<tr>
<td style="text-align: center; width: 750px; background-color: #d6d6d6; "><span style="font-family: sans-serif; font-size: 14px;"><b>SPAZIO RISERVATO ALL' ESECUTORE</b></span></td>
</tr>
</tbody>
</table>
<p style="font-family: sans-serif; font-size: 14px;">Note <span>{NoteControllo}</span></p>
<br />
<table border="0" cellpadding="1" cellspacing="1" style="width: 750px ">
<tbody>
<tr>
<td style="text-align: center; width: 375px; border: 1px solid #d6d6d6; padding:10px;">
<p><span style="font-family:sans-serif; font-size:14px; ">DATA/ORA</span></p>
</td>
<td style="text-align: center; width: 375px; border: 1px solid #d6d6d6; padding:10px;">
<p><span style="font-family:sans-serif; font-size:14px; ">TEMPO</span></p>
</td>
<td style="text-align: center; width: 375px; border: 1px solid #d6d6d6; padding: 10px; "><span style="font-family:sans-serif; font-size:14px;">NOMI E FIRME ESECUTORI</span></td>
</tr>
<tr>
<td style="text-align: center; width: 375px; border: 1px solid #d6d6d6; ">
<p><span style="font-family:sans-serif; font-size:14px;">{FormattedDataChiusura}</span></p>
<p> </p>
</td>
<td style="text-align: center; width: 375px; border: 1px solid #d6d6d6; ">
<p><span style="font-family:sans-serif; font-size:14px;">{Tempo}</span></p>
<p> </p>
</td>
<td style="text-align: center; width: 375px; border: 1px solid #d6d6d6; ">
<p><span style="font-family:sans-serif; font-size:14px;"><img src="{Firma}" alt="" style="height:44px; width:79px" /></span></p>
<p> </p>
</td>
</tr>
</tbody>
</table>
<p> </p>
<hard-pagebreak>
I replace the keys in {} with dynamic values. And in the end I replace
htmlReport = htmlReport.Replace("<hard-pagebreak>", "<b>[PAGEBREAK]</b>");var itemDetailsDoc = htmlProvider.Import(htmlReport);
Hello Pandi,
Thank you for providing us with the HTML snippet. I incorporated it into a project on my end (NET Standard, DPL version 2024.1.209) and replaced the placeholders with some sample data in order to reproduce the exception you are describing but I am able to export the content to PDF successfully without any issues.
That said, it is possible that I could be missing something in the process which is why I am attaching the project for your disposal as well. Feel free to examine it, compare differences, and don't hesitate to correct me if you find anything worth noting. If you are able to modify it so that it throws out the same error, feel free to send it back so I can examine it.
Reproducing this issue can depend on various factors which is why I would ask you to provide as many of the following context elements as possible regarding this case.
Anything is welcome as it would really help me with the investigation of this scenario.
Thank you in advance. I am looking forward to your reply.
Regards,
Yoan