How to save matched regex text to pdf file?

Is it possible to save extracted text from pdf to new pdf ? if the answer is yes , can you please tell me how to achieve it.Till now i extracted my desired output from pdf file but i have to save it as pdf file.I am stuck right now,it will be helpful if anyone guide me/tell me how to achieve it.
Note: I don’t want to save the output in word and then convert it as pdf because it loses the styles when i save it in word.

1 Like

Hey @check_account

What’s the style you want to apply if you can show that please ?

Thanks
#nK

Hello @check_account

Can you write that data to a word file and then convert it to pdf. You can use Word package to achieve this.

Create the bookark in the static word template and then write to it using word activities. Can refer to the below video.

Hi @check_account,

Create a word template. The label fields you specify in this template must be in the styles you want.

Then read the pdf and replace each value you read with the appropriate places in your word template.

This way you won’t lose both variables and styles.

Regards,
MY

can you give me some examples? or screenshot of word template?

Hi @check_account here is a code from spire pdf that might do the job for you. The below code finds a text and highlights in another document and the style does not change in new document . here i highlighted you can write text at particular location instead. Use page.Canvas .DrawString to write a text in particular location
Using pdf As New PdfDocument()
pdf.LoadFromFile(“input file”)
Dim result As Spire.Pdf.General.Find.PdfTextFind()= Nothing
For Each page As PdfPageBase In pdf.Pages
result = page.FindText(“the text u want to find”).Finds
For Each find As Spire.Pdf.General.Find.PdfTextFind In result
find.ApplyHighLight()
Next
Next
pdf.SaveToFile(“result.pdf”,FileFormat.PDF)

End Using