Sample C# code demonstrates how to use the Apryse CAD module for direct, high-quality conversion from DWG, DXF, DGN, DWF, and RVT to PDF. Learn more about our Server SDK and PDF Conversion Library.
1//---------------------------------------------------------------------------------------
2// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
3// Consult legal.txt regarding legal and license information.
4//---------------------------------------------------------------------------------------
5
6using System;
7using System.Drawing;
8using System.Drawing.Imaging;
9using System.Runtime.InteropServices;
10
11using pdftron;
12using pdftron.Common;
13using pdftron.PDF;
14using pdftron.SDF;
15
16namespace CAD2PDFTestCS
17{
18 /// <summary>
19 //---------------------------------------------------------------------------------------
20 // The following sample illustrates how to convert CAD documents (such as dwg, dgn, rvt,
21 // dxf, dwf) to pdf
22 //---------------------------------------------------------------------------------------
23 /// </summary>
24 class Class1
25 {
26 private static pdftron.PDFNetLoader pdfNetLoader = pdftron.PDFNetLoader.Instance();
27 static Class1() {}
28
29 /// <summary>
30 /// Check file extension
31 /// </summary>
32 static bool IsRVTFile(string input_file_name)
33 {
34 bool rvt_input = false;
35 if (input_file_name.Length > 2)
36 {
37 if (input_file_name.Substring(input_file_name.Length - 3, 3) == "rvt")
38 {
39 rvt_input = true;
40 }
41 }
42 return rvt_input;
43 }
44
45 /// <summary>
46 /// The main entry point for the application.
47 /// </summary>
48 static void Main(string[] args)
49 {
50 // The first step in every application using PDFNet is to initialize the
51 // library and set the path to common PDF resources. The library is usually
52 // initialized only once, but calling Initialize() multiple times is also fine.
53 PDFNet.Initialize(PDFTronLicense.Key);
54 PDFNet.AddResourceSearchPath("../../../../../Lib/");
55 if (!CADModule.IsModuleAvailable())
56 {
57 Console.WriteLine();
58 Console.WriteLine("Unable to run CAD2PDFTest: Apryse SDK CAD module not available.");
59 Console.WriteLine("---------------------------------------------------------------");
60 Console.WriteLine("The CAD module is an optional add-on, available for download");
61 Console.WriteLine("at http://www.pdftron.com/. If you have already downloaded this");
62 Console.WriteLine("module, ensure that the SDK is able to find the required files");
63 Console.WriteLine("using the PDFNet::AddResourceSearchPath() function.");
64 Console.WriteLine();
65 }
66
67 // Relative path to the folder containing test files.
68 string input_path = "../../../../TestFiles/CAD/";
69 string output_path = "../../../../TestFiles/Output/";
70
71 string input_file_name = "construction drawings color-28.05.18.dwg";
72 string output_file_name = "construction drawings color-28.05.18.pdf";
73
74 if (args.Length != 0)
75 {
76 input_file_name = args[0];
77 output_file_name = input_file_name + ".pdf";
78 }
79
80 Console.WriteLine("Example cad:");
81 try
82 {
83 using (PDFDoc pdfdoc = new PDFDoc())
84 {
85 if (IsRVTFile(input_file_name))
86 {
87 CADConvertOptions opts = new CADConvertOptions();
88 opts.SetPageWidth(800);
89 opts.SetPageHeight(600);
90 opts.SetRasterDPI(150);
91
92 pdftron.PDF.Convert.FromCAD(pdfdoc, input_path + input_file_name, opts);
93 }
94 else
95 {
96 pdftron.PDF.Convert.FromCAD(pdfdoc, input_path + input_file_name, null);
97 }
98 pdfdoc.Save(output_path + output_file_name, SDFDoc.SaveOptions.e_remove_unused);
99 }
100
101 Console.WriteLine("Done.");
102 }
103 catch (PDFNetException e)
104 {
105 Console.WriteLine(e.Message);
106 }
107 PDFNet.Terminate();
108 }
109 }
110}
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 <PDF/PDFNet.h>
7#include <PDF/PDFDoc.h>
8#include <PDF/Convert.h>
9#include <PDF/CADModule.h>
10#include <PDF/CADConvertOptions.h>
11#include <string>
12#include <iostream>
13#include <stdio.h>
14#include "../../LicenseKey/CPP/LicenseKey.h"
15
16using namespace pdftron;
17using namespace pdftron::SDF;
18using namespace PDF;
19using namespace std;
20
21
22//---------------------------------------------------------------------------------------
23// The following sample illustrates how to convert CAD documents to PDF format
24//
25// The CAD module is an optional PDFNet Add-on that can be used to convert CAD
26// documents into PDF documents
27//
28// The Apryse SDK CAD module can be downloaded from http://www.pdftron.com/
29//---------------------------------------------------------------------------------------
30
31UString inputPath("../../TestFiles/CAD/");
32UString outputPath("../../TestFiles/Output/");
33
34bool IsRVTFile(UString inputFile)
35{
36 bool rvt_input = false;
37 if (inputFile.GetLength() > 2)
38 {
39 if (inputFile.SubStr(inputFile.GetLength() - 3, 3) == "rvt")
40 {
41 rvt_input = true;
42 }
43 }
44 return rvt_input;
45}
46
47int main(int argc, char *argv[])
48{
49 int ret = 0;
50
51 try
52 {
53 // The first step in every application using PDFNet is to initialize the
54 // library and set the path to common PDF resources. The library is usually
55 // initialized only once, but calling Initialize() multiple times is also fine.
56 PDFNet::Initialize(LicenseKey);
57 PDFNet::AddResourceSearchPath("../../../Lib/");
58 if(!CADModule::IsModuleAvailable())
59 {
60 cout << endl;
61 cout << "Unable to run CAD2PDFTest: Apryse SDK CAD module not available." << endl;
62 cout << "---------------------------------------------------------------" << endl;
63 cout << "The CAD module is an optional add-on, available for download" << endl;
64 cout << "at http://www.pdftron.com/. If you have already downloaded this" << endl;
65 cout << "module, ensure that the SDK is able to find the required files" << endl;
66 cout << "using the PDFNet::AddResourceSearchPath() function." << endl << endl;
67 return 0;
68 }
69
70 typedef struct
71 {
72 UString inputFile, outputFile;
73 } TestFile;
74
75 UString inputFileName, outputFileName;
76 if (argv[1])
77 {
78 inputFileName = argv[1];
79 }
80 else
81 {
82 inputFileName = "construction drawings color-28.05.18.dwg";
83 }
84 outputFileName = inputFileName + ".pdf";
85
86 TestFile testFiles[] =
87 {
88 { inputFileName, outputFileName},
89 };
90
91 unsigned int ceTestFiles = sizeof(testFiles) / sizeof(TestFile);
92 for (unsigned int i = 0; i < ceTestFiles; i++)
93 {
94
95 // Convert the rest of the samples
96 if (IsRVTFile(testFiles[i].inputFile))
97 {
98 try
99 {
100 PDFDoc pdfdoc;
101 // Convert rvt file with some user options
102 CADConvertOptions opts;
103 opts.SetPageWidth(800);
104 opts.SetPageHeight(600);
105 opts.SetRasterDPI(150);
106
107 Convert::FromCAD(pdfdoc, inputPath + testFiles[i].inputFile, &opts);
108 pdfdoc.Save(outputPath + testFiles[i].outputFile, SDF::SDFDoc::e_linearized, NULL);
109 }
110 catch (Common::Exception& e)
111 {
112 cout << "Unable to convert file " << testFiles[i].inputFile << endl;
113 cout << e << endl;
114 ret = 1;
115 }
116 catch (...)
117 {
118 cout << "Unknown Exception" << endl;
119 ret = 1;
120 }
121 }
122 else
123 {
124 try
125 {
126 PDFDoc pdfdoc;
127 Convert::FromCAD(pdfdoc, inputPath + testFiles[i].inputFile, NULL);
128 pdfdoc.Save(outputPath + testFiles[i].outputFile, SDF::SDFDoc::e_linearized, NULL);
129 }
130 catch (Common::Exception& e)
131 {
132 cout << "Unable to convert file " << testFiles[i].inputFile << endl;
133 cout << e << endl;
134 ret = 1;
135 }
136 catch (...)
137 {
138 cout << "Unknown Exception" << endl;
139 ret = 1;
140 }
141 }
142 }
143
144 }
145 catch (Common::Exception& e)
146 {
147 cout << e << endl;
148 ret = 1;
149 }
150 catch (...)
151 {
152 cout << "Unknown Exception" << endl;
153 ret = 1;
154 }
155 PDFNet::Terminate();
156 return ret;
157}
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// Relative path to the folder containing test files.
15var inputPath = "../../TestFiles/CAD/"
16var outputPath = "../../TestFiles/Output/"
17
18// ---------------------------------------------------------------------------------------
19// The following sample illustrates how to use CAD module
20// --------------------------------------------------------------------------------------
21
22func main(){
23
24 // The first step in every application using PDFNet is to initialize the
25 // library and set the path to common PDF resources. The library is usually
26 // initialized only once, but calling Initialize() multiple times is also fine.
27 PDFNetInitialize(PDFTronLicense.Key)
28
29 // The location of the CAD Module
30 PDFNetAddResourceSearchPath("../../../PDFNetC/Lib/")
31
32 if ! CADModuleIsModuleAvailable(){
33
34 fmt.Println("Unable to run CAD2PDFTest: PDFTron SDK CAD module not available.\n" +
35 "---------------------------------------------------------------\n" +
36 "The CAD module is an optional add-on, available for download\n" +
37 "at http://www.pdftron.com/. If you have already downloaded this\n" +
38 "module, ensure that the SDK is able to find the required files\n" +
39 "using the PDFNet::AddResourceSearchPath() function.")
40
41 }else{
42
43 inputFileName := "construction drawings color-28.05.18.dwg"
44 outputFileName := inputFileName + ".pdf"
45 doc := NewPDFDoc()
46 ConvertFromCAD(doc, inputPath + inputFileName)
47 doc.Save(outputPath + outputFileName, uint(0))
48 }
49 PDFNetTerminate()
50 fmt.Println("CAD2PDF conversion example")
51}
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.*;
8import com.pdftron.sdf.Obj;
9import com.pdftron.sdf.ObjSet;
10import com.pdftron.sdf.SDFDoc;
11
12//---------------------------------------------------------------------------------------
13// The following sample illustrates how to convert CAD documents to PDF format using
14// the CAD2PDF class.
15//
16// 'pdftron.PDF.CAD2PDF' is an optional PDFNet Add-On utility class that can be
17// used to convert CAD documents into PDF documents by using an external module (cad2pdf).
18//
19// cad2pdf modules can be downloaded from http://www.pdftron.com/pdfnet/downloads.html.
20//---------------------------------------------------------------------------------------
21public class CAD2PDFTest {
22
23 public static boolean IsRVTFile(String input_file_name)
24 {
25 boolean rvt_input = false;
26
27 if (input_file_name.length() > 2)
28 {
29 if (input_file_name.substring(input_file_name.length() - 3, input_file_name.length()).equals("rvt"))
30 {
31 rvt_input = true;
32 }
33 }
34 return rvt_input;
35 }
36
37 public static void main(String[] args) {
38 String input_file_name = "construction drawings color-28.05.18.dwg";
39 String output_file_name = input_file_name + ".pdf";
40 if (args.length != 0)
41 {
42 input_file_name = args[0];
43 output_file_name = input_file_name + ".pdf";
44 }
45 PDFNet.initialize(PDFTronLicense.Key());
46 try
47 {
48 PDFNet.addResourceSearchPath("../../../Lib/");
49 if(!CADModule.isModuleAvailable())
50 {
51 System.out.println();
52 System.out.println("Unable to run CAD2PDFTest: Apryse SDK CAD module not available.");
53 System.out.println("---------------------------------------------------------------");
54 System.out.println("The CAD module is an optional add-on, available for download");
55 System.out.println("at http://www.pdftron.com/. If you have already downloaded this");
56 System.out.println("module, ensure that the SDK is able to find the required files");
57 System.out.println("using the PDFNet::AddResourceSearchPath() function." );
58 System.out.println();
59 }
60 } catch (PDFNetException e) {
61 System.out.println("CAD module not available, error:");
62 e.printStackTrace();
63 System.out.println(e);
64 }
65
66
67 // Relative path to the folder containing test files.
68 String input_path = "../../TestFiles/CAD/";
69 String output_path = "../../TestFiles/Output/";
70 String outputFile;
71 boolean printerInstalled = false;
72
73 try (PDFDoc doc = new PDFDoc()) {
74 if (IsRVTFile(input_file_name))
75 {
76 CADConvertOptions opts = new CADConvertOptions();
77 opts.setPageHeight(800);
78 opts.setPageWidth(300);
79 Convert.fromCAD(doc, input_path + input_file_name, opts);
80 }
81 else
82 {
83 Convert.fromCAD(doc, input_path + input_file_name, null);
84 }
85 outputFile = output_path + output_file_name;
86 doc.save(outputFile, SDFDoc.SaveMode.LINEARIZED, null);
87 } catch (PDFNetException e) {
88 System.out.println("Unable to convert DWG document, error:");
89 e.printStackTrace();
90 System.out.println(e);
91 }
92 PDFNet.terminate();
93 }
94}
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//---------------------------------------------------------------------------------------
8// The following sample illustrates how to convert CAD documents to PDF format
9//
10// The CAD module is an optional PDFNet Add-on that can be used to convert CAD
11// documents into PDF documents
12//
13// The Apryse SDK CAD module can be downloaded from http://www.pdftron.com/
14//---------------------------------------------------------------------------------------
15
16
17const { PDFNet } = require('@pdftron/pdfnet-node');
18const PDFTronLicense = require('../LicenseKey/LicenseKey');
19
20((exports) => {
21 'use strict';
22
23 exports.runCAD2PDFTest = () => {
24 const IsRVTFile = function (inputFile) {
25 let rvt_input = false;
26 if (inputFile.length > 2) {
27 if (inputFile.substr(inputFile.length - 3, 3) === 'rvt') {
28 rvt_input = true;
29 }
30 }
31 return rvt_input;
32 }
33
34 const main = async () => {
35 try {
36 await PDFNet.addResourceSearchPath('../../lib/');
37 if (!(await PDFNet.CADModule.isModuleAvailable())) {
38 console.log('\nUnable to run CAD2PDFTest: Apryse SDK CAD module not available.');
39 console.log('---------------------------------------------------------------');
40 console.log('The CAD module is an optional add-on, available for download');
41 console.log('at http://www.pdftron.com/. If you have already downloaded this');
42 console.log('module, ensure that the SDK is able to find the required files');
43 console.log('using the PDFNet.addResourceSearchPath() function.\n');
44
45 return;
46 }
47
48 // Relative path to the folder containing test files.
49 const inputPath = '../TestFiles/CAD/';
50 const outputPath = '../TestFiles/Output/';
51
52 const input_file_name = 'construction drawings color-28.05.18.dwg';
53 const output_file_name = 'construction drawings color-28.05.18.pdf';
54
55 const doc = await PDFNet.PDFDoc.create();
56 doc.initSecurityHandler();
57
58 if (IsRVTFile(input_file_name)) {
59 const opts = new PDFNet.Convert.CADConvertOptions();
60 opts.setPageWidth(800);
61 opts.setPageHeight(600);
62 opts.setRasterDPI(150);
63 await PDFNet.Convert.fromCAD(doc, inputPath + input_file_name, opts);
64 } else {
65 await PDFNet.Convert.fromCAD(doc, inputPath + input_file_name);
66 }
67 const outputFile = outputPath + output_file_name;
68 await doc.save(outputFile, PDFNet.SDFDoc.SaveOptions.e_linearized);
69 } catch (err) {
70 console.log(err);
71 }
72 };
73 PDFNet.runWithCleanup(main, PDFTronLicense.Key).catch(function(error) {
74 console.log('Error: ' + JSON.stringify(error));
75 }).then(function(){ return PDFNet.shutdown(); });
76 };
77 exports.runCAD2PDFTest();
78})(exports);
79// eslint-disable-next-line spaced-comment
80//# sourceURL=CAD2PDFTest.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// Relative path to the folder containing the test files.
11$input_path = getcwd()."/../../TestFiles/CAD/";
12$output_path = getcwd()."/../../TestFiles/Output/";
13
14//---------------------------------------------------------------------------------------
15// The following sample illustrates how to use CAD module
16//---------------------------------------------------------------------------------------
17
18 // The first step in every application using PDFNet is to initialize the
19 // library and set the path to common PDF resources. The library is usually
20 // initialized only once, but calling Initialize() multiple times is also fine.
21 PDFNet::Initialize($LicenseKey);
22 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.
23
24 // The location of the CAD Module
25 PDFNet::AddResourceSearchPath("../../../Lib/");
26 if(!CADModule::IsModuleAvailable()) {
27 echo "Unable to run CAD2PDFTest: PDFTron SDK CAD module not available.\n
28 ---------------------------------------------------------------\n
29 The CAD module is an optional add-on, available for download\n
30 at https://dev.apryse.com/. If you have already downloaded this\n
31 module, ensure that the SDK is able to find the required files\n
32 using the PDFNet::AddResourceSearchPath() function.\n";
33 } else
34 {
35 $doc = new PDFDoc();
36 Convert::FromCAD($doc, $input_path."construction drawings color-28.05.18.dwg");
37 $doc->Save($output_path."construction drawings color-28.05.18.dwg.pdf", 0);
38 echo "CAD2PDF conversion example \n";
39 }
40 PDFNet::Terminate();
41?>
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
11sys.path.append("../../LicenseKey/PYTHON")
12from LicenseKey import *
13
14# Relative path to the folder containing test files.
15input_path = "../../TestFiles/CAD/"
16output_path = "../../TestFiles/Output/"
17
18# ---------------------------------------------------------------------------------------
19# The following sample illustrates how to use CAD module
20# --------------------------------------------------------------------------------------
21
22def main():
23
24 # The first step in every application using PDFNet is to initialize the
25 # library and set the path to common PDF resources. The library is usually
26 # initialized only once, but calling Initialize() multiple times is also fine.
27 PDFNet.Initialize(LicenseKey)
28
29 # The location of the CAD Module
30 PDFNet.AddResourceSearchPath("../../../PDFNetC/Lib/")
31
32 if not CADModule.IsModuleAvailable():
33
34 print("""
35 Unable to run CAD2PDFTest: PDFTron SDK CAD module not available.
36 ---------------------------------------------------------------
37 The CAD module is an optional add-on, available for download
38 at https://dev.apryse.com/. If you have already downloaded this
39 module, ensure that the SDK is able to find the required files
40 using the PDFNet::AddResourceSearchPath() function.""")
41
42 else:
43
44 inputFileName = "construction drawings color-28.05.18.dwg"
45 outputFileName = inputFileName + ".pdf"
46 doc = PDFDoc()
47 Convert.FromCAD(doc, input_path + inputFileName, None)
48 doc.Save(output_path + outputFileName, 0)
49
50 PDFNet.Terminate()
51 print("CAD2PDF conversion example")
52
53
54if __name__ == '__main__':
55 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# Relative path to the folder containing test files.
13input_path = "../../TestFiles/CAD/"
14output_path = "../../TestFiles/Output/"
15
16#---------------------------------------------------------------------------------------
17# The following sample illustrates how to use CAD module
18#---------------------------------------------------------------------------------------
19
20 # The first step in every application using PDFNet is to initialize the
21 # library and set the path to common PDF resources. The library is usually
22 # initialized only once, but calling Initialize multiple times is also fine.
23 PDFNet.Initialize(PDFTronLicense.Key)
24
25 # The location of the CAD Module
26 PDFNet.AddResourceSearchPath("../../../PDFNetC/Lib/");
27
28 begin
29 if !CADModule.IsModuleAvailable
30 puts 'Unable to run CAD2PDFTest: PDFTron SDK CAD module not available.'
31 puts '---------------------------------------------------------------'
32 puts 'The CAD module is an optional add-on, available for download'
33 puts 'at https://dev.apryse.com/. If you have already downloaded this'
34 puts 'module, ensure that the SDK is able to find the required files'
35 puts 'using the PDFNet::AddResourceSearchPath() function.'
36 else
37 inputFileName = "construction drawings color-28.05.18.dwg"
38 outputFileName = inputFileName + ".pdf"
39 doc = PDFDoc.new
40 Convert.FromCAD(doc, input_path + inputFileName)
41 doc.Save(output_path + outputFileName, 0)
42 puts "CAD2PDF conversion example"
43 doc.Close
44 end
45 rescue Exception=>e
46 puts e
47
48 end
49 PDFNet.Terminate
1Imports System
2Imports System.Drawing
3Imports System.Drawing.Imaging
4Imports System.Runtime.InteropServices
5Imports pdftron
6Imports pdftron.Common
7Imports pdftron.PDF
8Imports pdftron.SDF
9
10Namespace CAD2PDFTestVB
11 Class Class1
12 Private Shared pdfNetLoader As pdftron.PDFNetLoader = pdftron.PDFNetLoader.Instance()
13
14 Private Shared Function IsRVTFile(ByVal input_file_name As String) As Boolean
15 Dim rvt_input As Boolean = False
16
17 If input_file_name.Length > 2 Then
18
19 If input_file_name.Substring(input_file_name.Length - 3, 3) = "rvt" Then
20 rvt_input = True
21 End If
22 End If
23
24 Return rvt_input
25 End Function
26
27 Shared Sub Main(ByVal args As String())
28 PDFNet.Initialize(PDFTronLicense.Key)
29 PDFNet.AddResourceSearchPath("../../../../../Lib/")
30
31 If Not CADModule.IsModuleAvailable() Then
32 Console.WriteLine()
33 Console.WriteLine("Unable to run CAD2PDFTest: Apryse SDK CAD module not available.")
34 Console.WriteLine("---------------------------------------------------------------")
35 Console.WriteLine("The CAD module is an optional add-on, available for download")
36 Console.WriteLine("at http://www.pdftron.com/. If you have already downloaded this")
37 Console.WriteLine("module, ensure that the SDK is able to find the required files")
38 Console.WriteLine("using the PDFNet::AddResourceSearchPath() function.")
39 Console.WriteLine()
40 End If
41
42 Dim input_path As String = "../../../../TestFiles/CAD/"
43 Dim output_path As String = "../../../../TestFiles/Output/"
44 Dim input_file_name As String = "construction drawings color-28.05.18.dwg"
45 Dim output_file_name As String = "construction drawings color-28.05.18.pdf"
46
47 If args.Length <> 0 Then
48 input_file_name = args(0)
49 output_file_name = input_file_name & ".pdf"
50 End If
51
52 Console.WriteLine("Example cad:")
53
54 Try
55
56 Using pdfdoc As PDFDoc = New PDFDoc()
57
58 If IsRVTFile(input_file_name) Then
59 Dim opts As CADConvertOptions = New CADConvertOptions()
60 opts.SetPageWidth(800)
61 opts.SetPageHeight(600)
62 opts.SetRasterDPI(150)
63 pdftron.PDF.Convert.FromCAD(pdfdoc, input_path & input_file_name, opts)
64 Else
65 pdftron.PDF.Convert.FromCAD(pdfdoc, input_path & input_file_name, Nothing)
66 End If
67
68 pdfdoc.Save(output_path & output_file_name, SDFDoc.SaveOptions.e_remove_unused)
69 End Using
70
71 Console.WriteLine("Done.")
72 Catch e As PDFNetException
73 Console.WriteLine(e.Message)
74 End Try
75 PDFNet.Terminate()
76 End Sub
77 End Class
78End Namespace
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales