Sample C# code to convert to PDF with virtual printer on Windows. It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc.
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 ConvertPrintTestCS
16{
17 /// <summary>
18 // The following sample illustrates how to convert to PDF with virtual printer on Windows.
19 // It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
20 // https://docs.apryse.com/windows/guides/features/conversion/convert-other/
21 //
22 // To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
23 // The installing application must be run as administrator. The manifest for this sample
24 // specifies appropriate the UAC elevation.
25 //
26 // Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7, or .NET Framework
27 // 3.x or higher. For older versions of .NET Framework running on Windows XP or Vista SP0 you need to install
28 // the XPS Essentials Pack (or equivalent redistributables).
29 //
30 // Also note that conversion under ASP.NET can be tricky to configure. Please see the following document for advice:
31 // http://www.pdftron.com/pdfnet/faq_files/Converting_Documents_in_Windows_Service_or_ASP.NET_Application_using_PDFNet.pdf
32 /// </summary>
33 class Testfile
34 {
35 public string inputFile, outputFile;
36 public Testfile(string inFile, string outFile)
37 {
38 inputFile = inFile;
39 outputFile = outFile;
40 }
41 };
42
43 class Class1
44 {
45 private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
46 static Class1() {}
47
48 // Relative path to the folder containing test files.
49 const string inputPath = "../../../../TestFiles/";
50 const string outputPath = "../../../../TestFiles/Output/";
51
52 static bool ConvertSpecificFormats()
53 {
54 //////////////////////////////////////////////////////////////////////////
55 bool err = false;
56 try
57 {
58 // Convert MSWord document to XPS
59 Console.WriteLine("Converting DOCX to XPS");
60 pdftron.PDF.Convert.ToXps(inputPath + "simple-word_2007.docx", outputPath + "simple-word_2007.xps");
61 Console.WriteLine("Saved simple-word_2007.xps");
62 }
63 catch (PDFNetException e)
64 {
65 Console.WriteLine(e.Message);
66 err = true;
67 }
68
69
70 //////////////////////////////////////////////////////////////////////////
71 try
72 {
73 using (PDFDoc pdfdoc = new PDFDoc())
74 {
75 Console.WriteLine("Converting from EMF");
76 pdftron.PDF.Convert.FromEmf(pdfdoc, inputPath + "simple-emf.emf");
77 pdfdoc.Save(outputPath + "emf2pdf v2.pdf", SDFDoc.SaveOptions.e_remove_unused);
78 Console.WriteLine("Saved emf2pdf v2.pdf");
79 }
80 }
81 catch (PDFNetException e)
82 {
83 Console.WriteLine(e.Message);
84 err = true;
85 }
86
87 return err;
88 }
89
90 static Boolean ConvertToPdfFromFile()
91 {
92 System.Collections.ArrayList testfiles = new System.Collections.ArrayList();
93 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-powerpoint_2007.pptx", "pptx2pdf.pdf"));
94 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-word_2007.docx", "docx2pdf.pdf"));
95 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-excel_2007.xlsx", "xlsx2pdf.pdf"));
96 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-publisher.pub", "pub2pdf.pdf"));
97 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-text.txt", "txt2pdf.pdf"));
98 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-rtf.rtf", "rtf2pdf.pdf"));
99 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-emf.emf", "emf2pdf.pdf"));
100 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-webpage.mht", "mht2pdf.pdf"));
101 testfiles.Add(new ConvertPrintTestCS.Testfile("simple-webpage.html", "html2pdf.pdf"));
102
103 bool err = false;
104 try
105 {
106 if (pdftron.PDF.Convert.Printer.IsInstalled("PDFTron PDFNet"))
107 {
108 pdftron.PDF.Convert.Printer.SetPrinterName("PDFTron PDFNet");
109 }
110 else if (!pdftron.PDF.Convert.Printer.IsInstalled())
111 {
112 try
113 {
114 Console.WriteLine("Installing printer (requires Windows platform and administrator)");
115 pdftron.PDF.Convert.Printer.Install();
116 Console.WriteLine("Installed printer " + pdftron.PDF.Convert.Printer.GetPrinterName());
117 // the function ConvertToXpsFromFile may require the printer so leave it installed
118 // uninstallPrinterWhenDone = true;
119 }
120 catch (PDFNetException e)
121 {
122 Console.WriteLine("ERROR: Unable to install printer.");
123 Console.WriteLine(e.Message);
124 err = true;
125 }
126 catch
127 {
128 Console.WriteLine("ERROR: Unable to install printer. Make sure that the package's bitness matches your operating system's bitness and that you are running with administrator privileges.");
129 }
130 }
131 }
132 catch (PDFNetException e)
133 {
134 Console.WriteLine("ERROR: Unable to install printer.");
135 Console.WriteLine(e.Message);
136 err = true;
137 }
138
139 foreach (Testfile file in testfiles)
140 {
141 try
142 {
143 using (pdftron.PDF.PDFDoc pdfdoc = new PDFDoc())
144 {
145
146 if (pdftron.PDF.Convert.RequiresPrinter(inputPath + file.inputFile))
147 {
148 Console.WriteLine("Using PDFNet printer to convert file " + file.inputFile);
149 }
150 pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath + file.inputFile);
151 pdfdoc.Save(outputPath + file.outputFile, SDFDoc.SaveOptions.e_linearized);
152 Console.WriteLine("Converted file: " + file.inputFile);
153 Console.WriteLine("to: " + file.outputFile);
154 }
155 }
156 catch (PDFNetException e)
157 {
158 Console.WriteLine("ERROR: on input file " + file.inputFile);
159 Console.WriteLine(e.Message);
160 err = true;
161 }
162 }
163
164 return err;
165 }
166
167
168 /// <summary>
169 /// The main entry point for the application.
170 /// </summary>
171 [STAThread]
172 static void Main(string[] args)
173 {
174 if (Environment.OSVersion.Platform == PlatformID.Win32NT)
175 {
176 PDFNet.Initialize(PDFTronLicense.Key);
177 bool err = false;
178
179 err = ConvertToPdfFromFile();
180 if (err)
181 {
182 Console.WriteLine("ConvertFile failed");
183 }
184 else
185 {
186 Console.WriteLine("ConvertFile succeeded");
187 }
188
189 err = ConvertSpecificFormats();
190 if (err)
191 {
192 Console.WriteLine("ConvertSpecificFormats failed");
193 }
194 else
195 {
196 Console.WriteLine("ConvertSpecificFormats succeeded");
197 }
198
199
200 if (pdftron.PDF.Convert.Printer.IsInstalled())
201 {
202 try
203 {
204 Console.WriteLine("Uninstalling printer (requires Windows platform and administrator)");
205 pdftron.PDF.Convert.Printer.Uninstall();
206 Console.WriteLine("Uninstalled Printer " + pdftron.PDF.Convert.Printer.GetPrinterName());
207 }
208 catch
209 {
210 Console.WriteLine("Unable to uninstall printer");
211 }
212 }
213
214 PDFNet.Terminate();
215 Console.WriteLine("Done.");
216 }
217 else
218 {
219 Console.WriteLine("ConvertPrintTest only available on Windows");
220 }
221 }
222 }
223}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2023 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
12//---------------------------------------------------------------------------------------
13// The following sample illustrates how to convert to PDF with virtual printer on Windows.
14// It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
15// https://docs.apryse.com/windows/guides/features/conversion/convert-other/
16//
17// To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
18// The installing application must be run as administrator. The manifest for this sample
19// specifies appropriate the UAC elevation.
20//
21// Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
22// For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
23// equivalent redistributables). You can download the XPS Essentials Pack from:
24// http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
25// Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
26// http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
27//
28// Note: Convert.FromEmf and Convert.ToEmf will only work on Windows and require GDI+.
29//
30// Please contact us if you have any questions.
31//---------------------------------------------------------------------------------------
32
33using namespace pdftron;
34using namespace PDF;
35using namespace std;
36
37UString inputPath("../../TestFiles/");
38UString outputPath("../../TestFiles/Output/");
39
40typedef struct
41{
42 UString inputFile, outputFile;
43}
44Testfile;
45
46Testfile testfiles[] =
47{
48 { "simple-word_2007.docx", "docx2pdf.pdf"},
49 { "simple-powerpoint_2007.pptx", "pptx2pdf.pdf"},
50 { "simple-excel_2007.xlsx", "xlsx2pdf.pdf"},
51 { "simple-publisher.pub", "pub2pdf.pdf"},
52 { "simple-text.txt", "txt2pdf.pdf"},
53 { "simple-rtf.rtf", "rtf2pdf.pdf"},
54 { "simple-emf.emf", "emf2pdf.pdf"},
55 { "simple-webpage.mht", "mht2pdf.pdf"},
56 { "simple-webpage.html", "html2pdf.pdf"}
57};
58
59int ConvertSpecificFormats(); // convert to/from PDF, XPS, EMF, SVG
60int ConvertToPdfFromFile(); // convert from a file to PDF automatically
61
62int main(int argc, char *argv[])
63{
64
65//Virtual printer only available on Windows
66#if defined(_WIN32)
67 // The first step in every application using PDFNet is to initialize the
68 // library. The library is usually initialized only once, but calling
69 // Initialize() multiple times is also fine.
70 int err = 0;
71
72 PDFNet::Initialize(LicenseKey);
73
74 // Demonstrate Convert::ToPdf and Convert::Printer
75 err = ConvertToPdfFromFile();
76 if (err)
77 {
78 cout << "ConvertFile failed" << endl;
79 }
80 else
81 {
82 cout << "ConvertFile succeeded" << endl;
83 }
84
85 // Demonstrate Convert::[FromEmf, FromXps, ToEmf, ToSVG, ToXPS]
86 err = ConvertSpecificFormats();
87 if (err)
88 {
89 cout << "ConvertSpecificFormats failed" << endl;
90 }
91 else
92 {
93 cout << "ConvertSpecificFormats succeeded" << endl;
94 }
95
96 if (Convert::Printer::IsInstalled())
97 {
98 try
99 {
100 cout << "Uninstalling printer (requires Windows platform and administrator)" << endl;
101 Convert::Printer::Uninstall();
102 cout << "Uninstalled printer " << Convert::Printer::GetPrinterName().ConvertToAscii().c_str() << endl;;
103 }
104 catch (Common::Exception)
105 {
106 cout << "Unable to uninstall printer" << endl;
107 }
108 }
109
110 PDFNet::Terminate();
111 cout << "Done.\n";
112 return err;
113#else
114 cout << "ConvertPrintTest only available on Windows\n";
115#endif // defined(_WIN32)
116
117}
118
119int ConvertToPdfFromFile()
120{
121 int ret = 0;
122
123 if( Convert::Printer::IsInstalled("PDFTron PDFNet") )
124 {
125 Convert::Printer::SetPrinterName("PDFTron PDFNet");
126 }
127 else if (!Convert::Printer::IsInstalled())
128 {
129 try
130 {
131 // This will fail if not run as administrator. Harmless if PDFNet
132 // printer already installed
133 cout << "Installing printer (requires Windows platform and administrator)\n";
134 Convert::Printer::Install();
135 cout << "Installed printer " << Convert::Printer::GetPrinterName().ConvertToAscii().c_str() << endl;
136 }
137 catch (Common::Exception)
138 {
139 cout << "Unable to install printer" << endl;
140 }
141 }
142
143 unsigned int ceTestfiles = sizeof (testfiles) / sizeof (Testfile);
144
145 for (unsigned int i = 0; i < ceTestfiles; i++)
146 {
147 try
148 {
149 PDFDoc pdfdoc;
150 UString inputFile = inputPath + testfiles[i].inputFile;
151 UString outputFile = outputPath + testfiles[i].outputFile;
152 if (Convert::RequiresPrinter(inputFile))
153 {
154 cout << "Using PDFNet printer to convert file " << testfiles[i].inputFile << endl;
155 }
156 Convert::ToPdf(pdfdoc, inputFile);
157 pdfdoc.Save(outputFile, SDF::SDFDoc::e_linearized, NULL);
158 cout << "Converted file: " << testfiles[i].inputFile << endl << "to: " << testfiles[i].outputFile << endl;
159 }
160 catch (Common::Exception& e)
161 {
162 cout << "Unable to convert file " << testfiles[i].inputFile.ConvertToAscii().c_str() << endl;
163 cout << e << endl;
164 ret = 1;
165 }
166 catch (...)
167 {
168 cout << "Unknown Exception" << endl;
169 ret = 1;
170 }
171 }
172
173 return ret;
174}
175
176int ConvertSpecificFormats()
177{
178 //////////////////////////////////////////////////////////////////////////
179 int ret = 0;
180 try
181 {
182 PDFDoc pdfdoc;
183
184 cout << "Converting from EMF" << endl;
185 Convert::FromEmf(pdfdoc, inputPath + "simple-emf.emf");
186 pdfdoc.Save(outputPath + "emf2pdf v2.pdf", SDF::SDFDoc::e_remove_unused, NULL);
187 cout << "Saved emf2pdf v2.pdf" << endl;
188 }
189 catch (Common::Exception& e)
190 {
191 cout << e << endl;
192 ret = 1;
193 }
194 catch (...)
195 {
196 cout << "Unknown Exception" << endl;
197 ret = 1;
198 }
199
200 //////////////////////////////////////////////////////////////////////////
201 try
202 {
203 // Convert MSWord document to XPS
204 cout << "Converting DOCX to XPS" << endl;
205 Convert::ToXps(inputPath + "simple-word_2007.docx", outputPath + "simple-word_2007.xps");
206 cout << "Saved simple-word_2007.xps" << endl;
207 }
208 catch (Common::Exception& e)
209 {
210 cout << e << endl;
211 ret = 1;
212 }
213 catch (...)
214 {
215 cout << "Unknown Exception" << endl;
216 ret = 1;
217 }
218
219 return ret;
220}
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
3// Consult LICENSE.txt regarding license information.
4//---------------------------------------------------------------------------------------
5
6package main
7import (
8 "testing"
9 "fmt"
10 "flag"
11 "runtime"
12 . "github.com/ApryseSDK/pdftron-go/v2"
13)
14
15var licenseKey string
16var modulePath string
17
18func init() {
19 flag.StringVar(&licenseKey, "license", "", "License key for Apryse SDK")
20 flag.StringVar(&modulePath, "modulePath", "", "Module path for Apryse SDK")
21}
22
23//---------------------------------------------------------------------------------------
24// The following sample illustrates how to convert to PDF with virtual printer on Windows.
25// It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
26// https://docs.apryse.com/windows/guides/features/conversion/convert-other/
27//
28// To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
29// The installing application must be run as administrator. The manifest for this sample
30// specifies appropriate the UAC elevation.
31//
32// Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
33// For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
34// equivalent redistributables). You can download the XPS Essentials Pack from:
35// http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
36// Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
37// http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
38//
39// Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+.
40//
41// Please contact us if you have any questions.
42//---------------------------------------------------------------------------------------
43
44// Relative path to the folder containing the test files.
45var inputPath = "../../TestFiles/"
46var outputPath = "../../TestFiles/Output/"
47
48
49func ConvertSpecificFormats() bool{
50 ret := false
51
52
53 // Convert MSWord document to XPS
54 fmt.Println("Converting DOCX to XPS")
55 outputFile := "simple-word_2007.xps"
56 ConvertToXps(inputPath + "simple-word_2007.docx", outputPath + outputFile)
57 fmt.Println("Saved " + outputFile)
58
59 // Start with a PDFDoc to collect the converted documents
60 pdfdoc := NewPDFDoc()
61 // Convert the EMF document to PDF
62 s1 := inputPath + "simple-emf.emf"
63
64 fmt.Println("Converting from EMF")
65 ConvertFromEmf(pdfdoc, s1)
66 outputFile = "emf2pdf v2.pdf"
67 pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_remove_unused))
68 fmt.Println("Saved " + outputFile)
69
70 return ret
71}
72func ConvertToPdfFromFile() bool{
73 testFiles := [][]string{
74 {"simple-word_2007.docx","docx2pdf.pdf"},
75 {"simple-powerpoint_2007.pptx","pptx2pdf.pdf"},
76 {"simple-excel_2007.xlsx","xlsx2pdf.pdf"},
77 {"simple-publisher.pub","pub2pdf.pdf"},
78 {"simple-text.txt","txt2pdf.pdf"},
79 { "simple-rtf.rtf","rtf2pdf.pdf"},
80 { "simple-emf.emf","emf2pdf.pdf"},
81 { "simple-webpage.mht","mht2pdf.pdf"},
82 { "simple-webpage.html","html2pdf.pdf"}}
83 ret := false
84
85 if PrinterIsInstalled("PDFTron PDFNet"){
86 PrinterSetPrinterName("PDFTron PDFNet")
87 }else if ! PrinterIsInstalled(){
88 fmt.Println("Installing printer (requires Windows platform and administrator)")
89 PrinterInstall()
90 fmt.Println("Installed printer " + PrinterGetPrinterName())
91 }
92
93 for _, testfile := range testFiles {
94
95 pdfdoc := NewPDFDoc()
96 inputFile := testfile[0]
97 outputFile := testfile[1]
98 if ConvertRequiresPrinter(inputPath + inputFile){
99 fmt.Println("Using PDFNet printer to convert file " + inputFile)
100 }
101 ConvertToPdf(pdfdoc, inputPath + inputFile)
102 pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_linearized))
103 pdfdoc.Close()
104 fmt.Println("Converted file: " + inputFile + "\nto: " + outputFile)
105 }
106 return ret
107}
108
109func TestConvertPrint(t *testing.T){
110 if runtime.GOOS == "windows" {
111 // The first step in every application using PDFNet is to initialize the
112 // library. The library is usually initialized only once, but calling
113 // Initialize() multiple times is also fine.
114 PDFNetInitialize(licenseKey)
115
116 // Demonstrate Convert.ToPdf and Convert.Printer
117 err := ConvertToPdfFromFile()
118 if err{
119 fmt.Println("ConvertFile failed")
120 }else{
121 fmt.Println("ConvertFile succeeded")
122 }
123 // Demonstrate Convert.[FromEmf, FromXps, ToEmf, ToSVG, ToXPS]
124 err = ConvertSpecificFormats()
125 if err{
126 fmt.Println("ConvertSpecificFormats failed")
127 }else{
128 fmt.Println("ConvertSpecificFormats succeeded")
129 }
130 fmt.Println("Uninstalling printer (requires Windows platform and administrator)")
131 PrinterUninstall()
132 fmt.Println("Uninstalled printer " + PrinterGetPrinterName())
133
134 PDFNetTerminate()
135 fmt.Println("Done.")
136 }else{
137 fmt.Println("ConvertPrintTest only available on Windows")
138 }
139}
1//
2// Copyright (c) 2001-2023 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.*;
8import com.pdftron.sdf.Obj;
9import com.pdftron.sdf.ObjSet;
10import com.pdftron.sdf.SDFDoc;
11import java.util.ArrayList;
12//---------------------------------------------------------------------------------------
13// The following sample illustrates how to convert to PDF with virtual printer on Windows.
14// It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
15// https://docs.apryse.com/windows/guides/features/conversion/convert-other/
16//
17// To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
18// The installing application must be run as administrator. The manifest for this sample
19// specifies appropriate the UAC elevation.
20//
21// Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
22// For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
23// equivalent redistributables). You can download the XPS Essentials Pack from:
24// http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
25// Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
26// http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
27//
28// Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+.
29//
30// Please contact us if you have any questions.
31//---------------------------------------------------------------------------------------
32class Testfile
33{
34 public String inputFile, outputFile;
35 public Testfile(String inFile, String outFile)
36 {
37 inputFile = inFile;
38 outputFile = outFile;
39 }
40}
41
42public class ConvertPrintTest
43{
44 // Relative path to the folder containing test files.
45 static String inputPath = "../../TestFiles/";
46 static String outputPath = "../../TestFiles/Output/";
47
48 static boolean ConvertSpecificFormats()
49 {
50 //////////////////////////////////////////////////////////////////////////
51 boolean err = false;
52 try (PDFDoc pdfdoc = new PDFDoc())
53 {
54 System.out.println("Converting from EMF");
55 Convert.fromEmf(pdfdoc, inputPath + "simple-emf.emf");
56 pdfdoc.save(outputPath + "emf2pdf v2.pdf", SDFDoc.SaveMode.REMOVE_UNUSED, null);
57 System.out.println("Saved emf2pdf v2.pdf");
58 }
59 catch (PDFNetException e)
60 {
61 System.out.println(e);
62 err = true;
63 }
64
65
66 //////////////////////////////////////////////////////////////////////////
67 try
68 {
69 // Convert MSWord document to XPS
70 System.out.println("Converting DOCX to XPS");
71 Convert.toXps(inputPath + "simple-word_2007.docx", outputPath + "simple-word_2007.xps");
72 System.out.println("Saved simple-word_2007.xps");
73 }
74 catch (PDFNetException e)
75 {
76 System.out.println(e);
77 err = true;
78 }
79
80 return err;
81 }
82
83 static boolean ConvertToPdfFromFile()
84 {
85 ArrayList<Testfile> testfiles = new ArrayList<Testfile>();
86 testfiles.add(new Testfile("simple-word_2007.docx", "docx2pdf.pdf"));
87 testfiles.add(new Testfile("simple-powerpoint_2007.pptx", "pptx2pdf.pdf"));
88 testfiles.add(new Testfile("simple-excel_2007.xlsx", "xlsx2pdf.pdf"));
89 testfiles.add(new Testfile("simple-publisher.pub", "pub2pdf.pdf"));
90 testfiles.add(new Testfile("simple-text.txt", "txt2pdf.pdf"));
91 testfiles.add(new Testfile("simple-rtf.rtf", "rtf2pdf.pdf"));
92 testfiles.add(new Testfile("simple-emf.emf", "emf2pdf.pdf"));
93 testfiles.add(new Testfile("simple-webpage.mht", "mht2pdf.pdf"));
94 testfiles.add(new Testfile("simple-webpage.html", "html2pdf.pdf"));
95
96 boolean err = false;
97 try{
98 if (ConvertPrinter.isInstalled("PDFTron PDFNet"))
99 {
100 ConvertPrinter.setPrinterName("PDFTron PDFNet");
101 }
102 else if (!ConvertPrinter.isInstalled())
103 {
104 try
105 {
106 System.out.println("Installing printer (requires Windows platform and administrator)");
107 ConvertPrinter.install();
108 System.out.println("Installed printer " + ConvertPrinter.getPrinterName());
109 // the function ConvertToXpsFromFile may require the printer so leave it installed
110 // uninstallPrinterWhenDone = true;
111 }
112 catch (PDFNetException e)
113 {
114 System.out.println("ERROR: Unable to install printer.");
115 System.out.println(e);
116 err = true;
117 }
118 catch (Exception e)
119 {
120 System.out.println("ERROR: Unable to install printer. Make sure that the package's bitness matches your operating system's bitness and that you are running with administrator privileges.");
121 }
122 }
123 }
124 catch (PDFNetException e)
125 {
126 System.out.println("ERROR: Unable to install printer.");
127 System.out.println(e);
128 err = true;
129 }
130
131 for (Testfile file : testfiles)
132 {
133 try (PDFDoc pdfdoc = new PDFDoc())
134 {
135 if (Convert.requiresPrinter(inputPath + file.inputFile))
136 {
137 System.out.println("Using PDFNet printer to convert file " + file.inputFile);
138 }
139 Convert.toPdf(pdfdoc, inputPath + file.inputFile);
140 pdfdoc.save(outputPath + file.outputFile, SDFDoc.SaveMode.LINEARIZED, null);
141 System.out.println("Converted file: " + file.inputFile);
142 System.out.println("to: " + file.outputFile);
143 }
144 catch (PDFNetException e)
145 {
146 System.out.println("ERROR: on input file " + file.inputFile);
147 System.out.println(e);
148 err = true;
149 }
150 }
151
152 return err;
153 }
154
155 /// <summary>
156 /// The main entry point for the application.
157 /// </summary>
158 public static void main(String[] args)
159 {
160 if (System.getProperty("os.name").startsWith("Windows")) {
161
162 PDFNet.initialize(PDFTronLicense.Key());
163 boolean err = false;
164
165 err = ConvertToPdfFromFile();
166 if (err)
167 {
168 System.out.println("ConvertFile failed");
169 }
170 else
171 {
172 System.out.println("ConvertFile succeeded");
173 }
174
175 err = ConvertSpecificFormats();
176 if (err)
177 {
178 System.out.println("ConvertSpecificFormats failed");
179 }
180 else
181 {
182 System.out.println("ConvertSpecificFormats succeeded");
183 }
184
185 try
186 {
187 System.out.println("Uninstalling printer (requires Windows platform and administrator)");
188 ConvertPrinter.uninstall();
189 System.out.println("Uninstalled printer " + ConvertPrinter.getPrinterName());
190 }
191 catch (Exception e)
192 {
193 System.out.println("Unable to uninstall printer");
194 err = true;
195 }
196
197 System.out.println("Done.");
198
199 PDFNet.terminate();
200 }
201 else {
202 System.out.println("ConvertPrintTest only available on Windows");
203 }
204 }
205
206}
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 to PDF with virtual printer on Windows.
8// It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
9// https://docs.apryse.com/windows/guides/features/conversion/convert-other/
10//
11// To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
12// The installing application must be run as administrator. The manifest for this sample
13// specifies appropriate the UAC elevation.
14//
15// Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
16// For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
17// equivalent redistributables). You can download the XPS Essentials Pack from:
18// http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
19// Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
20// http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
21//
22// Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+.
23//
24// Please contact us if you have any questions.
25//---------------------------------------------------------------------------------------
26
27const { PDFNet } = require('@pdftron/pdfnet-node');
28const PDFTronLicense = require('../LicenseKey/LicenseKey');
29
30((exports) => {
31 'use strict';
32
33 let Testfile = function (inputFile, outputFile) {
34 this.inputFile = inputFile;
35 this.outputFile = outputFile;
36 }
37
38 const testfiles = [
39 new Testfile('simple-word_2007.docx', 'docx2pdf.pdf'),
40 new Testfile('simple-powerpoint_2007.pptx', 'pptx2pdf.pdf'),
41 new Testfile('simple-excel_2007.xlsx', 'xlsx2pdf.pdf'),
42 new Testfile('simple-publisher.pub', 'pub2pdf.pdf'),
43 new Testfile('simple-text.txt', 'txt2pdf.pdf'),
44 new Testfile('simple-rtf.rtf', 'rtf2pdf.pdf'),
45 new Testfile('simple-emf.emf', 'emf2pdf.pdf'),
46 new Testfile('simple-webpage.mht','mht2pdf.pdf'),
47 new Testfile('simple-webpage.html', 'html2pdf.pdf'),
48 ]
49
50
51
52 const inputPath = '../TestFiles/';
53 const outputPath = '../TestFiles/Output/';
54
55 exports.runConvertPrintTest = () => {
56
57 const main = async () => {
58 if (process.platform === 'win32') {
59 try {
60 await convertToPdfFromFile();
61 console.log('ConvertFile succeeded');
62 } catch (err) {
63 console.log('ConvertFile failed');
64 console.log(err);
65 }
66
67 try {
68 await convertSpecificFormats();
69 console.log('ConvertSpecificFormats succeeded');
70 } catch (err) {
71 console.log('ConvertSpecificFormats failed');
72 console.log(err);
73 }
74 if (await PDFNet.Convert.printerIsInstalled()) {
75 try {
76 console.log('Uninstalling printer (requires Windows platform and administrator)');
77 await PDFNet.Convert.printerUninstall();
78 console.log('Uninstalled printer ' + await PDFNet.Convert.printerGetPrinterName());
79 } catch (err) {
80 console.log('Unable to uninstall printer');
81 }
82 }
83 console.log('Done.');
84 }
85 else {
86 console.log('ConvertPrintTest only available on Windows');
87 }
88 };
89
90 const convertToPdfFromFile = async () => {
91 if (await PDFNet.Convert.printerIsInstalled('PDFTron PDFNet')) {
92 await PDFNet.Convert.printerSetPrinterName('PDFTron PDFNet');
93 } else if (!(await PDFNet.Convert.printerIsInstalled())) {
94 try {
95 // This will fail if not run as administrator. Harmless if PDFNet
96 // printer already installed
97 console.log('Installing printer (requires Windows platform and administrator)');
98 await PDFNet.Convert.printerInstall();
99 console.log('Installed printer ' + await PDFNet.Convert.printerGetPrinterName());
100 } catch (err) {
101 console.log('Unable to install printer');
102 }
103 }
104 for (const testfile of testfiles) {
105
106 try {
107 const pdfdoc = await PDFNet.PDFDoc.create();
108 await pdfdoc.initSecurityHandler();
109 const inputFile = inputPath + testfile.inputFile;
110 const outputFile = outputPath + testfile.outputFile;
111 if (await PDFNet.Convert.requiresPrinter(inputFile)) {
112 console.log('Using PDFNet printer to convert file ' + testfile.inputFile);
113 }
114 await PDFNet.Convert.toPdf(pdfdoc, inputFile);
115 await pdfdoc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
116 console.log('Converted file: ' + testfile.inputFile + '\nto: ' + testfile.outputFile);
117 } catch (err) {
118 console.log('Unable to convert file ' + testfile.inputFile);
119 console.log(err);
120 }
121 }
122 };
123
124 const convertSpecificFormats = async () => {
125
126 try {
127 // Convert MSWord document to XPS
128 console.log('Converting DOCX to XPS');
129 await PDFNet.Convert.fileToXps(inputPath + 'simple-word_2007.docx', outputPath + 'simple-word_2007.xps');
130 console.log('Saved simple-word_2007.xps');
131 } catch (err) {
132 console.log(err);
133 }
134 try {
135 const pdfdoc = await PDFNet.PDFDoc.create();
136 await pdfdoc.initSecurityHandler();
137
138 console.log('Converting from EMF');
139 await PDFNet.Convert.fromEmf(pdfdoc, inputPath + 'simple-emf.emf');
140 await pdfdoc.save(outputPath + 'emf2pdf v2.pdf', PDFNet.SDFDoc.SaveOptions.e_linearized);
141 console.log('Saved emf2pdf v2.pdf');
142 } catch (err) {
143 console.log(err);
144 }
145 };
146 PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
147 console.log('Error: ' + JSON.stringify(error));
148 }).then(function(){ return PDFNet.shutdown(); });
149 };
150 exports.runConvertPrintTest();
151})(exports);
152// eslint-disable-next-line spaced-comment
153//# sourceURL=ConvertPrintTest.js
1'
2' Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3'
4
5Imports System
6Imports System.Drawing
7Imports System.Drawing.Drawing2D
8Imports pdftron
9Imports pdftron.Common
10Imports pdftron.Filters
11Imports pdftron.SDF
12Imports pdftron.PDF
13
14' The following sample illustrates how to convert to PDF with virtual printer on Windows.
15' It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
16' https://docs.apryse.com/windows/guides/features/conversion/convert-other/
17'
18' To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
19' The installing application must be run as administrator. The manifest for this sample
20' specifies appropriate the UAC elevation.
21'
22' Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7, or .NET Framework
23' 3.x or higher. For older versions of .NET Framework running on Windows XP or Vista SP0 you need to install
24' the XPS Essentials Pack (or equivalent redistributables).
25'
26' Also note that conversion under ASP.NET can be tricky to configure. Please see the following document for advice:
27' http://www.pdftron.com/pdfnet/faq_files/Converting_Documents_in_Windows_Service_or_ASP.NET_Application_using_PDFNet.pdf
28Module ConvertPrintTestVB
29 Class Testfile
30 Public inputFile, outputFile As String
31
32 Public Sub New(ByVal inFile As String, ByVal outFile As String)
33 inputFile = inFile
34 outputFile = outFile
35 End Sub
36 End Class
37
38 Class Class1
39 Shared pdfNetLoader As pdftron.PDFNetLoader = pdftron.PDFNetLoader.Instance()
40
41 Shared Sub New()
42 End Sub
43
44 Const inputPath As String = "../../../../TestFiles/"
45 Const outputPath As String = "../../../../TestFiles/Output/"
46
47 Private Shared Function ConvertSpecificFormats() As Boolean
48 Dim err As Boolean = False
49 Try
50 Using pdfdoc As PDFDoc = New PDFDoc()
51 Console.WriteLine("Converting from EMF")
52 pdftron.PDF.Convert.FromEmf(pdfdoc, inputPath & "simple-emf.emf")
53 pdfdoc.Save(outputPath & "emf2pdf v2.pdf", SDFDoc.SaveOptions.e_remove_unused)
54 Console.WriteLine("Saved emf2pdf v2.pdf")
55 End Using
56
57 Catch e As PDFNetException
58 Console.WriteLine(e.Message)
59 err = True
60 End Try
61
62 Try
63 Console.WriteLine("Converting DOCX to XPS")
64 pdftron.PDF.Convert.ToXps(inputPath & "simple-word_2007.docx", outputPath & "simple-word_2007.xps")
65 Console.WriteLine("Saved simple-word_2007.xps")
66 Catch e As PDFNetException
67 Console.WriteLine(e.Message)
68 err = True
69 End Try
70
71 Return err
72 End Function
73
74 Private Shared Function ConvertToPdfFromFile() As Boolean
75 Dim testfiles As System.Collections.ArrayList = New System.Collections.ArrayList()
76 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-powerpoint_2007.pptx", "pptx2pdf.pdf"))
77 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-text.txt", "txt2pdf.pdf"))
78 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-word_2007.docx", "docx2pdf.pdf"))
79 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-rtf.rtf", "rtf2pdf.pdf"))
80 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-excel_2007.xlsx", "xlsx2pdf.pdf"))
81 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-publisher.pub", "pub2pdf.pdf"))
82 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-emf.emf", "emf2pdf.pdf"))
83 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-webpage.mht", "mht2pdf.pdf"))
84 testfiles.Add(New ConvertPrintTestVB.Testfile("simple-webpage.html", "html2pdf.pdf"))
85 Dim err As Boolean = False
86
87 Try
88 If pdftron.PDF.Convert.Printer.IsInstalled("PDFTron PDFNet") Then
89 pdftron.PDF.Convert.Printer.SetPrinterName("PDFTron PDFNet")
90 ElseIf Not pdftron.PDF.Convert.Printer.IsInstalled() Then
91
92 Try
93 Console.WriteLine("Installing printer (requires Windows platform and administrator)")
94 pdftron.PDF.Convert.Printer.Install()
95 Console.WriteLine("Installed printer " & pdftron.PDF.Convert.Printer.GetPrinterName())
96 Catch e As PDFNetException
97 Console.WriteLine("ERROR: Unable to install printer.")
98 Console.WriteLine(e.Message)
99 err = True
100 Catch
101 Console.WriteLine("ERROR: Unable to install printer. Make sure that the package's bitness matches your operating system's bitness and that you are running with administrator privileges.")
102 End Try
103 End If
104
105 Catch e As PDFNetException
106 Console.WriteLine("ERROR: Unable to install printer.")
107 Console.WriteLine(e.Message)
108 err = True
109 End Try
110
111 For Each file As Testfile In testfiles
112
113 Try
114
115 Using pdfdoc As pdftron.PDF.PDFDoc = New PDFDoc()
116
117 If pdftron.PDF.Convert.RequiresPrinter(inputPath & file.inputFile) Then
118 Console.WriteLine("Using PDFNet printer to convert file " & file.inputFile)
119 End If
120
121 pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath & file.inputFile)
122 pdfdoc.Save(outputPath & file.outputFile, SDFDoc.SaveOptions.e_linearized)
123 Console.WriteLine("Converted file: " & file.inputFile)
124 Console.WriteLine("to: " & file.outputFile)
125 End Using
126
127 Catch e As PDFNetException
128 Console.WriteLine("ERROR: on input file " & file.inputFile)
129 Console.WriteLine(e.Message)
130 err = True
131 End Try
132 Next
133
134 Return err
135 End Function
136
137 <STAThread>
138 Shared Sub Main(ByVal args As String())
139 ' Virtual printer only available on Windows
140 If Environment.OSVersion.Platform = PlatformID.Win32NT Then
141 PDFNet.Initialize(PDFTronLicense.Key)
142 Dim err As Boolean = False
143 err = ConvertToPdfFromFile()
144
145 If err Then
146 Console.WriteLine("ConvertFile failed")
147 Else
148 Console.WriteLine("ConvertFile succeeded")
149 End If
150
151 err = ConvertSpecificFormats()
152
153 If err Then
154 Console.WriteLine("ConvertSpecificFormats failed")
155 Else
156 Console.WriteLine("ConvertSpecificFormats succeeded")
157 End If
158
159 If pdftron.PDF.Convert.Printer.IsInstalled() Then
160 Try
161 Console.WriteLine("Uninstalling printer (requires Windows platform and administrator)")
162 pdftron.PDF.Convert.Printer.Uninstall()
163 Console.WriteLine("Uninstalled Printer " & pdftron.PDF.Convert.Printer.GetPrinterName())
164 Catch
165 Console.WriteLine("Unable to uninstall printer")
166 End Try
167 End If
168
169 PDFNet.Terminate()
170 Console.WriteLine("Done.")
171 Else
172 Console.WriteLine("ConvertPrintTest only available on Windows")
173 End If
174 End Sub
175 End Class
176End Module
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
9from PDFNetPython import *
10
11import platform
12
13sys.path.append("../../LicenseKey/PYTHON")
14from LicenseKey import *
15
16#---------------------------------------------------------------------------------------
17# The following sample illustrates how to convert to PDF with virtual printer on Windows.
18# It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
19# https://docs.apryse.com/windows/guides/features/conversion/convert-other/
20#
21# To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
22# The installing application must be run as administrator. The manifest for this sample
23# specifies appropriate the UAC elevation.
24#
25# Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
26# For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
27# equivalent redistributables). You can download the XPS Essentials Pack from:
28# http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
29# Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
30# http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
31#
32# Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+.
33#
34# Please contact us if you have any questions.
35#---------------------------------------------------------------------------------------
36
37# Relative path to the folder containing the test files.
38inputPath = "../../TestFiles/"
39outputPath = "../../TestFiles/Output/"
40
41
42
43def ConvertSpecificFormats():
44 ret = 0
45 try:
46 # Convert MSWord document to XPS
47 print("Converting DOCX to XPS")
48 outputFile = "simple-word_2007.xps"
49 Convert.ToXps(inputPath + "simple-word_2007.docx", outputPath + outputFile)
50 print("Saved " + outputFile)
51 except:
52 ret = 1
53
54 try:
55 # Start with a PDFDoc to collect the converted documents
56 pdfdoc = PDFDoc()
57 # Convert the EMF document to PDF
58 s1 = inputPath + "simple-emf.emf"
59 print("Converting from EMF")
60 Convert.FromEmf(pdfdoc, s1)
61 outputFile = "emf2pdf v2.pdf"
62 pdfdoc.Save(outputPath + outputFile, SDFDoc.e_remove_unused)
63 print("Saved " + outputFile)
64 except:
65 ret = 1
66 return ret
67
68# convert from a file to PDF automatically
69def ConvertToPdfFromFile():
70 testfiles = [
71 [ "simple-word_2007.docx","docx2pdf.pdf"],
72 [ "simple-powerpoint_2007.pptx","pptx2pdf.pdf"],
73 [ "simple-excel_2007.xlsx","xlsx2pdf.pdf"],
74 [ "simple-publisher.pub","pub2pdf.pdf"],
75 [ "simple-text.txt","txt2pdf.pdf"],
76 [ "simple-rtf.rtf","rtf2pdf.pdf"],
77 [ "simple-emf.emf","emf2pdf.pdf"],
78 [ "simple-webpage.mht","mht2pdf.pdf"],
79 [ "simple-webpage.html","html2pdf.pdf"]
80 ]
81 ret = 0
82
83 try:
84 if ConvertPrinter.IsInstalled("PDFTron PDFNet"):
85 ConvertPrinter.SetPrinterName("PDFTron PDFNet")
86 elif not ConvertPrinter.isInstalled():
87 try:
88 print("Installing printer (requires Windows platform and administrator)")
89 ConvertPrinter.Install()
90 print("Installed printer " + ConvertPrinter.getPrinterName())
91 # the function ConvertToXpsFromFile may require the printer so leave it installed
92 # uninstallPrinterWhenDone = true;
93 except:
94 print("ERROR: Unable to install printer.")
95 except:
96 print("ERROR: Unable to install printer.")
97
98 for testfile in testfiles:
99 try:
100 pdfdoc = PDFDoc()
101 inputFile = testfile[0]
102 outputFile = testfile[1]
103 if Convert.RequiresPrinter(inputPath + inputFile):
104 print("Using PDFNet printer to convert file " + inputFile)
105 Convert.ToPdf(pdfdoc, inputPath + inputFile)
106 pdfdoc.Save(outputPath + outputFile, SDFDoc.e_compatibility)
107 pdfdoc.Close()
108 print("Converted file: " + inputFile + "\nto: " + outputFile)
109 except:
110 ret = 1
111 print("ERROR: on input file " + inputFile)
112 return ret
113
114
115def main():
116 if platform.system() == 'Windows':
117 # The first step in every application using PDFNet is to initialize the
118 # library. The library is usually initialized only once, but calling
119 # Initialize() multiple times is also fine.
120 PDFNet.Initialize(LicenseKey)
121
122 # Demonstrate Convert.ToPdf and Convert.Printer
123 err = ConvertToPdfFromFile()
124 if err:
125 print("ConvertFile failed")
126 else:
127 print("ConvertFile succeeded")
128
129 # Demonstrate Convert.[FromEmf, FromXps, ToEmf, ToSVG, ToXPS]
130 err = ConvertSpecificFormats()
131 if err:
132 print("ConvertSpecificFormats failed")
133 else:
134 print("ConvertSpecificFormats succeeded")
135
136 try:
137 print("Uninstalling printer (requires Windows platform and administrator)")
138 ConvertPrinter.Uninstall()
139 print("Uninstalled printer " + ConvertPrinter.getPrinterName())
140 except:
141 print("Unable to uninstall printer")
142
143 PDFNet.Terminate()
144 print("Done.")
145 else:
146 print("ConvertPrintTest only available on Windows")
147
148if __name__ == '__main__':
149 main()
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales