0

I am using pspdfkit to add few text annotations via the viewer. After adding the annotations I want to change their contents when the user clicks save button, and then save the pdf. I am not sure how to save the original pdf and also if I want to create a copy of it ?

This is how I get the doc and change the annotations text.

        var doc = PdfView.Controller.GetPdfDocument();
        var annots =await doc.GetAnnotationsAsync(0);
        //I am assuming all my anotations are text (just for testing)
        foreach (IAnnotation item in annots)
        {
            ((Text)item).Contents = "Changed content"; 
        }

I can export it using

 await pdfView.Document.ExportAsync(dataWriter);

but how to create dataWriter from the doc.

Help will be appreciated.

thanks

Parminder
  • 3,088
  • 6
  • 37
  • 61
  • Should it be a "StorageFile" instead of a "DataWriter"? https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefile ? – Hoai Dam Aug 24 '18 at 03:39
  • the dataWriter object requirement is pspdfkit – Parminder Aug 24 '18 at 03:45
  • Then it depends on the target where you want to save the PDF, you will instantiate the DataWriter with the corresponding IOutputStream (e.g. FileOutputStream, InMemoryRandomAccessStream ...). The documentation is pretty straightforward here https://learn.microsoft.com/en-us/uwp/api/windows.storage.streams.datawriter.-ctor#Windows_Storage_Streams_DataWriter__ctor_Windows_Storage_Streams_IOutputStream_ – Hoai Dam Aug 24 '18 at 03:57

0 Answers0