Spire.PDF 10.4.7 supports retrieving the font formatting of found text

Spire.PDF 10.4.7 supports retrieving the font formatting of found text

2024-04-24 07:15:15

We're pleased to announce the release of Spire.PDF 10.4.7. This version supports retrieving the font formatting of found text, and adds a progress callback interface for saving documents. Moreover, the issues that occurred when converting, loading and saving PDF files have also been successfully fixed. More details are listed below.

Here is a list of changes made in this release

Category ID Description
New feature SPIREPDF-2422
SPIREPDF-6640
Supports retrieving the font formatting of found text.
Note: Only supports retrieving bold, faux bold (font style set to fill and stroke), italic, and color; does not support retrieving underline.
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
PdfPageBase page = pdf.Pages[0];
PdfTextFinder finds = new PdfTextFinder(page);
finds.Options.Parameter = TextFindParameter.None;
List<PdfTextFragment> result = finds.Find("hello");
StringBuilder str = new StringBuilder();
foreach (PdfTextFragment find in result)
{
	string text = find.LineText;
	string FontName = find.TextStates[0].FontName;
	float FontSize = find.TextStates[0].FontSize;
	string FontFamily = find.TextStates[0].FontFamily;
	bool IsBold = find.TextStates[0].IsBold;
	bool IsSimulateBold = find.TextStates[0].IsSimulateBold;
	bool IsItalic = find.TextStates[0].IsItalic;
	Color color = find.TextStates[0].ForegroundColor;
	str.AppendLine(text);
	str.AppendLine("FontName: " + FontName);
	str.AppendLine("FontSize: " + FontSize);
	str.AppendLine("FontFamily: " + FontFamily);
	str.AppendLine("IsBold: " + IsBold);
	str.AppendLine("IsSimulateBold: " + IsSimulateBold);
	str.AppendLine("IsItalic: " + IsItalic);
	str.AppendLine("color: " + color);
	str.AppendLine(" ");
}
PdfTextReplacer ptr = new PdfTextReplacer(page);
ptr.ReplaceAllText("hello", "New");
File.WriteAllText(outputFile_T, str.ToString());
pdf.SaveToFile(outputFile);
pdf.Dispose();
New feature SPIREPDF-6602 Adds a progress callback interface for saving documents.
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
pdf.RegisterProgressNotifier(new CustomProgressNotifier());
pdf.SaveToFile(outputFile, FileFormat.XPS);
pdf.Close();

public class CustomProgressNotifier :IProgressNotifier
{
	StringBuilder str = new StringBuilder();
	public void Notify(float progress)
	{
		str.AppendLine(progress + "%");
		File.WriteAllText(outputFile_txt, str.ToString());
	}
}
Bug SPIREPDF-6626 Fixes the issue that the content was lost when converting PDF documents to images.
Bug SPIREPDF-6627 Fixes the issue that it failed to draw text containing the "∙" (unicode = 8729) character on a PDF page.
Bug SPIREPDF-6634 Fixes the issue that the application threw "System.NullReferenceException" when printing grayscale PDF documents.
Bug SPIREPDF-6635 Fixes the issue that the application threw "System.ArgumentNullException" when converting grayscale PDF documents.
Bug SPIREPDF-6636 Fixes the issue that the verification results were incorrect when using signatureOne.VerifySignature() method to verify digital signatures.
Bug SPIREPDF-6639 Fixes the issue that the images were lost when converting XPS documents to PDF documents.
Bug SPIREPDF-6641
SPIREPDF-6645
Fixes the issue that the application threw "System.NullReferenceException" when converting OFD documents to PDF documents.
Bug SPIREPDF-6656 Fixes the issue that the signatures were invalid after loading and saving PDF documents.
Bug SPIREPDF-6660 Fixes the issue that the application threw "System.ArgumentException" when converting OFD documents to PDF documents.
Bug SPIREPDF-6673 Fixes the issue that the application threw "System.ArgumentNullException" during finding text.
Click the link to download Spire.PDF 10.4.7:
More information of Spire.PDF new release or hotfix: