Save document
Foxit PDF SDK for iOS supports multiple save modes, including synchronous save and save to custom output streams. Use Core SDK (FSPDFDoc) or FSPDFViewCtrl depending on your scenario.
Save via FSPDFDoc
Synchronous save
objc
[doc saveAs:outputPath saveFlags:FSPDFDocSaveFlagNormal];Asynchronous save (progressive)
For large files; use with FSPauseCallback for pause/resume:
objc
FSProgressive *progressive = [doc startSaveAs:outputPath
saveFlags:FSPDFDocSaveFlagNormal
pause:nil];
FSProgressState state = FSProgressiveToBeContinued;
while (state == FSProgressiveToBeContinued) {
state = [progressive resume];
}Save to custom output stream
Implement FSFileWriterCallback:
objc
FSProgressive *progressive = [doc startSaveAs:fileWriterCallback
saveFlags:FSPDFDocSaveFlagNormal
pause:nil];
FSProgressState state = FSProgressiveToBeContinued;
while (state == FSProgressiveToBeContinued) {
state = [progressive resume];
}Save flags
| Constant | Description |
|---|---|
FSPDFDocSaveFlagNormal | Normal save |
FSPDFDocSaveFlagIncremental | Incremental save (append changes only; faster) |
FSPDFDocSaveFlagNoOriginal | Do not preserve original data (full rewrite) |
FSPDFDocSaveFlagXRefStream | Use cross-reference stream (XRef Stream) |
FSPDFDocSaveFlagRemoveRedundantObjects | Remove redundant objects (smaller file) |
FSPDFDocSaveFlagLinearized | Linearized save (optimized for web viewing) |
Combine flags with |:
objc
[doc saveAs:outputPath
saveFlags:FSPDFDocSaveFlagIncremental | FSPDFDocSaveFlagRemoveRedundantObjects];Save via FSPDFViewCtrl
UI-oriented save APIs:
objc
// Save to file path
[pdfViewCtrl saveDoc:filePath flag:FSPDFDocSaveFlagNormal];
// Save to custom output stream
[pdfViewCtrl saveDocToFileWriter:fileWriterCallback flag:FSPDFDocSaveFlagNormal];Complete example
objc
FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:inputPath];
[doc load:nil];
// ... modify document ...
// Incremental save to new file
[doc saveAs:outputPath saveFlags:FSPDFDocSaveFlagIncremental];API reference
See the API reference for FSPDFDoc.