Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Sep 02, 2021 1:22 am

Thanks for your response.
Okay, if the official version is released, we will inform you immediately.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Sep 02, 2021 3:46 pm

Brian,

I have been testing the conversion of text file to PDF using spire.pdf, I see an issue where "TAB" is not transformed correctly.

The code snippet I used is below

string text = File.ReadAllText("TestFile.txt");
PdfDocument doc = new PdfDocument();
PdfSection section = doc.Sections.Add();
PdfPageBase page = section.Pages.Add();
PdfFont font = new PdfFont(PdfFontFamily.Courier, 10);
PdfStringFormat format = new PdfStringFormat();
format.LineSpacing = 10f;
PdfBrush brush = PdfBrushes.Black;
PdfTextWidget textWidget = new PdfTextWidget(text, font, brush);
float y = 0;
PdfTextLayout textLayout = new PdfTextLayout();
textLayout.Break = PdfLayoutBreakType.FitPage;
textLayout.Layout = PdfLayoutType.Paginate;
RectangleF bounds = new RectangleF(new PointF(0, y), page.Canvas.ClientSize);
textWidget.StringFormat = format;
textWidget.Draw(page, bounds, textLayout);
doc.SaveToFile("TxtToPDf.pdf", FileFormat.PDF);

Also please find the input and the output files attached.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Fri Sep 03, 2021 3:16 am

Hello,

Thanks for providing your test files.
Regarding the "TAB" issue you mentioned, do you mean that indentation of the text marked in screenshot below is not consistent with your .txt file? Or if I misunderstood, please describe your problem in detail. Thank you in advance for your help.
screenshot.png


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Sun Sep 05, 2021 3:52 am

Yes, you got right. The indentation is not coming correctly in the pdf from text.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Mon Sep 06, 2021 7:04 am

Hello,

Thanks for your response.
I have posted it to our Dev team and they will further investigate whether this can be improved. If there is any update, we will let you know.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Sep 08, 2021 2:29 am

Hi Brian,

Thanks for the update. Please let me know if this can be fixed and with that the release of the new official version also so that I can update my supervisor.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Wed Sep 08, 2021 8:21 am

Hello,

Thanks for your patience.

After our further investigation, we found that many blank parts of your txt file are composed of variable-length tabs (as shown below). When using “File.ReadAllText()" to read your TXT file, all tabs are parsed as "\t" characters, but it will not contain any length information. And when our product processes the strings, it will calculate the interval distance of all “\t” characters according to the same rules. In other words, tabs of different lengths in your document will all be treated as the same length. So the final TxtToPDf.pdf has some unaligned text.
screenshot.png


We are sorry that due to the inability to get the length information of tabs, the PDF generated by our product cannot be exactly the same as your TXT file, hope you can understand.

If you have any other questions, please feel free to contact us.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Sep 09, 2021 3:11 am

Thanks Brian. I wanted to try and use Sprire.xls to treat this file as a tab separated file and convert it to an excel. I tried to add Spire.xls from the latest package, however it was erroring out when I was instantiating. Do you have a sample code which can read the tab separated text file which I provided earlier and convert it to an xls sheet?

Also I need the date of new official version as you told me that will be released last week itself.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Thu Sep 09, 2021 9:22 am

Hello,

Thanks for your response.
You can refer to the following code to convert a txt file to an excel file, but since some text in your TXT file is split by spaces, the generated Excel file cannot be exactly the same as the TXT file either. Hope you can understand.
Code: Select all
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];
            // AutoFit Column width
            sheet.AllocatedRange.AutoFitColumns();
            string str = File.ReadAllText(@"TestFile.TXT");
            string[] rows = str.Split(new string[]{"\n"}, StringSplitOptions.RemoveEmptyEntries);


            for (int i = 0; i < rows.Length; i++)
            {
                string[] cells = rows[i].Split(new string[] { "\t" }, StringSplitOptions.RemoveEmptyEntries);
                for (int j=0; j < cells.Length; j++)
                {
                    sheet.Rows[i].CellList[j].Text = cells[j];
                }
            }

            workbook.SaveToFile("result.xlsx",ExcelVersion.Version2016);


Besides, I only mentioned that we were able to provide you with a temporary version of Spire.Office last week, not the official version. I got news from our Test team that since the fix of SPIREPDF-4553 had some impacts on other cases, our developers need to solve these impacts first. Therefore, it will take some time before the official version can be released. Sorry for the delay and inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Sep 10, 2021 2:09 am

Hi Brian,

I might have found a work around for my issue with some specific text files with abnormal tabs. So instead of PDF I decided to covert the text file to docx using Spire.doc and then transform it to image.

Please see the code snippet below and apply it to the sample file I posted earlier.

Document doc = new Document();
doc.LoadFromFile(@"C:\Test\TestFile.txt");
foreach (Section section in doc.Sections)
{
foreach (Paragraph par in section.Paragraphs)
{
par.Format.HorizontalAlignment = HorizontalAlignment.Justify;
ParagraphStyle style = new ParagraphStyle(doc);
style.CharacterFormat.FontName = "Courier New";
style.CharacterFormat.FontSize = 10;
style.CharacterFormat.Bold = true;
doc.Styles.Add(style);
par.ApplyStyle(style.Name);
}
}
doc.SaveToFile("C:\\Test\\Result-Fulldocbold10.docx", Spire.Doc.FileFormat.Docx);


So all our client testing would be complete by a day and we have to prepare for Prod release. Please let me know when your team is ready with the latest release.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Fri Sep 10, 2021 7:03 am

Okay, if the official version of Spire.Office is relased, we will inform you immediately,

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Sep 13, 2021 3:35 am

Thanks Brian for your response. All ready for my release and waiting for your official version of Spire.Office.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Thu Sep 16, 2021 2:09 pm

Brian, Please let me know if there is any update on this?

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Fri Sep 17, 2021 10:45 am

Hello,

Thanks for your follow up.
Our latest release of Spire.Office Platinum (Hotfix) Version: 6.9.1 already contains the fix of the issue SPIREPDF-4553. Please download and test it on your side. Looking forward to your test result.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Tue Sep 21, 2021 3:16 am

Hi Brian,

I tested and it looks good. But waiting for the client output on the results.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Return to Spire.PDF

cron