These samples shows how to integrate PDFNet WebViewer into any HTML5, Silverlight, or Flash web application. The sample is using 'pdftron.PDF.Convert.ToXod()' to convert/stream PDF, XPS, MS Office, RTF, HTML and other document formats to WebViewer 'pdftron.PDF.Convert.ToXod()' is an optional Add-On to the Core SDK and is part of PDFNet WebViewer Publishing Platform.
1//
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3//
4
5using System;
6using System.Drawing;
7using System.Drawing.Drawing2D;
8
9using pdftron;
10using pdftron.Common;
11using pdftron.Filters;
12using pdftron.SDF;
13using pdftron.PDF;
14
15namespace WebViewerConvertCS
16{
17 /// <summary>
18 /// The following sample illustrates how to convert PDF, XPS, image, MS Office, and
19 /// other image document formats to XOD format.
20 ///
21 /// Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
22 /// be directly converted to XOD. Other formats such as MS Office
23 /// (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
24 /// These types of conversions guarantee optimal output, while preserving important
25 /// information such as document metadata, intra document links and hyper-links,
26 /// bookmarks etc.
27 ///
28 /// In case there is no direct conversion available, PDFNet can still convert from
29 /// any printable document to XOD using a virtual printer driver. To check
30 /// if a virtual printer is required use Convert::RequiresPrinter(filename). In this
31 /// case the installing application must be run as administrator. The manifest for this
32 /// sample specifies appropriate the UAC elevation. The administrator privileges are
33 /// not required for direct or interop conversions.
34 ///
35 /// Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
36 /// optionally licensable add-on to PDFNet Core SDK. For details, please see
37 /// https://apryse.com/pricing
38 /// </summary>
39 class Testfile
40 {
41 public string inputFile, outputFile;
42 public Testfile(string inFile, string outFile)
43 {
44 inputFile = inFile;
45 outputFile = outFile;
46 }
47 };
48
49 class Class1
50 {
51 // Relative path to the folder containing test files.
52 const string inputPath = "../../../../TestFiles/";
53 const string outputPath = "../../../../TestFiles/Output/";
54
55 static void BulkConvertRandomFilesToXod()
56 {
57 int err = 0;
58 System.Collections.ArrayList testfiles = new System.Collections.ArrayList();
59 testfiles.Add(new WebViewerConvertCS.Testfile("simple-powerpoint_2007.pptx", "simple-powerpoint_2007.xod"));
60 testfiles.Add(new WebViewerConvertCS.Testfile("simple-word_2007.docx", "simple-word_2007.xod"));
61 testfiles.Add(new WebViewerConvertCS.Testfile("butterfly.png", "butterfly.xod"));
62 testfiles.Add(new WebViewerConvertCS.Testfile("numbered.pdf", "numbered.xod"));
63 testfiles.Add(new WebViewerConvertCS.Testfile("dice.jpg", "dice.xod"));
64 testfiles.Add(new WebViewerConvertCS.Testfile("simple-xps.xps", "simple-xps.xod"));
65
66 foreach (Testfile file in testfiles)
67 {
68 try
69 {
70 if (pdftron.PDF.Convert.RequiresPrinter(inputPath + file.inputFile))
71 {
72 Console.WriteLine("Using PDFNet printer to convert file " + file.inputFile);
73 }
74
75 pdftron.PDF.Convert.ToXod(inputPath + file.inputFile, outputPath + file.outputFile);
76 Console.WriteLine("Converted file: " + file.inputFile + " to: " + file.outputFile);
77 }
78 catch (PDFNetException e)
79 {
80 Console.WriteLine("ERROR: on input file " + file.inputFile);
81 Console.WriteLine(e.Message);
82 err = 1;
83 }
84 }
85 if (err == 1) {
86 Console.WriteLine("ConvertFile failed");
87 } else {
88 Console.WriteLine("ConvertFile succeeded");
89 }
90 }
91
92 private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
93 static Class1() {}
94
95 /// <summary>
96 /// </summary>
97 [STAThread]
98 static void Main(string[] args)
99 {
100 PDFNet.Initialize(PDFTronLicense.Key);
101
102 // Sample 1:
103 // Directly convert from PDF to XOD.
104 pdftron.PDF.Convert.ToXod(inputPath + "newsletter.pdf", outputPath + "from_pdf.xod");
105
106 // Sample 2:
107 // Directly convert from generic XPS to XOD.
108 pdftron.PDF.Convert.ToXod(inputPath + "simple-xps.xps", outputPath + "from_xps.xod");
109
110 // Sample 3:
111 // Convert from MS Office (does not require printer driver for Office 2007+)
112 // and other document formats to XOD.
113 BulkConvertRandomFilesToXod();
114 PDFNet.Terminate();
115 Console.WriteLine("Done.");
116 }
117 }
118}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6#include <iostream>
7#include <sstream>
8#include <PDF/PDFNet.h>
9#include <PDF/Convert.h>
10#include "../../LicenseKey/CPP/LicenseKey.h"
11
12void BulkConvertRandomFilesToXod();
13
14//---------------------------------------------------------------------------------------
15// The following sample illustrates how to convert PDF, XPS, image, MS Office, and
16// other image document formats to XOD.
17//
18// Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
19// be directly converted to XOD. Other formats such as MS Office
20// (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
21// These types of conversions guarantee optimal output, while preserving important
22// information such as document metadata, intra document links and hyper-links,
23// bookmarks etc.
24//
25// In case there is no direct conversion available, PDFNet can still convert from
26// any printable document to XOD using a virtual printer driver. To check
27// if a virtual printer is required use Convert::RequiresPrinter(filename). In this
28// case the installing application must be run as administrator. The manifest for this
29// sample specifies appropriate the UAC elevation. The administrator privileges are
30// not required for direct or interop conversions.
31//
32// Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
33// optionally licensable add-on to PDFNet Core SDK. For details, please see
34// https://apryse.com/pricing.
35//---------------------------------------------------------------------------------------
36
37using namespace pdftron;
38using namespace PDF;
39using namespace std;
40
41UString inputPath("../../TestFiles/");
42UString outputPath("../../TestFiles/Output/");
43
44int main(int argc, char *argv[])
45{
46 int err = 0;
47 try
48 {
49 PDFNet::Initialize(LicenseKey);
50 {
51 // Sample 1:
52 // Directly convert from PDF to XOD.
53 Convert::ToXod(inputPath + "newsletter.pdf", outputPath + "from_pdf.xod");
54
55 // Sample 2:
56 // Directly convert from generic XPS to XOD.
57 Convert::ToXod(inputPath + "simple-xps.xps", outputPath + "from_xps.xod");
58
59 // Sample 3:
60 // Convert from MS Office (does not require printer driver for Office 2007+)
61 // and other document formats to XOD.
62 BulkConvertRandomFilesToXod();
63 }
64 PDFNet::Terminate();
65 }
66 catch(Common::Exception& e)
67 {
68 std::cout << e << std::endl;
69 err = 1;
70 }
71 catch(...)
72 {
73 std::cout << "Unknown Exception" << std::endl;
74 err = 1;
75 }
76
77 cout << "Done.\n";
78 return err;
79}
80
81
82
83typedef struct
84{
85 UString inputFile, outputFile;
86 bool requiresWindowsPlatform;
87} Testfile;
88
89Testfile testfiles[] =
90{
91 {"simple-powerpoint_2007.pptx", "simple-powerpoint_2007.xod", true},
92 {"simple-word_2007.docx", "simple-word_2007.xod", true},
93 {"butterfly.png", "butterfly.xod", false},
94 {"numbered.pdf", "numbered.xod", false},
95 {"dice.jpg", "dice.xod", false},
96 {"simple-xps.xps", "simple-xps.xod", false}
97};
98
99void BulkConvertRandomFilesToXod()
100{
101 int err = 0;
102#ifdef _MSC_VER
103 if( Convert::Printer::IsInstalled("PDFTron PDFNet") )
104 {
105 Convert::Printer::SetPrinterName("PDFTron PDFNet");
106 }
107 else if( !Convert::Printer::IsInstalled() )
108 {
109 try
110 {
111 // This will fail if not run as administrator. Harmless if PDFNet
112 // printer already installed
113 cout << "Installing printer (requires Windows platform and administrator)\n";
114 Convert::Printer::Install();
115 cout << "Installed printer " << Convert::Printer::GetPrinterName().ConvertToAscii().c_str() << "\n";
116 }
117 catch(Common::Exception)
118 {
119 cout << "Unable to install printer\n";
120 }
121 }
122#endif
123 unsigned int ceTestfiles = sizeof( testfiles ) / sizeof ( Testfile );
124
125 for( unsigned int i = 0; i < ceTestfiles; i++ )
126 {
127#ifndef _MSC_VER
128 if( testfiles[i].requiresWindowsPlatform)
129 {
130 continue;
131 }
132#endif
133 try
134 {
135 UString inputFile = inputPath + testfiles[i].inputFile;
136 UString outputFile = outputPath + testfiles[i].outputFile;
137 if( Convert::RequiresPrinter(inputFile) )
138 {
139 cout << "Using PDFNet printer to convert file " << testfiles[i].inputFile << "\n";
140 }
141 Convert::ToXod(inputFile, outputFile);
142 cout << "Converted file: " << testfiles[i].inputFile << " to: " << testfiles[i].outputFile << "\n";
143 }
144 catch(Common::Exception& e)
145 {
146 cout << "Unable to convert file " << testfiles[i].inputFile.ConvertToAscii().c_str() << "\n";
147 cout << e << "\n";
148 err = 1;
149 }
150 catch(...)
151 {
152 cout << "Unknown Exception" << "\n";
153 err = 1;
154 }
155 }
156
157 if( err ) {
158 cout << "ConvertFile failed\n";
159 }
160 else {
161 cout << "ConvertFile succeeded\n";
162 }
163
164#ifdef _MSC_VER
165 if( Convert::Printer::IsInstalled() )
166 {
167 try
168 {
169 cout << "Uninstalling printer (requires Windows platform and administrator)\n";
170 Convert::Printer::Uninstall();
171 cout << "Uninstalled Printer " << Convert::Printer::GetPrinterName().ConvertToAscii().c_str() << "\n";
172 }
173 catch (Common::Exception)
174 {
175 cout << "Unable to uninstall printer\n";
176 }
177 }
178#endif
179}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2021 by PDFTron Systems Inc. All Rights Reserved.
3// Consult LICENSE.txt regarding license information.
4//---------------------------------------------------------------------------------------
5
6package main
7import (
8 "fmt"
9 . "pdftron"
10)
11
12import "pdftron/Samples/LicenseKey/GO"
13
14//---------------------------------------------------------------------------------------
15// The following sample illustrates how to convert PDF, XPS, image, MS Office, and
16// other image document formats to XOD format.
17//
18// Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
19// be directly converted to XOD. Other formats such as MS Office
20// (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
21// These types of conversions guarantee optimal output, while preserving important
22// information such as document metadata, intra document links and hyper-links,
23// bookmarks etc.
24//
25// In case there is no direct conversion available, PDFNet can still convert from
26// any printable document to XOD using a virtual printer driver. To check
27// if a virtual printer is required use Convert::RequiresPrinter(filename). In this
28// case the installing application must be run as administrator. The manifest for this
29// sample specifies appropriate the UAC elevation. The administrator privileges are
30// not required for direct or interop conversions.
31//
32// Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
33// optionally licensable add-on to PDFNet Core SDK. For details, please see
34// https://apryse.com/pricing.
35//---------------------------------------------------------------------------------------
36
37// Relative path to the folder containing the test files.
38var inputPath = "../../TestFiles/"
39var outputPath = "../../TestFiles/Output/"
40
41func main(){
42 PDFNetInitialize(PDFTronLicense.Key)
43
44 // Sample 1:
45 // Directly convert from PDF to XOD.
46 ConvertToXod(inputPath + "newsletter.pdf", outputPath + "from_pdf.xod")
47
48 // Sample 2:
49 // Directly convert from generic XPS to XOD.
50 ConvertToXod(inputPath + "simple-xps.xps", outputPath + "from_xps.xod")
51
52 // Sample 3:
53 // Directly convert from PNG to XOD.
54 fmt.Println("Converting: " + inputPath + "butterfly.png" + " to: " + outputPath + "butterfly.xod")
55 ConvertToXod(inputPath + "butterfly.png", outputPath + "butterfly.xod")
56
57 // Sample 4:
58 fmt.Println("Converting: " + inputPath + "numbered.pdf" + " to: " + outputPath + "numbered.xod")
59 ConvertToXod(inputPath + "numbered.pdf", outputPath + "numbered.xod")
60
61 // Sample 5:
62 // Directly convert from JPG to XOD.
63 fmt.Println("Converting: " + inputPath + "dice.jpg" + " to: " + outputPath + "dice.xod")
64 ConvertToXod(inputPath + "dice.jpg", outputPath + "dice.xod")
65
66 // Sample 6:
67 // Directly convert from generic XPS to XOD.
68 fmt.Println("Converting: " + inputPath + "simple-xps.xps" + " to: " + outputPath + "simple-xps.xod")
69 ConvertToXod(inputPath + "simple-xps.xps", outputPath + "simple-xps.xod")
70
71 PDFNetTerminate()
72 fmt.Println("Done.")
73}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6import com.pdftron.common.PDFNetException;
7import com.pdftron.pdf.*;
8
9//---------------------------------------------------------------------------------------
10// The following sample illustrates how to convert PDF, XPS, image, MS Office, and
11// other image document formats to XOD format.
12//
13// Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
14// be directly converted to XOD. Other formats such as MS Office
15// (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
16// These types of conversions guarantee optimal output, while preserving important
17// information such as document metadata, intra document links and hyper-links,
18// bookmarks etc.
19//
20// In case there is no direct conversion available, PDFNet can still convert from
21// any printable document to XOD using a virtual printer driver. To check
22// if a virtual printer is required use Convert::RequiresPrinter(filename). In this
23// case the installing application must be run as administrator. The manifest for this
24// sample specifies appropriate the UAC elevation. The administrator privileges are
25// not required for direct or interop conversions.
26//
27// Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
28// optionally licensable add-on to PDFNet Core SDK. For details, please see
29// https://apryse.com/pricing.
30//---------------------------------------------------------------------------------------
31
32public class WebViewerConvertTest {
33 public WebViewerConvertTest() {
34
35 }
36
37 private class TestFile {
38 public String inputFile;
39 public String outputFile;
40 public boolean requiresWindowsPlatform;
41
42 public TestFile(String inputFile, String outputFile,
43 boolean requiresWindowsPlatform) {
44 this.inputFile = inputFile;
45 this.outputFile = outputFile;
46 this.requiresWindowsPlatform = requiresWindowsPlatform;
47 }
48 }
49
50 public static boolean printerInstalled;
51
52 // Relative path to the folder containing test files.
53 public static String input_path = "../../TestFiles/";
54 public static String output_path = "../../TestFiles/Output/";
55
56 public TestFile[] testFiles = {
57 new TestFile("simple-powerpoint_2007.pptx", "simple-powerpoint_2007.xod", true),
58 new TestFile("simple-word_2007.docx", "simple-word_2007.xod", true),
59 new TestFile("butterfly.png", "butterfly.xod", false),
60 new TestFile("numbered.pdf", "numbered.xod", false),
61 new TestFile("dice.jpg", "dice.xod", false),
62 new TestFile("simple-xps.xps", "simple-xps.xod", false) };
63
64 public void bulkConvertRandomFilesToXod() {
65 int err = 0;
66 if(System.getProperty("os.name").startsWith("Windows"))
67 {
68 try {
69 // See if the alternative printer is installed, the PDFNet printer
70 // is installed, or if not try to install a printer
71 if (ConvertPrinter.isInstalled("PDFTron PDFNet")) {
72 ConvertPrinter.setPrinterName("PDFTron PDFNet");
73 printerInstalled = true;
74 System.out.println("PDFTron PDFNet Printer is already installed");
75 } else if (ConvertPrinter.isInstalled()) {
76 printerInstalled = true;
77 System.out.println("PDFTron PDFNet Printer is already installed");
78 } else {
79 System.out.println("Installing printer (requires administrator and Windows platform)");
80 // This will fail if not run as administrator. Harmless if PDFNet printer already installed
81 ConvertPrinter.install();
82 System.out.println("Installed printer " + ConvertPrinter.getPrinterName());
83 printerInstalled = true;
84 }
85 } catch (PDFNetException e) {
86 System.out.println("Unable to install printer, error:");
87 System.out.println(e);
88 }
89 }
90 for (int i=0; i<testFiles.length; ++i) {
91 TestFile file=testFiles[i];
92 try {
93 if (Convert.requiresPrinter(file.inputFile)) {
94 String osName = System.getProperty("os.name");
95 if (osName.indexOf("Windows",0)==-1) {
96 continue;
97 }
98 System.out.println("Using PDFNet printer to convert file " + file.inputFile);
99 }
100 Convert.toXod(input_path + file.inputFile, output_path + file.outputFile);
101 System.out.println("Converted file: " + file.inputFile + " to: " + file.outputFile);
102 } catch (PDFNetException e) {
103 System.out.println("Unable to convert file: " + file.inputFile);
104 System.out.println(e.toString());
105 err = 1;
106 }
107 }
108 if (err == 1) {
109 System.out.println("ConvertFile failed");
110 } else {
111 System.out.println("ConvertFile succeeded");
112 }
113
114 // Uninstall the printer
115 if (printerInstalled) {
116 try {
117 System.out
118 .println("Uninstalling printer (requires administrator)");
119 ConvertPrinter.uninstall();
120 System.out.println("Uninstalled printer "
121 + ConvertPrinter.getPrinterName());
122 } catch (PDFNetException e) {
123 System.out.println("Unable to uninstall printer, error:");
124 System.out.println(e);
125 }
126 }
127 }
128
129 public static void main(String[] args) {
130 // The first step in every application using PDFNet is to initialize the
131 // library. The library is usually initialized only once, but calling
132 // Initialize() multiple times is also fine.
133 PDFNet.initialize(PDFTronLicense.Key());
134
135
136 String outputFile;
137 printerInstalled = false;
138
139 try {
140 // Sample 1:
141 // Directly convert from PDF to XOD.
142 Convert.toXod(input_path + "newsletter.pdf", output_path+ "from_pdf.xod");
143
144 // Sample 2:
145 // Directly convert from generic XPS to XOD.
146 Convert.toXod(input_path + "simple-xps.xps", output_path + "from_xps.xod");
147
148 // Sample 3:
149 // Convert from MS Office (does not require printer driver for
150 // Office 2007+)
151 // and other document formats to XOD.
152 WebViewerConvertTest test = new WebViewerConvertTest();
153 test.bulkConvertRandomFilesToXod();
154
155 } catch (PDFNetException e) {
156 System.out.println("Unable to convert file document to XOD, error:");
157 System.out.println(e);
158 }
159
160 PDFNet.terminate();
161 System.out.println("Done.");
162 }
163}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6//---------------------------------------------------------------------------------------
7// The following sample illustrates how to convert PDF, XPS, image, MS Office, and
8// other image document formats to XOD.
9//
10// Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
11// be directly converted to XOD. Other formats such as MS Office
12// (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
13// These types of conversions guarantee optimal output, while preserving important
14// information such as document metadata, intra document links and hyper-links,
15// bookmarks etc.
16//
17// In case there is no direct conversion available, PDFNet can still convert from
18// any printable document to XOD using a virtual printer driver. To check
19// if a virtual printer is required use Convert::RequiresPrinter(filename). In this
20// case the installing application must be run as administrator. The manifest for this
21// sample specifies appropriate the UAC elevation. The administrator privileges are
22// not required for direct or interop conversions.
23//
24// Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
25// optionally licensable add-on to PDFNet Core SDK. For details, please see
26// https://apryse.com/pricing.
27//---------------------------------------------------------------------------------------
28
29const { PDFNet } = require('@pdftron/pdfnet-node');
30const PDFTronLicense = require('../LicenseKey/LicenseKey');
31
32((exports) => {
33 'use strict';
34
35 exports.runWebViewerConvertTest = () => {
36 const inputPath = '../TestFiles/';
37 const outputPath = inputPath + 'Output/';
38 const main = async () => {
39 try {
40 // Sample 1:
41 // Directly convert from PDF to XOD.
42 await PDFNet.Convert.fileToXod(inputPath + 'newsletter.pdf', outputPath + 'from_pdf.xod');
43
44 // Sample 2:
45 // Directly convert from generic XPS to XOD.
46 await PDFNet.Convert.fileToXod(inputPath + 'simple-xps.xps', outputPath + 'from_xps.xod');
47
48 // Sample 3:
49 // Convert from MS Office (does not require printer driver for Office 2007+)
50 // and other document formats to XOD.
51 await bulkConvertRandomFilesToXod();
52 } catch (err) {
53 console.log(err.stack);
54 }
55 };
56
57 let Testfile = function (inputFile, outputFile, requiresWindowsPlatform) {
58 this.inputFile = inputFile;
59 this.outputFile = outputFile;
60 this.requiresWindowsPlatform = requiresWindowsPlatform;
61 }
62
63 const testfiles = [
64 new Testfile('simple-powerpoint_2007.pptx', 'simple-powerpoint_2007.xod', true),
65 new Testfile('simple-word_2007.docx', 'simple-word_2007.xod', true),
66 new Testfile('butterfly.png', 'butterfly.xod', false),
67 new Testfile('numbered.pdf', 'numbered.xod', false),
68 new Testfile('dice.jpg', 'dice.xod', false),
69 new Testfile('simple-xps.xps', 'simple-xps.xod', false),
70 ]
71
72 const bulkConvertRandomFilesToXod = async () => {
73 let err = 0;
74 if (process.platform === 'win32') {
75 if (await PDFNet.Convert.printerIsInstalled('PDFTron PDFNet')) {
76 await PDFNet.Convert.printerSetPrinterName('PDFTron PDFNet');
77 } else if (!(await PDFNet.Convert.printerIsInstalled())) {
78 try {
79 // This will fail if not run as administrator. Harmless if PDFNet
80 // printer already installed
81 console.log('Installing printer (requires Windows platform and administrator)');
82 await PDFNet.Convert.printerUninstall();
83 console.log('Installed printer ' + await PDFNet.Convert.printerGetPrinterName());
84 } catch (exp) {
85 console.log('Unable to install printer');
86 }
87 }
88 }
89
90 for (const testfile of testfiles)
91 {
92 if (process.platform !== 'win32' && testfile.requiresWindowsPlatform) {
93 continue;
94 }
95 try {
96 const inputFile = inputPath + testfile.inputFile;
97 const outputFile = outputPath + testfile.outputFile;
98 if (await PDFNet.Convert.requiresPrinter(inputFile)) {
99 console.log('Using PDFNet printer to convert file ' + testfile.inputFile);
100 }
101 await PDFNet.Convert.fileToXod(inputFile, outputFile);
102 console.log('Converted file: ' + testfile.inputFile + ' to: ' + testfile.outputFile);
103 } catch (exp) {
104 console.log('Unable to convert file ' + testfile.inputFile);
105 console.log(exp);
106 err = 1;
107 }
108 }
109
110 if (err) {
111 console.log('ConvertFile failed');
112 } else {
113 console.log('ConvertFile succeeded');
114 }
115
116 if (process.platform === 'win32' && await PDFNet.Convert.printerIsInstalled()) {
117 try {
118 console.log('Uninstalling printer (requires Windows platform and administrator)');
119 await PDFNet.Convert.printerUninstall();
120 console.log('Uninstalled Printer ' + await PDFNet.Convert.printerGetPrinterName());
121 }
122 catch (exp)
123 {
124 console.log('Unable to uninstall printer');
125 }
126 }
127 }
128
129 PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function (error) {
130 console.log('Error: ' + JSON.stringify(error));
131 }).then(function () { return PDFNet.shutdown(); });
132 };
133 exports.runWebViewerConvertTest();
134})(exports);
135// eslint-disable-next-line spaced-comment
136//# sourceURL=WebViewerConvertTest.js
1<?php
2//---------------------------------------------------------------------------------------
3// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
4// Consult LICENSE.txt regarding license information.
5//---------------------------------------------------------------------------------------
6if(file_exists("../../../PDFNetC/Lib/PDFNetPHP.php"))
7include("../../../PDFNetC/Lib/PDFNetPHP.php");
8include("../../LicenseKey/PHP/LicenseKey.php");
9
10//---------------------------------------------------------------------------------------
11// The following sample illustrates how to convert PDF, XPS, image, MS Office, and
12// other image document formats to XOD format.
13//
14// Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
15// be directly converted to XOD.
16// These types of conversions guarantee optimal output, while preserving important
17// information such as document metadata, intra document links and hyper-links,
18// bookmarks etc.
19//
20// In case there is no direct conversion available, PDFNet can still convert from
21// any printable document to XOD using a virtual printer driver. To check
22// if a virtual printer is required use Convert::RequiresPrinter(filename). In this
23// case the installing application must be run as administrator. The manifest for this
24// sample specifies appropriate the UAC elevation. The administrator privileges are
25// not required for direct or interop conversions.
26//
27// Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
28// optionally licensable add-on to PDFNet Core SDK. For details, please see
29// https://apryse.com/pricing.
30//---------------------------------------------------------------------------------------
31
32
33// Relative path to the folder containing the test files.
34$inputPath = "../../TestFiles/";
35$outputPath = "../../TestFiles/Output/";
36
37function main()
38{
39 global $inputPath, $outputPath, $LicenseKey;
40
41 PDFNet::Initialize($LicenseKey);
42 PDFNet::GetSystemFontList(); // Wait for fonts to be loaded if they haven't already. This is done because PHP can run into errors when shutting down if font loading is still in progress.
43
44 // Sample 1:
45 // Directly convert from PDF to XOD.
46 echo(nl2br("Converting: ".$inputPath."newsletter.pdf"." to ".$outputPath."from_pdf.xod"."\n"));
47 Convert::ToXod($inputPath."newsletter.pdf", $outputPath."from_pdf.xod");
48
49 // Sample 2:
50 // Directly convert from generic XPS to XOD.
51 echo(nl2br("Converting: ".$inputPath."simple-xps.xps"." to ".$outputPath."from_xps.xod"."\n"));
52 Convert::ToXod($inputPath."simple-xps.xps", $outputPath."from_xps.xod");
53
54 // Sample 3:
55 // Directly convert from PNG to XOD.
56 echo(nl2br("Converting: ".$inputPath."butterfly.png"." to ".$outputPath."butterfly.xod"."\n"));
57 Convert::ToXod($inputPath."butterfly.png", $outputPath."butterfly.xod");
58
59 // Sample 4:
60 echo(nl2br("Converting: " . $inputPath . "numbered.pdf" . " to: " . $outputPath . "numbered.xod\n"));
61 Convert::ToXod($inputPath . "numbered.pdf", $outputPath . "numbered.xod");
62
63 // Sample 5:
64 // Directly convert from JPG to XOD.
65 echo(nl2br("Converting: ".$inputPath."dice.jpg"." to ".$outputPath."dice.xod"."\n"));
66 Convert::ToXod($inputPath."dice.jpg", $outputPath."dice.xod");
67
68 // Sample 6:
69 // Directly convert from generic XPS to XOD.
70 echo(nl2br("Converting: " . $inputPath . "simple-xps.xps" . " to: " . $outputPath . "simple-xps.xod\n"));
71 Convert::ToXod($inputPath . "simple-xps.xps", $outputPath . "simple-xps.xod");
72 PDFNet::Terminate();
73 echo(nl2br("Done.\n"));
74}
75
76main();
77?>
1#---------------------------------------------------------------------------------------
2# Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3# Consult LICENSE.txt regarding license information.
4#---------------------------------------------------------------------------------------
5
6import site
7site.addsitedir("../../../PDFNetC/Lib")
8import sys
9import platform
10from PDFNetPython import *
11
12sys.path.append("../../LicenseKey/PYTHON")
13from LicenseKey import *
14
15#---------------------------------------------------------------------------------------
16# The following sample illustrates how to convert PDF, XPS, image, MS Office, and
17# other image document formats to XOD format.
18#
19# Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
20# be directly converted to XOD. Other formats such as MS Office
21# (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
22# These types of conversions guarantee optimal output, while preserving important
23# information such as document metadata, intra document links and hyper-links,
24# bookmarks etc.
25#
26# In case there is no direct conversion available, PDFNet can still convert from
27# any printable document to XOD using a virtual printer driver. To check
28# if a virtual printer is required use Convert::RequiresPrinter(filename). In this
29# case the installing application must be run as administrator. The manifest for this
30# sample specifies appropriate the UAC elevation. The administrator privileges are
31# not required for direct or interop conversions.
32#
33# Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
34# optionally licensable add-on to PDFNet Core SDK. For details, please see
35# https://apryse.com/pricing.
36#---------------------------------------------------------------------------------------
37
38# Relative path to the folder containing the test files.
39inputPath = "../../TestFiles/"
40outputPath = "../../TestFiles/Output/"
41
42def main():
43 PDFNet.Initialize(LicenseKey)
44
45 # Sample 1:
46 # Directly convert from PDF to XOD.
47 Convert.ToXod(inputPath + "newsletter.pdf", outputPath + "from_pdf.xod")
48
49 # Sample 2:
50 # Directly convert from generic XPS to XOD.
51 Convert.ToXod(inputPath + "simple-xps.xps", outputPath + "from_xps.xod")
52
53 # Sample 3:
54 # Directly convert from PNG to XOD.
55 print("Converting: " + inputPath + "butterfly.png" + " to: " + outputPath + "butterfly.xod")
56 Convert.ToXod(inputPath + "butterfly.png", outputPath + "butterfly.xod")
57
58 # Sample 4:
59 print("Converting: " + inputPath + "numbered.pdf" + " to: " + outputPath + "numbered.xod")
60 Convert.ToXod(inputPath + "numbered.pdf", outputPath + "numbered.xod")
61
62 # Sample 5:
63 # Directly convert from JPG to XOD.
64 print("Converting: " + inputPath + "dice.jpg" + " to: " + outputPath + "dice.xod")
65 Convert.ToXod(inputPath + "dice.jpg", outputPath + "dice.xod")
66
67 # Sample 6:
68 # Directly convert from generic XPS to XOD.
69 print("Converting: " + inputPath + "simple-xps.xps" + " to: " + outputPath + "simple-xps.xod")
70 Convert.ToXod(inputPath + "simple-xps.xps", outputPath + "simple-xps.xod")
71
72 PDFNet.Terminate()
73 print("Done.")
74
75if __name__ == '__main__':
76 main()
1#---------------------------------------------------------------------------------------
2# Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3# Consult LICENSE.txt regarding license information.
4#---------------------------------------------------------------------------------------
5
6require '../../../PDFNetC/Lib/PDFNetRuby'
7include PDFNetRuby
8require '../../LicenseKey/RUBY/LicenseKey'
9
10$stdout.sync = true
11
12#---------------------------------------------------------------------------------------
13# The following sample illustrates how to convert PDF, XPS, image, MS Office, and
14# other image document formats to XOD format.
15#
16# Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
17# be directly converted to XOD Other formats such as MS Office
18# (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
19# These types of conversions guarantee optimal output, while preserving important
20# information such as document metadata, intra document links and hyper-links,
21# bookmarks etc.
22#
23# In case there is no direct conversion available, PDFNet can still convert from
24# any printable document to XOD using a virtual printer driver. To check
25# if a virtual printer is required use Convert::RequiresPrinter(filename). In this
26# case the installing application must be run as administrator. The manifest for this
27# sample specifies appropriate the UAC elevation. The administrator privileges are
28# not required for direct or interop conversions.
29#
30# Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
31# optionally licensable add-on to PDFNet Core SDK. For details, please see
32# https://apryse.com/pricing.
33#---------------------------------------------------------------------------------------
34
35# Relative path to the folder containing the test files.
36$inputPath = "../../TestFiles/"
37$outputPath = "../../TestFiles/Output/"
38
39def main()
40 PDFNet.Initialize(PDFTronLicense.Key)
41
42 # Sample 1:
43 # Directly convert from PDF to XOD.
44 Convert.ToXod($inputPath + "newsletter.pdf", $outputPath + "from_pdf.xod")
45
46 # Sample 2:
47 # Directly convert from generic XPS to XOD.
48 Convert.ToXod($inputPath + "simple-xps.xps", $outputPath + "from_xps.xod")
49
50 # Sample 3:
51 # Directly convert from PNG to XOD.
52 puts "Converting: " + $inputPath + "butterfly.png" + " to " + $outputPath + "butterfly.xod"
53 Convert.ToXod($inputPath + "butterfly.png", $outputPath + "butterfly.xod")
54
55 # Sample 4:
56 # Directly convert from PDF to XOD.
57 puts "Converting: " + $inputPath + "numbered.pdf" + " to " + $outputPath + "numbered.xod"
58 Convert.ToXod($inputPath + "numbered.pdf", $outputPath + "numbered.xod")
59
60 # Sample 5:
61 # Directly convert from JPG to XOD.
62 puts "Converting: " + $inputPath + "dice.jpg" + " to " + $outputPath + "dice.xod"
63 Convert.ToXod($inputPath + "dice.jpg", $outputPath + "dice.xod")
64
65 # Sample 6:
66 # Directly convert from generic XPS to XOD.
67 puts "Converting: " + $inputPath + "simple-xps.xps" + " to " + $outputPath + "simple-xps.xod"
68 Convert.ToXod($inputPath + "simple-xps.xps", $outputPath + "simple-xps.xod")
69 PDFNet.Terminate
70 puts "Done."
71end
72
73main()
1'
2' Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3'
4
5Imports pdftron
6Imports pdftron.Common
7Imports pdftron.Filters
8Imports pdftron.SDF
9Imports pdftron.PDF
10
11''' <summary>
12''' The following sample illustrates how to convert PDF, XPS, image, MS Office, and
13''' other image document formats to XOD format.
14'''
15''' Certain file formats such as PDF, generic XPS, EMF, and raster image formats can
16''' be directly converted to XOD. Other formats such as MS Office
17''' (Word, Excel, Publisher, Powerpoint, etc) can be directly converted via interop.
18''' These types of conversions guarantee optimal output, while preserving important
19''' information such as document metadata, intra document links and hyper-links,
20''' bookmarks etc.
21'''
22''' In case there is no direct conversion available, PDFNet can still convert from
23''' any printable document to XOD using a virtual printer driver. To check
24''' if a virtual printer is required use Convert::RequiresPrinter(filename). In this
25''' case the installing application must be run as administrator. The manifest for this
26''' sample specifies appropriate the UAC elevation. The administrator privileges are
27''' not required for direct or interop conversions.
28'''
29''' Please note that PDFNet Publisher (i.e. 'pdftron.PDF.Convert.ToXod') is an
30''' optionally licensable add-on to PDFNet Core SDK. For details, please see
31''' https://apryse.com/pricing
32''' </summary>
33Class Testfile
34 Public inputFile As String, outputFile As String
35 Public Sub New(ByVal inFile As String, ByVal outFile As String)
36 inputFile = inFile
37 outputFile = outFile
38 End Sub
39End Class
40
41Module WebViewerConvertTestVB
42 Dim pdfNetLoader As PDFNetLoader
43 Sub New()
44 pdfNetLoader = pdftron.PDFNetLoader.Instance()
45 End Sub
46
47 ' Relative path to the folder containing test files.
48 Dim inputPath As String = "../../../../TestFiles/"
49 Dim outputPath As String = "../../../../TestFiles/Output/"
50
51 Private Sub BulkConvertRandomFilesToXod()
52 Dim err As Integer = 0
53 Dim testfiles As New System.Collections.ArrayList()
54 testfiles.Add(New Testfile("simple-powerpoint_2007.pptx", "simple-powerpoint_2007.xod"))
55 testfiles.Add(New Testfile("simple-word_2007.docx", "simple-word_2007.xod"))
56 testfiles.Add(New Testfile("butterfly.png", "butterfly.xod"))
57 testfiles.Add(New Testfile("numbered.pdf", "numbered.xod"))
58 testfiles.Add(New Testfile("dice.jpg", "dice.xod"))
59 testfiles.Add(New Testfile("simple-xps.xps", "simple-xps.xod"))
60
61 For Each file As Testfile In testfiles
62 Try
63 If pdftron.PDF.Convert.RequiresPrinter(inputPath + file.inputFile) Then
64 Console.WriteLine("Using PDFNet printer to convert file " & file.inputFile)
65 End If
66
67 pdftron.PDF.Convert.ToXod(inputPath + file.inputFile, outputPath + file.outputFile)
68 Console.WriteLine("Converted file: " & file.inputFile & "to: " & file.outputFile)
69 Catch e As PDFNetException
70 Console.WriteLine("ERROR: on input file " & file.inputFile)
71 Console.WriteLine(e.Message)
72 err = 1
73 End Try
74 Next
75 If err = 1 Then
76 Console.WriteLine("ConvertFile failed")
77 Else
78 Console.WriteLine("ConvertFile succeeded")
79 End If
80
81 End Sub
82
83 Sub Main()
84 PDFNet.Initialize(PDFTronLicense.Key)
85
86 ' Sample 1:
87 ' Directly convert from PDF to XOD.
88 pdftron.PDF.Convert.ToXod(inputPath + "newsletter.pdf", outputPath + "from_pdf.xod")
89
90 ' Sample 2:
91 ' Directly convert from generic XPS to XOD.
92 pdftron.PDF.Convert.ToXod(inputPath + "simple-xps.xps", outputPath + "from_xps.xod")
93
94 ' Sample 3:
95 ' Convert from MS Office (does not require printer driver for Office 2007+)
96 ' and other document formats to XOD.
97 BulkConvertRandomFilesToXod()
98 PDFNet.Terminate()
99 Console.WriteLine("Done.")
100 End Sub
101
102End Module
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales