ConsoleApp2.zip (240.4 KB)
Hello I have encountered 2 problems when using Chinese to generate PDF
-
there is a hyphen after each sentence
-
the right side cannot be aligned
but I use the English effect is very good
My code is
// Open document
Document doc = new Document();
// Add page to pages collection of Document object
Page page = doc.Pages.Add();
TextBuilder builder = new TextBuilder(page);
// Create text paragraph
TextParagraph paragraph = new TextParagraph();
// Set subsequent lines indentparagraph.VerticalAlignment= VerticalAlignment.Top; paragraph.HorizontalAlignment= HorizontalAlignment.FullJustify; paragraph.Justify = true; paragraph.FormattingOptions.HyphenSymbol = string.Empty; // Specify the location to add TextParagraph paragraph.Rectangle = new Aspose.Pdf.Rectangle(100, 600, 400, 200); // Specify word wraping mode paragraph.FormattingOptions.WrapMode = TextFormattingOptions.WordWrapMode.ByWords; // Create text fragment TextFragment fragment1 = new TextFragment("文学,在广义上,是任何单一的书面作品,I’m trying to create a TextParagraph object 或用文字写作来传达思想、表达情感、发挥想像的所有著作,此时又称文学作品。文学写作则是一种艺术形式,或被认为具有艺术或智力价值的任何单一作品,通常是由于以不同于普通用途的方式部ph(); paragraph.Rectangle = new Rec署语言。中国先秦时期将以文字写成的作品都统称为文学,魏晋以后才逐渐将文学作品单独列出。在现代,则通常将文学分为韵文、散文、剧本、小说四大类别,是文化的重要表现形式,以不同的流派表现内心情感和再现一定时期和一定地域的生w, but nothing worked: paragra活。这个概念,又随著时间的推移而改变了意义:现在它可以扩大到非书面的口头艺术形式,可以与语言或文字本身de.ByWords;var textBuilder = new TextBuilder(page); tex配合,因此很难就其起源达成一致。印刷技术的发展使得书面作品的分布和扩散成为可能,最终导致了网络文学。"); // Add fragment to paragraph fragment1.TextState.HorizontalAlignment = HorizontalAlignment.Right; paragraph.AppendLine(fragment1); // Add paragraph builder.AppendParagraph(paragraph); // Save resulting PDF document. doc.Save("test.pdf");
QQ截图20230422163804.jpg (91.6 KB)