Foxit Developer Blog

    Insights, tutorials, and updates from the Foxit PDF SDK engineering team.

    Foxit PDF Conversion SDK

    How to Convert PDF to Word, PowerPoint and Excel using Node.js

    System Requirements For system requirements, please check the latest developer guide here. Installation For installation, please refer to the developer guide here. Working with Foxit PDF Conversion SDK Node.js API It’s easy to use Foxit PDF Conversion SDK Node.js for converting PDF to Office. We can use PDF paths or PDF streams as a source of PDF input.  Before using it, first look at the definition of input parameters. PDFConversionSDK.PDF2Office.StartConvertToWordWithPath(src_pdf_path, src_pdf_password, saved_word_file_path, setting_data, convert_callback); PDFConversionSDK.PDF2Office.StartConvertToPPTWithPath(src_pdf_path, src_pdf_password, saved_ppt_file_path, setting_data, convert_callback); PDFConversionSDK.PDF2Office.StartConvertToExcelWithPath(src_pdf_path, src_pdf_password, saved_excel_file_path, setting_data, convert_callback); PDFConversionSDK.PDF2Office.StartConvertToWordWithStream(src_pdf_reader,src_pdf_password, saved_word_file_stream, setting_data, convert_callback); PDFConversionSDK.PDF2Office.StartConvertToPPTWithStream(src_pdf_reader,src_pdf_password, saved_ppt_file_stream, setting_data, convert_callback); PDFConversionSDK.PDF2Office.StartConvertToExcelWithStream(src_pdf_reader,src_pdf_password, saved_excel_file_stream, setting_data, convert_callback);

    Read Article
    Foxit PDF SDK for Web

    How to Use the Select Text Event to Activate a Browser Translation Plugin

    This article demonstrates how you can use the select text function with Foxit PDF SDK to activate a web browser translation plugin. In this example, we will use the Chrome Saladict plugin to implement a pop-up dictionary or page translator. We use Foxit PDF SDK to do it and you can get a free 30 day trial here. Platform: Web Programming Language: JavaScript License Key Requirement: Standard SDK Version: Foxit PDF SDK 9.0 Step 1 The first step is to enable the Saladict plugin in the Chrome://extensions panel.

    Read Article
    Foxit PDF SDK for Linux
    Foxit PDF SDK for Mac
    Foxit PDF SDK for Windows

    How to Identify PDFs using Layout Recognition

    This article aims to demonstrate how to identify a PDF using Layout Recognition. The data structure parsed by Layout Recognition is a bit like a tree structure, the root node is class LRStructureElement. Generally, class LRStructureElement has many child nodes, including class LRGraphicsObjectElement, class LRContentElement or class LRStructureElement. LRContentElement may have a corresponding LRGraphicsObjectElement,, whereas LRGraphicsObjectElement generally does not contain child nodes.

    Read Article
    Foxit PDF SDK for Web

    How to Create a Custom Screenshot Tool with Foxit PDF SDK for Web

    This article will demonstrate creating a custom screenshot tool with Foxit PDF SDK for Web. You can get a free 30 day trial here. Platform: Web Programming Language: JavaScript License Key Requirement: Standard SDK Version: Foxit PDF SDK 9.0 Step 1: Create a customized screenshot image storage service to upload the snapshots. //Custom screenshot image storage service const SnapshotServer = PDFViewCtrl.SnapshotServer; const pdfui = new PDFUI({ ... viewerOptions: { snapshotServer: new SnapshotServer({ origin: location.origin, uploadSnapshotAPIPath: 'snapshot/upload', payloadFieldName: 'file', method: 'POST', render: function(resp) { return resp; } }) ... } }) var pdfviewer = await pdfui.getPDFViewer(); // Capture the picture of the specified area on the page. var imageBlob = await pdfviewer.takeSnapshot(0, 0, 0, 200, 200); // Upload images to a specified server. var uploadResult = await pdfviewer.uploadImage(imageBlob); // Capture the picture and copy it to the clipboard var copyResult = await pdfviewer.copySnapshot(uploadResult);

    Read Article
    Foxit PDF SDK for Web

    How to Set Annotation Flags for Different Users with Foxit PDF SDK for Web

    This article aims to demonstrate how to set annotation flags for different users with our Web SDK. Follow the two steps below to perform the function. We use Foxit PDF SDK to do it and you can get a free 30 day trial here. Platform: Web Programming Language: JavaScript License Key Requirement: Standard SDK Version: Foxit PDF SDK 8.3 Step 1: Set annotation flags to lock annotations of other users at the application level:

    Read Article
    Foxit PDF SDK for Linux
    Foxit PDF SDK for Mac
    Foxit PDF SDK for Windows

    How to Create a Table of Contents Based on Bookmark Information in PDFs

    This article contains sample code that enables you to create a table of contents based on bookmark Information in PDFs. We use Foxit PDF SDK to do it and you can get a free 30 day trial here. Platform: Windows, Mac, Linux Programming Language: C++, Java, C#, Objective-C, C License Key requirement: StandardC++ void AddTOCToPDF(PDFDoc doc) { //Set the table of contents configuration. Int32Array intarray; int depth = doc.GetBookmarkLevelDepth(); if (depth > 0) { for (int i = 1; i <= depth; i++) { intarray.Add(i); } } WString title = L""; TableOfContentsConfig toc_config = TableOfContentsConfig(title, intarray, true, false); //Add the table of contents doc.AddTableOfContents(toc_config); }

    Read Article
    Foxit PDF SDK for Linux
    Foxit PDF SDK for Mac
    Foxit PDF SDK for Web

    How to Create your own JavaScript for Annotations

    This article demonstrates how to use JavaScript for annotations so you can get the most out of Foxit PDF SDK. Read on below for the 4 simple steps to get started. Platform: Windows, Mac, Linux Programming Language: C++, Java, C#, Objective-C, C License Key requirement: Standard SDK Version: Foxit PDF SDK 8.3 Step 1 LaunchURL: We will start by adding a link annotation to trigger the “launchURL” JavaScript to launch “https://webviewer-demo.foxit.com”

    Read Article
    Foxit PDF SDK for Linux
    Foxit PDF SDK for Mac
    Foxit PDF SDK for Windows

    How to Create your own JavaScript for PDF Forms

    JavaScript is crucial to form workflows for companies who want to boast the latest and greatest in document technologies. The article below demonstrates how to add JavaScript to PDF forms with Foxit PDF SDK. Platform: Windows, Mac, Linux Programming Language: C++, Java, C#, Objective-C, C License Key requirement: Standard SDK Version: Foxit PDF SDK 8.3 Below we will detail six simple demos. Step 1 AFSimple_Calculate: We will add two text field whose values will be used to add together. The third text field will contain the value of the sum of the first two form fields.

    Read Article
    Foxit PDF SDK for Web

    Foxit PDF SDK for Web: Advanced Forms

    Foxit’s advanced forms consist of Ultraforms that render a 2D barcode inside a PDF fillable form. It does this using JavaScript libraries which makes it unique relative to alternative 2D barcode solutions on the market. By comparison, other providers render a 2D barcode inside a PDF fillable form by using the PDF reader application to produce the 2D barcode. This means that they can only render a 2D barcode in a PDF form so long as the form user is using their product. Ultraforms will render a 2D barcode inside a PDF form using any PDF reader product, so long as it has implemented support for the JavaScript specification for PDF. Foxit PDF SDK for Web now adds a fantastic addition because it means form users don’t have to install a PDF reader on their device anymore.

    Read Article
    Foxit PDF SDK for Web

    How to use ActionCallback

    How to trigger JavaScript //JsActionCallback is the implementation class of ActionCallback. JsActionCallback* action_handler = new JsActionCallback(); Library::SetActionCallback(action_handler); Form form(pdf_doc); PDFPage pdf_page = pdf_doc.GetPage(0); //Set JavaScript for the button. Control control = form.GetControl(pdf_page, 0); Widget widget_annot = control.GetWidget(); AdditionalAction widget_aa(widget_annot); Action action = Action::Create(pdf_doc, Action::e_TypeJavaScript); JavaScriptAction javascipt_action(action); javascipt_action.SetScript(L"JavaScript code"); widget_aa.SetAction(AdditionalAction::e_TriggerAnnotMouseButtonPressed, javascipt_action); //Trigger JavaScript Script. widget_aa.DoJSAction(AdditionalAction::e_TriggerAnnotMouseButtonPressed) How [...]

    Read Article