Определение переноса строк
Следующий фрагмент кода также работает с библиотекой Aspose.PDF.Drawing .
Отслеживание переноса строк многострочного TextFragment
Aspose.PDF for .NET предлагает ведение журнала (отслеживание) фоновой обработки (перенос строк) многострочных текстовых фрагментов в сценариях добавления текста. Вы можете использовать метод GetNotifications () класса Page следующим образом, чтобы отслеживать перенос строк текстового фрагмента:
.NET Core 3.1
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DetermineLineBreak ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_Text ();
// Create PDF document
using ( var document = new Aspose . Pdf . Document ())
{
// Enable notification logging
document . EnableNotificationLogging = true ;
Aspose . Pdf . Page page = document . Pages . Add ();
for ( int i = 0 ; i < 4 ; i ++)
{
var text = new Aspose . Pdf . Text . TextFragment ( "Lorem ipsum \r\ndolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." );
text . TextState . FontSize = 20 ;
page . Paragraphs . Add ( text );
}
// Save PDF document
document . Save ( dataDir + "DetermineLineBreak_out.pdf" );
string notifications = document . Pages [ 1 ]. GetNotifications ();
File . WriteAllText ( dataDir + "notifications_out.txt" , notifications );
}
}
.NET 8
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void DetermineLineBreak ()
{
// The path to the documents directory
var dataDir = RunExamples . GetDataDir_AsposePdf_Text ();
// Create PDF document
using var document = new Aspose . Pdf . Document ();
// Enable notification logging
document . EnableNotificationLogging = true ;
Aspose . Pdf . Page page = document . Pages . Add ();
for ( int i = 0 ; i < 4 ; i ++)
{
var text = new Aspose . Pdf . Text . TextFragment ( "Lorem ipsum \r\ndolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." );
text . TextState . FontSize = 20 ;
page . Paragraphs . Add ( text );
}
// Save PDF document
document . Save ( dataDir + "DetermineLineBreak_out.pdf" );
string notifications = document . Pages [ 1 ]. GetNotifications ();
File . WriteAllText ( dataDir + "notifications_out.txt" , notifications );
}