0

I just want to edit PDFPage text , user click on edit button a box will be shown on each textBox rect and when user touch on any box then its text will be start editing and user able to remove all text and replace it with new one.

Here is my pdf page and i am currently using PDFKit in swift 4.
For batter understanding.

Here is some reference Images of FoxitPDF Reader. Hopefully it will be helpful.
1

2

3

Abu Ul Hassan
  • 1,340
  • 11
  • 28
Jawad Ali
  • 34
  • 3
  • Do you want to edit the text which you added ? Or you want to edit the text which is already there in the pdf? – Faheem Rahman Dec 13 '18 at 10:45
  • want to edit the text which is already there – Jawad Ali Dec 14 '18 at 11:07
  • That is not possible. Only the things which we have added can be editted. text can be highlighted or underlined or strike-out. We cannot change the text which is already there. Otherwise you will have to color the area of the text and then add new text over it. There is no built in service for this. – Faheem Rahman Dec 14 '18 at 11:15
  • PDF Expert , Foxit reader and PSDPDF app's are doing this... – Jawad Ali Jan 01 '19 at 05:36

1 Answers1

0

I think as follows. First of all, you need to get all strings of the page you want to edit from a PDF file.

if let pdf = PDFDocument(url: url) {
    let pageCount = pdf.pageCount
    let documentContent = NSMutableAttributedString()

    guard let page = pdf.page(at: "certain page") else { continue }
    guard let pageContent = page.attributedString else { continue }
    documentContent.append(pageContent)
}

And then you should show them on TextField or TextView when clicking the edit Button. So I think you can edit or remove the text you want. Finally you need to save the changes. I guess you know how can create a PDF with text so I'll not write about it. Hope it helps.

Miah G.
  • 129
  • 1
  • 7