#1 PDF Brand
PDF Software and Tools Tailored to your Business
Over half a billion users choose award–winning Foxit products to achieve their paperless office strategy.
Foxit PDF SDK
The high-performance libraries, using the most popular developer languages and environments, add robust PDF functionality to enterprise, mobile, and cloud applications across all platforms.
C++
using namespace std;
using namespace foxit;
using namespace foxit::common;
using foxit::common::Library;
using namespace pdf;
using namespace annots;
using foxit::pdf::annots::Line;
// Create a blank document
PDFDoc doc = PDFDoc();
// Add a blank A4 page to the document
PDFPage page = doc.InsertPage(0, 595, 842);
// Create a note annotation
annots::Note note(page.AddAnnot(Annot::e_Note, RectF(10, 350, 50, 400)));
// Set note annotation properties
note.SetIconName(“Comment”);
note.SetSubject(L”Note”);
note.SetTitle(L”Foxit SDK”);
note.SetContent(L”Note annotation.”);
note.SetCreationDateTime(GetLocalDateTime());
note.SetModifiedDateTime(GetLocalDateTime());
note.SetUniqueID(WString::FromLocal(RandomUID()));
// Add state annotation to note annotation
Note state = note.AddStateAnnot(Markup::e_StateModelReview, Markup::e_StateAccepted);
state.SetContent(L”Accepted set by Foxit SDK”);
state.SetTitle(L”Foxit SDK”);
state.SetModifiedDateTime(GetLocalDateTime());
state.SetUniqueID(WString::FromLocal(RandomUID()));
state.ResetAppearanceStream();
// Appearance should be reset.
note.ResetAppearanceStream();
cout << “Add a note annotation.” << endl;
// Save PDF file
C#
using foxit;
using foxit.common;
using foxit.common.fxcrt;
using foxit.pdf;
using foxit.pdf.annots;
using (PDFDoc doc = new PDFDoc())
{
// Add a blank A4 page to the document
PDFPage page = doc.InsertPage(0, 595, 842);
// Get first page with index 0
using (PDFPage page = doc.GetPage(0))
{
// Add note annotation
Note note = null;
Annot annot = null;
using (annot = page.AddAnnot(Annot.Type.e_Note, new RectF(10, 350, 50, 400)))
using (note = new Note(annot))
{
note.SetIconName(“Comment”);
note.SetSubject(“Note”);
note.SetTitle(“Foxit SDK”);
note.SetContent(“Note annotation.”);
note.SetCreationDateTime(GetLocalDateTime());
note.SetModifiedDateTime(GetLocalDateTime());
note.SetUniqueID(RandomUID());
}
// Add state annotation to note annotation
using (Note state = note.AddStateAnnot(Markup.StateModel.e_StateModelReview, Markup.State.e_StateAccepted))
{
state.SetContent(“Accepted set by Foxit SDK”);
state.SetTitle(“Foxit SDK”);
state.SetModifiedDateTime(GetLocalDateTime());
state.SetUniqueID(RandomUID());
state.ResetAppearanceStream();
// Appearance should be reset.
note.ResetAppearanceStream();
Console.WriteLine(“Add a note annotation.”);
}
// Save PDF file
String newPdf = output_path + “annotation.pdf”;
doc.SaveAs(newPdf, (int)PDFDoc.SaveFlags.e_SaveFlagNoOriginal);
Objective-C
// Create a new document
FSPDFDoc* doc = [[FSPDFDoc alloc] init];
// Set a blank page width and height and add to document
floatw =612.0;floath =792.0;
FSPDFPage* page = [doc insertPage:index width:w height:h];
// Add note annotation
FSRectF* annot_rect = [[FSRectF alloc] initWithLeft1:10 bottom1:350 right1:50 top1:400];
FSNote* note = [[FSNote alloc] initWithAnnot:[page addAnnot:FSAnnotNote rect:annot_rect]];
// Set some properties for the annotation
[note setIconName:@”Comment”];
[note setSubject:@”Note”];
[note setTitle:@”Foxit SDK”];
[note setContent:@”Note annotation.”];
// Reset Appearance
[note resetAppearanceStream];
NSLog(@”Add a note annotation.”);
// Save PDF file
NSString* save_pdf_path = [output_directory stringByAppendingPathComponent:@”annotation.pdf”];
[doc saveAs:save_pdf_path save_flags
Objective-C
#import “AppDelegate.h”
#import <UIKit/UIKit.h>
@implementation AppDelegate
– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *sn = @”your-licence-key-signature”;
NSString *key = @”your-licence-here”;
FSErrorCode eRet = [FSLibrary initialize:sn key:key];
if (FSErrSuccess != eRet) {
NSLog(@”License Key Invalid”);
}
return YES;
}
Java
import com.foxit.sdk.common.Library;
import com.foxit.sdk.common.fxcrt.RectF;
import com.foxit.sdk.pdf.PDFDoc;
import com.foxit.sdk.pdf.PDFPage;
import com.foxit.sdk.pdf.annots.Note;
// Load a document
PDFDoc doc = new PDFDoc();
// Get first page with index 0
PDFPage page = doc.insertPage(0, 595, 842);
// Add note annotation
Note note = new Note(page.addAnnot(Annot.e_Note, new RectF(10, 350, 50, 400)));
//This flag is used for printing annotations.
note.setFlags(4);
note.setIconName(“Comment”);
note.setSubject(“Note”);
note.setTitle(“Foxit SDK”);
note.setContent(“Note annotation.”);
note.setCreationDateTime(GetLocalDateTime());
note.setModifiedDateTime(GetLocalDateTime());
note.setUniqueID(RandomUID());
// Add state annotation to note annotation
Note state = new Note(note.addStateAnnot(“Foxit SDK”, Markup.e_StateModelReview, Markup.e_StateAccepted));
state.setContent(“Accepted set by Foxit SDK”);
state.setUniqueID(RandomUID());
// Appearance should be reset.
note.resetAppearanceStream();
System.out.println(“Add a note annotation.”);
Java
import com.foxit.sdk.PDFException;
import com.foxit.sdk.common.Library;
import java.io.File;
import static com.foxit.sdk.common.Constants.e_ErrSuccess;
import static com.foxit.sdk.pdf.PDFDoc.e_SaveFlagNoOriginal;
public static void main(String[] args) throws PDFException {
// Initialize library
int error_code = Library.initialize(sn, key);
if (error_code != e_ErrSuccess) {
System.out.println(“Library Initialize Error: ” + error_code);
return;
}
Java
import com.foxit.sdk.PDFViewCtrl;
import com.foxit.sdk.common.Constants;
import com.foxit.sdk.common.fxcrt.RectF;
import com.foxit.sdk.common.fxcrt.RectFArray;
import com.foxit.sdk.pdf.PDFDoc;
import com.foxit.sdk.pdf.PDFPage;
import com.foxit.sdk.pdf.TextSearch;
import com.foxit.sdk.pdf.annots.Annot;
import com.foxit.sdk.pdf.annots.Note;
import com.foxit.sdk.pdf.annots.QuadPoints;
import com.foxit.sdk.pdf.annots.QuadPointsArray;
import com.foxit.sdk.pdf.annots.TextMarkup;
import com.foxit.sdk.common.fxcrt.PointF;
// Define path
String pdfpath = “xxx/Sample.pdf”;
// Create PDF from scratch
PDFDoc doc = new PDFDoc(pdfpath);
doc.load(null);
// Get first page of document
PDFPage pdfPage = doc.getPage(1);
// Create rectangle
RectF rect = new RectF(100, 100, 120, 120);
Note note = new Note(pdfPage.addAnnot(Annot.e_Note, rect));
note.setIconName(“Comment”);
// Set border color to blue
note.setBorderColor(0xff0000ff);
// Add some content
note.setContent(“Foxit PDF SDK”);
// Reset appearance
Java
package com.foxit;
import android.content.Context;
import android.os.Environment;
import com.foxit.home.R;
import com.foxit.pdfreader.MultiTabView;
import com.foxit.pdfreader.fragment.AppTabsManager;
import com.foxit.sdk.common.Constants;
import com.foxit.sdk.common.Library;
import com.foxit.uiextensions.controls.toolbar.IBaseItem;
import com.foxit.uiextensions.home.local.LocalModule;
import com.foxit.uiextensions.utils.UIToast;
import java.io.File;
import java.util.HashMap;
public class App {
private static String sn = “your license key signature”;
private static String key = “your license key”;
private Context mContext;
private int errCode = Constants.e_ErrSuccess;
private static App INSTANCE = new App();
public static App instance() {
return INSTANCE;
}
private App(){
errCode = Library.initialize(sn, key);
}
public boolean checkLicense(){
switch (errCode) {
case Constants.e_ErrSuccess:
break ;
case Constants.e_ErrInvalidLicense:
UIToast.getInstance(mContext).show(mContext.getString(R.string.fx_the_license_is_invalid));
return false;
default:
UIToast.getInstance(mContext).show(mContext.getString(R.string.fx_failed_to_initialize_the_library));
return false;
}
return true;
Objective-C
// Create a new document
FSPDFDoc* doc = [[FSPDFDoc alloc] init];
// Set a blank page width and height and add to document
floatw =612.0;floath =792.0;
FSPDFPage* page = [doc insertPage:index width:w height:h];
// Add note annotation
FSRectF* annot_rect = [[FSRectF alloc] initWithLeft1:10 bottom1:350 right1:50 top1:400];
FSNote* note = [[FSNote alloc] initWithAnnot:[page addAnnot:FSAnnotNote rect:annot_rect]];
// Set some properties for the annotation
[note setIconName:@”Comment”];
[note setSubject:@”Note”];
[note setTitle:@”Foxit SDK”];
[note setContent:@”Note annotation.”];
// Reset Appearance
[note resetAppearanceStream];
NSLog(@”Add a note annotation.”);
// Save PDF file
NSString* save_pdf_path = [output_directory stringByAppendingPathComponent:@”annotation.pdf”];
[doc saveAs:save_pdf_path save_flag
Objective-C
#import “AppDelegate.h”
#import <UIKit/UIKit.h>
@implementation AppDelegate
– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSString *sn = @”your-licence-key-signature”;
NSString *key = @”your-licence-here”;
FSErrorCode eRet = [FSLibrary initialize:sn key:key];
if (FSErrSuccess != eRet) {
NSLog(@”License Key Invalid”);
}
return YES;
}
C++
//Render the pdf page, then save it to a bitmap file.
void FunctionDemo::MainPage::render_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
StorageFolder^ documentFolder = Windows::Storage::KnownFolders::DocumentsLibrary;
std::shared_ptr spBitmap = std::make_shared(nullptr);
create_task(documentFolder->GetFileAsync(“FoxitBigPreview.pdf”)).then([=](StorageFile^ file) {
try
{
m_doc = ref new FSPDFDoc(file, 0);
if (!m_doc)
{
return;
}
FSErrorCode code = m_doc->Load(“”);
if (code != FSErrorCode::e_errSuccess) {
return;
}
FSPDFPage^ page = m_doc->GetPage(0);
if (!page->IsParsed())
{
page->StartParse(0, nullptr, false);
}
//create bitmap
int pageWidth = (int)page->GetWidth();
int pageHeight = (int)page->GetHeight();
*spBitmap = ref new FSBitmap(pageWidth, pageHeight, FSDIBFormat::e_dibRgb32, nullptr, 0);
if (!(*spBitmap)) {
return;
}
(*spBitmap)->FillRect(0xffffffff, nullptr);
//init renderer
FSRenderer^ render = ref new FSRenderer((*spBitmap), false);
if (!render) {
return;
}
//set different kinds of properties
render->SetRenderContentFlags((int)FSRenderContentFlag::e_renderPage);
render->SetTransformAnnotIcon(true);
render->SetColorMode(FSRenderColorMode::e_colorModeNormal);
render->SetForceHalftone(true);
FSMatrix^ matrix = page->GetDisplayMatrix(0, 0, pageWidth, pageHeight, FSRotation::e_rotation0);
render->StartRender(page, matrix, nullptr);
}
catch (Platform::Exception^ e)
{
OutputDebugString(e->Message->Data());
}
}).then([=]()
{
return documentFolder->CreateFileAsync(“Output_Render.bmp”, CreationCollisionOption::ReplaceExisting);
}).then([=](StorageFile^ file)
{
FSImage^ img = ref new FSImage();
img->AddFrame((*spBitmap));
if(img->SaveAs(file, “bmp”))
this->showMesseageDialog(“”, “The output file is saved to:” + file->Path);
else
this->showMesseageDialog(“”, “error!”);
});
JavaScript
// Add the script below to your javascript file to initialize the viewer
// Replace “window.demoLicenseKey” with your license key
// And replace ‘doc’ with the path to the PDF file you wish to load
var docViewerId = ‘docViewer’;
$(document).ready(function(){
var optionsParams = {
language: window.getLanguage(),
toolbarConfig: window.toolbarConfig,
fontUrl: ‘http://webpdf.foxitsoftware.com/webfonts/’,
licenseKey: window.demoLicenseKey,
};
WebPDF.ready(docViewerId, options, false).then(function(){
openDocument();
});
function openDocument(){
var fileurl = WebPDF.baseUrl + ‘doc’;
var openFileParams = {
url: fileurl,
fileId: fileurl
};
WebPDF.ViewerInstance.openFileByUri(openFileParams).catch(function(error) {
console.log(error);
});}
});
ROBUST FUNCTIONALITY
Foxit PDF SDK Features
Viewing & rendering
Our core API provides for high-fidelity rendering of PDF documents with optimized performance for desktop and mobile platforms.
Full-text search
Fast full-text search for any PDF document, language, or encoding type. The SQLite-based full-text search delivers near-instant results, even for repositories on any digital device.
Rights management
Our PDF SDK can generate secure PDFs with native encryption and decryption, or integrate with customized DRM or IRM security systems. Our technology integrates with Microsoft RMS.
Plug-Ins & Open Source Solutions
CORDOVA SUPPORT
We provide sample projects, demos, API docs and more for every single feature in the PDF SDK to get you up to speed quickly.
KOTLIN SUPPORT
We provide sample projects, demos, API docs and more for every single feature in the PDF SDK to get you up to speed quickly.
REACT NATIVE SUPPORT
We provide sample projects, demos, API docs and more for every single feature in the PDF SDK to get you up to speed quickly.
WEBPDF.JS VIEWER
We provide sample projects, demos, API docs and more for every single feature in the PDF SDK to get you up to speed quickly.
Make More Agreements
Learn the easy way to generate, sign, and track documents