because I want to be able to display the corresponding information in the corresponding position when generating the PDF
Like this
rxyc example.jpg (633.8 KB)
because I want to be able to display the corresponding information in the corresponding position when generating the PDF
Like this
rxyc example.jpg (633.8 KB)
This is the code sample you are looking for:
private void Logic()
{
var doc = new Document();
string content = "if you're looking for random paragraphs, you've come to the right place. When a random word or a random sentence isn't quite enough, the next logical step is to find a random paragraph. We created the Random Paragraph Generator with you in mind. The process is quite simple. Choose the number of random paragraphs you'd like to see and click the button. Your chosen number of paragraphs will instantly appear.\r\n\r\nWhile it may not be obvious to everyone, there are a number of reasons creating random paragraphs can be useful. A few examples of how some people use this generator are listed in the following paragraphs.\r\n\r\nIt's not only writers who can benefit from this free online tool. If you're a programmer who's working on a project where blocks of text are needed, this tool can be a great way to get that. It's a good way to test your programming and that the tool being created is working well.\r\n\r\nAbove are a few examples of how the random paragraph generator can be beneficial. The best way to see if this random paragraph picker will be useful for your intended purposes is to give it a try. Generate a number of paragraphs to see if they are beneficial to your current project.\r\n\r\nIf you do find this paragraph tool useful, please do us a favor and let us know how you're using it. It's greatly beneficial for us to know the different ways this tool is being used so we can improve it with updates. This is especially true since there are times when the generators we create get used in completely unanticipated ways from when we initially created them. If you have the time, please send us a quick note on what you'd like to see changed or added to make it better in the future.";
var page = doc.Pages.Add();
int columnSpacing = 40;
page.PageInfo.Margin = new MarginInfo(30, 50, 30, 50);
var colummWidth = (page.PageInfo.Width - (page.PageInfo.Margin.Left + page.PageInfo.Margin.Right + columnSpacing)) / 2;
FloatingBox floatingBox = new FloatingBox();
var columnInfo = new ColumnInfo();
columnInfo.ColumnCount = 2;
columnInfo.ColumnSpacing = columnSpacing.ToString();
columnInfo.ColumnWidths = string.Join(" ", new double[2] { colummWidth, colummWidth });
floatingBox.ColumnInfo = columnInfo;
floatingBox.Height = page.PageInfo.Height - (page.PageInfo.Margin.Top + page.PageInfo.Margin.Bottom);
// Just to generate more text
for (int i = 0; i < 20; i++)
{
TextFragment fragment = new TextFragment(content);
fragment.TextState.HorizontalAlignment = HorizontalAlignment.Justify;
floatingBox.Paragraphs.Add(fragment);
}
page.Paragraphs.Add(floatingBox);
doc.Save($"{PartialPath}_output.pdf");
}
This is the output:
TextInTwoColumns_output.pdf (121.0 KB)
Hello Thank you very much for your reply
I would like to get the block position of the text as shown in the picture
QQ截图20230420210521.jpg (221.4 KB)
You turn each of those blocks into a paragraph. To mimic the looks, you must have the same column width, font, font size, spacing, etc.
Thank you very much for your reply
Do you have a demo I can refer to?
But you can use my code as a reference and use the documentation about the Text fragments(documentation) to make the changes I mentioned. My job is to guide you and give you the tools to achieve your needs. And that is what I did.