Accessibility
Starting in version 8.4, Foxit PDF SDK supports tagging PDF files.
System Requirements
- Platforms: Windows, Mac, and Linux
- Languages: C, C++, Java, C#, Python, Objective-C, Node.js, and Go
- License: A license key that includes the
Accessibilitymodule - SDK versions:
- Foxit PDF SDK (C, C++, C#, Java, Python, Objective-C) 8.4+
- Foxit PDF SDK (Node.js) 10.0+
- Foxit PDF SDK (Go) 11.0+
Tag a PDF Document
In the \examples\simple_demo\taggedpdf folder, Foxit PDF SDK provides a sample that demonstrates how to tag a PDF document with Foxit PDF SDK.
c++
#include "include/common/fs_common.h"
#include "include/pdf/fs_pdfdoc.h"
#include "include/pdf/fs_pdfpage.h"
#include "include/addon/accessibility/fs_taggedpdf.h"
using namespace std;
using namespace foxit;
using namespace foxit::common;
using foxit::common::Library;
using namespace pdf;
using namespace foxit::addon::accessibility;
...
PDFDoc pdfDoc(input_file);
pdfDoc.Load();
TaggedPDF taggedpdf(pdfDoc);
Progressive progressive = taggedpdf.StartTagDocument(NULL);
Progressive::State progressState = Progressive::e_ToBeContinued;
while (Progressive::e_ToBeContinued == progressState)
progressState = progressive.Continue();
pdfDoc.SaveAs(output_file_path);
...C
#include "include/fs_basictypes_c.h"
#include "include/fs_common_c.h"
#include "include/fs_pdfdoc_c.h"
#include "include/fs_pdfpage_c.h"
#include "include/fs_search_c.h"
#include "include/fs_convert_c.h"
#include "include/fs_taggedpdf_c.h"
...
FS_PDFDOC_HANDLE pdf_doc;
FSDK_PDFDoc_Create0(input_file, &pdf_doc);
FSDK_PDFDoc_Load(pdf_doc, NULL);
FS_TAGGEDPDF_HANDLE tagged_pdf;
error_code = FSDK_TaggedPDF_Create(pdf_doc, &tagged_pdf);
FS_PROGRESSIVE_HANDLE progressive;
FSDK_TaggedPDF_StartTagDocument(tagged_pdf, NULL, &progressive);
FSState progressive_state = e_FSToBeContinued;
while (progressive_state == e_FSToBeContinued)
FSDK_Progressive_Continue(progressive, &progressive_state);
FS_BOOL return_value = false;
error_code = FSDK_PDFDoc_SaveAs(pdf_doc, output_file, 0, &return_value);
FSDK_TaggedPDF_Release(tagged_pdf);
FSDK_PDFDoc_Release(pdf_doc);
...java
import com.foxit.sdk.common.Progressive;
import com.foxit.sdk.pdf.PDFDoc;
import com.foxit.sdk.addon.accessibility.*;
import com.foxit.sdk.common.fxcrt.RectF;
....
PDFDoc pdfDoc= new PDFDoc(input_file);
pdfDoc.load(null);
TaggedPDF taggedpdf = new TaggedPDF(pdfDoc);
Progressive progressive = taggedpdf.startTagDocument(null);
int progressState = Progressive.e_ToBeContinued;
while (Progressive.e_ToBeContinued == progressState)
progressState = progressive.resume();
pdfDoc.saveAs(output_file_path, 0);
....py
import sys
import site
if sys.version_info.major == 2:
_PYTHON2_ = True
else:
_PYTHON2_ = False
if _PYTHON2_:
site.addsitedir('../../../')
from FoxitPDFSDKPython2 import *
else:
from FoxitPDFSDKPython3 import *
....
pdfDoc = PDFDoc(input_file)
pdfDoc.Load("")
taggedpdf = TaggedPDF(pdfDoc)
progressive = taggedpdf.StartTagDocument(None)
progressState = Progressive.e_ToBeContinued
while (Progressive.e_ToBeContinued == progressState):
progressState = progressive.Continue()
pdfDoc.SaveAs(output_file_path, PDFDoc.e_SaveFlagNoOriginal)objc
#include "FSPDFObjC.h"
...
FSPDFDoc* doc = [[FSPDFDoc alloc] initWithPath:inputFile];
FSErrorCode errorCode = [doc load:nil];
if (errorCode != FSErrSuccess) {
NSLog(@"The Doc [%@] Error: %ld", inputFile, errorCode);
return -1;
}
FSTaggedPDF* taggedpdf = [[FSTaggedPDF alloc] initWithDoc:doc];
FSProgressive* progressive = [taggedpdf startTagDocument:nil];
while([progressive resume] == FSProgressiveToBeContinued){
;
}
[doc saveAs:outputFile save_flags:FSPDFDocSaveFlagNoOriginal];
...js
const FSDK = require("@fuxinsoft/foxit-pdf-sdk-node");
...
let pdfDoc = new FSDK.PDFDoc(input_file);
pdfDoc.Load("");
let taggedpdf = new FSDK.TaggedPDF(pdfDoc);
let progressive = taggedpdf.StartTagDocument(null);
let progressState = FSDK.Progressive.e_ToBeContinued;
while (FSDK.Progressive.e_ToBeContinued == progressState)
progressState = progressive.Continue();
pdfDoc.SaveAs(output_file_path, FSDK.PDFDoc.e_SaveFlagNormal);csharp
using foxit.common;
using foxit.common.fxcrt;
using foxit.addon.conversion;
using foxit.pdf;
using foxit.addon.accessibility;
...
using(pdf_doc=newPDFDoc(input_file))
{
pdf_doc.Load(null);
using(vartaggedpdf=newTaggedPDF(pdf_doc))
{
Progressiveprogressive=taggedpdf.StartTagDocument(null);
Progressive.Statestate=Progressive.State.e_ToBeContinued;
while(state==Progressive.State.e_ToBeContinued)
{
state=progressive.Continue();
}
}
pdf_doc.SaveAs(output_file,0);
}
...go
import (
. "foxit.com/fsdk"
)
....
pdfDoc := NewPDFDoc(input_file)
pdfDoc.Load("")
taggedpdf := NewTaggedPDF(pdfDoc)
progressive := taggedpdf.StartTagDocument()
progressState := ProgressiveE_ToBeContinued
for (ProgressiveE_ToBeContinued == progressState){
progressState = progressive.Continue()
}
pdfDoc.SaveAs(output_file_path, uint(PDFDocE_SaveFlagNoOriginal))