Hope your're doing well. Actually, I have a requirment to convert simple text file to pdf in my application.
My aim is to first read a text file from a folder and store it in a string variable ,as we dont have a font methods in pdf converter, I am taking that text in a html string builder variable and adding some html font name and font size , then trying to convert it into a pdf format,.
Here is my code
StringBuilder mailBody = new StringBuilder();
mailBody.AppendFormat("<html>");
string fontname = "Lucida Console";
int size = 12;
mailBody.AppendFormat("<p> <span style='font-name:" + fontname + ";font-size:" + size + "px;'>" + readText + "<span></p>");
readText = mailBody.ToString();
Converter.ConvertHtmlString(readText, Dst_File);
But, the problem is that my text data is in ROWS and COLUMNS format. It has some spaces.
After converting it into a pdf using Converter.ConvertHtmlString(readText, Dst_File);
PDF data is getting compressed. I am data is printing line by line. there is no spaces in it. Could you please help me out. I will be very thank full
Problem in pdf printing using htmlstring
Re: Problem in pdf printing using htmlstring
Support · Jul 7, 2015Hello,
The code you are using to convert the text file to HTML is most likely removing the spaces in your row/column formatted text. Before you pass the HTML string to Converter for conversion to PDF, save the html file to disk and open it in Internet Explorer (IE) and check to make sure the row/column format is retained in the HTML. DynamicPDF Converter relies on IE to convert the HTML to PDF. So the PDF rendering will look similar to IE rendering of the HTML. If you want the PDF output to look similar to your text file, you will need to make sure the text file is correctly converted to HTML. In other words, if you open the intermediate HTML file in IE it should render the HTML in row/column format.
Thanks,
ceTe Software Support Team.