Skip to content

Commit

Permalink
Added updates for latest PDFTronGo lib update.
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins committed Jun 23, 2023
1 parent f189db0 commit cc8b23a
Show file tree
Hide file tree
Showing 21 changed files with 98,278 additions and 97,488 deletions.
174 changes: 174 additions & 0 deletions pdftron_darwin_arm64.go

Large diffs are not rendered by default.

174 changes: 174 additions & 0 deletions pdftron_darwin_x86_64.go

Large diffs are not rendered by default.

174 changes: 174 additions & 0 deletions pdftron_linux.go

Large diffs are not rendered by default.

178,936 changes: 89,555 additions & 89,381 deletions pdftron_windows.go

Large diffs are not rendered by default.

139 changes: 139 additions & 0 deletions samples/ConvertPrintTest/ConvertPrint_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2023 by Apryse Software Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------

package main
import (
"testing"
"fmt"
"flag"
"runtime"
. "github.com/pdftron/pdftron-go/v2"
)

var licenseKey string
var modulePath string

func init() {
flag.StringVar(&licenseKey, "license", "", "License key for Apryse SDK")
flag.StringVar(&modulePath, "modulePath", "", "Module path for Apryse SDK")
}

//---------------------------------------------------------------------------------------
// The following sample illustrates how to convert to PDF with virtual printer on Windows.
// It supports several input formats like docx, xlsx, rtf, txt, html, pub, emf, etc. For more details, visit
// https://docs.apryse.com/documentation/windows/guides/features/conversion/convert-other/
//
// To check if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert::RequiresPrinter(filename).
// The installing application must be run as administrator. The manifest for this sample
// specifies appropriate the UAC elevation.
//
// Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
// For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
// equivalent redistributables). You can download the XPS Essentials Pack from:
// http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
// Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
// http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
//
// Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+.
//
// Please contact us if you have any questions.
//---------------------------------------------------------------------------------------

// Relative path to the folder containing the test files.
var inputPath = "../../TestFiles/"
var outputPath = "../../TestFiles/Output/"


func ConvertSpecificFormats() bool{
ret := false


// Convert MSWord document to XPS
fmt.Println("Converting DOCX to XPS")
outputFile := "simple-word_2007.xps"
ConvertToXps(inputPath + "simple-word_2007.docx", outputPath + outputFile)
fmt.Println("Saved " + outputFile)

// Start with a PDFDoc to collect the converted documents
pdfdoc := NewPDFDoc()
// Convert the EMF document to PDF
s1 := inputPath + "simple-emf.emf"

fmt.Println("Converting from EMF")
ConvertFromEmf(pdfdoc, s1)
outputFile = "emf2pdf v2.pdf"
pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_remove_unused))
fmt.Println("Saved " + outputFile)

return ret
}
func ConvertToPdfFromFile() bool{
testFiles := [][]string{
{"simple-word_2007.docx","docx2pdf.pdf"},
{"simple-powerpoint_2007.pptx","pptx2pdf.pdf"},
{"simple-excel_2007.xlsx","xlsx2pdf.pdf"},
{"simple-publisher.pub","pub2pdf.pdf"},
{"simple-text.txt","txt2pdf.pdf"},
{ "simple-rtf.rtf","rtf2pdf.pdf"},
{ "simple-emf.emf","emf2pdf.pdf"},
{ "simple-webpage.mht","mht2pdf.pdf"},
{ "simple-webpage.html","html2pdf.pdf"}}
ret := false

if PrinterIsInstalled("PDFTron PDFNet"){
PrinterSetPrinterName("PDFTron PDFNet")
}else if ! PrinterIsInstalled(){
fmt.Println("Installing printer (requires Windows platform and administrator)")
PrinterInstall()
fmt.Println("Installed printer " + PrinterGetPrinterName())
}

for _, testfile := range testFiles {

pdfdoc := NewPDFDoc()
inputFile := testfile[0]
outputFile := testfile[1]
if ConvertRequiresPrinter(inputPath + inputFile){
fmt.Println("Using PDFNet printer to convert file " + inputFile)
}
ConvertToPdf(pdfdoc, inputPath + inputFile)
pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_linearized))
pdfdoc.Close()
fmt.Println("Converted file: " + inputFile + "\nto: " + outputFile)
}
return ret
}

func TestConvertPrint(t *testing.T){
if runtime.GOOS == "windows" {
// The first step in every application using PDFNet is to initialize the
// library. The library is usually initialized only once, but calling
// Initialize() multiple times is also fine.
PDFNetInitialize(licenseKey)

// Demonstrate Convert.ToPdf and Convert.Printer
err := ConvertToPdfFromFile()
if err{
fmt.Println("ConvertFile failed")
}else{
fmt.Println("ConvertFile succeeded")
}
// Demonstrate Convert.[FromEmf, FromXps, ToEmf, ToSVG, ToXPS]
err = ConvertSpecificFormats()
if err{
fmt.Println("ConvertSpecificFormats failed")
}else{
fmt.Println("ConvertSpecificFormats succeeded")
}
fmt.Println("Uninstalling printer (requires Windows platform and administrator)")
PrinterUninstall()
fmt.Println("Uninstalled printer " + PrinterGetPrinterName())

PDFNetTerminate()
fmt.Println("Done.")
}else{
fmt.Println("ConvertPrintTest only available on Windows")
}
}
105 changes: 30 additions & 75 deletions samples/ConvertTest/Convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"testing"
"fmt"
"flag"
"runtime"
. "github.com/pdftron/pdftron-go/v2"
)

Expand All @@ -21,23 +20,12 @@ func init() {
}

//---------------------------------------------------------------------------------------
// The following sample illustrates how to use the PDF.Convert utility class to convert
// documents and files to PDF, XPS, SVG, or EMF.
// The following sample illustrates how to use the PDF::Convert utility class to convert
// documents and files to PDF, XPS, or SVG, or EMF. The sample also shows how to convert MS Office files
// using our built in conversion.
//
// Certain file formats such as XPS, EMF, PDF, and raster image formats can be directly
// converted to PDF or XPS. Other formats are converted using a virtual driver. To check
// if ToPDF (or ToXPS) require that PDFNet printer is installed use Convert.RequiresPrinter(filename).
// The installing application must be run as administrator. The manifest for this sample
// specifies appropriate the UAC elevation.
//
// Note: the PDFNet printer is a virtual XPS printer supported on Vista SP1 and Windows 7.
// For Windows XP SP2 or higher, or Vista SP0 you need to install the XPS Essentials Pack (or
// equivalent redistributables). You can download the XPS Essentials Pack from:
// http://www.microsoft.com/downloads/details.aspx?FamilyId=B8DCFFDD-E3A5-44CC-8021-7649FD37FFEE&displaylang=en
// Windows XP Sp2 will also need the Microsoft Core XML Services (MSXML) 6.0:
// http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&displaylang=en
//
// Note: Convert.fromEmf and Convert.toEmf will only work on Windows and require GDI+.
// converted to PDF or XPS.
//
// Please contact us if you have any questions.
//---------------------------------------------------------------------------------------
Expand All @@ -46,51 +34,6 @@ func init() {
var inputPath = "../TestFiles/"
var outputPath = "../TestFiles/Output/"

func ConvertToPdfFromFile() bool{
testFiles := [][]string{
{"simple-word_2007.docx","docx2pdf.pdf", "false"},
{"simple-powerpoint_2007.pptx","pptx2pdf.pdf", "false"},
{"simple-excel_2007.xlsx","xlsx2pdf.pdf", "false"},
{"simple-publisher.pub","pub2pdf.pdf", "true"},
//{"simple-visio.vsd","vsd2pdf.pdf}, // requires Microsoft Office Visio
{"simple-text.txt","txt2pdf.pdf", "false"},
{"simple-rtf.rtf","rtf2pdf.pdf", "true"},
{"butterfly.png","png2pdf.pdf", "false"},
{"simple-emf.emf","emf2pdf.pdf", "true"},
{"simple-xps.xps","xps2pdf.pdf", "false"},
//{"simple-webpage.mht","mht2pdf.pdf", true},
{"simple-webpage.html","html2pdf.pdf", "true"}}
ret := false

if runtime.GOOS == "windows" {
if PrinterIsInstalled("PDFTron PDFNet"){
PrinterSetPrinterName("PDFTron PDFNet")
}else if ! PrinterIsInstalled(){
fmt.Println("Installing printer (requires Windows platform and administrator)")
PrinterInstall()
fmt.Println("Installed printer " + PrinterGetPrinterName())
}
}

for _, testfile := range testFiles {
if runtime.GOOS != "windows" {
if testfile[2] == "true" {
continue
}
}
pdfdoc := NewPDFDoc()
inputFile := testfile[0]
outputFile := testfile[1]
if ConvertRequiresPrinter(inputPath + inputFile){
fmt.Println("Using PDFNet printer to convert file " + inputFile)
}
ConvertToPdf(pdfdoc, inputPath + inputFile)
pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_compatibility))
pdfdoc.Close()
fmt.Println("Converted file: " + inputFile + "\nto: " + outputFile)
}
return ret
}

func ConvertSpecificFormats() bool{
ret := false
Expand All @@ -104,15 +47,6 @@ func ConvertSpecificFormats() bool{
pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_remove_unused))
fmt.Println("Saved " + outputFile)

// Convert the EMF document to PDF
if runtime.GOOS == "windows" {
s1 = inputPath + "simple-emf.emf"
fmt.Println("Converting from EMF")
ConvertFromEmf(pdfdoc, s1)
outputFile = "emf2pdf v2.pdf"
pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_remove_unused))
fmt.Println("Saved " + outputFile)
}

// Convert the TXT document to PDF
set := NewObjSet()
Expand Down Expand Up @@ -177,6 +111,31 @@ func ConvertSpecificFormats() bool{

return ret
}
func ConvertToPdfFromFile() bool{
testFiles := [][]string{
{"simple-word_2007.docx","docx2pdf.pdf"},
{"simple-powerpoint_2007.pptx","pptx2pdf.pdf"},
{"simple-excel_2007.xlsx","xlsx2pdf.pdf"},

{"simple-text.txt","txt2pdf.pdf"},
{"butterfly.png","png2pdf.pdf"},
{"simple-xps.xps","xps2pdf.pdf"}}
ret := false


for _, testfile := range testFiles {

pdfdoc := NewPDFDoc()
inputFile := testfile[0]
outputFile := testfile[1]
PrinterSetMode(PrinterE_prefer_builtin_converter)
ConvertToPdf(pdfdoc, inputPath + inputFile)
pdfdoc.Save(outputPath + outputFile, uint(SDFDocE_linearized))
pdfdoc.Close()
fmt.Println("Converted file: " + inputFile + "\nto: " + outputFile)
}
return ret
}

func TestConvert(t *testing.T){
// The first step in every application using PDFNet is to initialize the
Expand All @@ -198,11 +157,7 @@ func TestConvert(t *testing.T){
}else{
fmt.Println("ConvertSpecificFormats succeeded")
}
if runtime.GOOS == "windows" {
fmt.Println("Uninstalling printer (requires Windows platform and administrator)")
PrinterUninstall()
fmt.Println("Uninstalled printer " + PrinterGetPrinterName())
}

PDFNetTerminate()
fmt.Println("Done.")
}
64 changes: 32 additions & 32 deletions samples/TestFiles/imagemask.dat
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
FFFFFFFFFFFFFFFFFFFFFFFCFFFFFFFF
FFFFFFF87FFFFFFFFFFFFFF83FFFFFFF
FFFFFFF83FFFFFFFFFFFFFF83FFFFFFF
FFFFFFF83FFFFFFFEFFFFFF83FFFFFFF
F3FFFFF83FFFFFFFF8FFFFF83FFFFFFF
FE3FFFF83FFFFC7FFF0FFFF83FFFF87F
FF87FFF83FFFE01FFFE1FFF87FFFC00F
FFF0FFF87FFF0003FFF87FF87FFE007F
FFFC3FF87FFC03FFFFFE0FF87FF80FFF
FFFF07FC7FF03FFFFFFF83FC7FE0FFFF
FFFFC1FC7FC1FFFFFFFFE0FC7F87FFFF
FFFFF07C7F0FFFFFFFFFF87C7E1FFFFF
FFFFFC3C7C7FFFFFFFFFFC1C7CFFFFFF
FFFFFE0C78FFFFFFFFFFFF0C73FFFFFF
FFFFFF8473FFFFFFFFFFFF8067FFFFFF
FFFFFFC06FFFFFFFFFFFFFE04FFFFFFF
FFFFFFF05FFFFFFFE00000000000000F
E00000000000000FFFFFFFFC7FFFF80F
FFFFFFFC7FFFFC1FFF7FFFFC7FFFFC3F
FFBFFFFC7FFFFEFFFFDFFFFC7FFFFFFF
FFCFFFFC7FFFFFFFFFE7FFFC7FFFFFFF
FFE3FFFC7FFFFFFFFFF3FFFC7FFFFFFF
FFF1FFFC7FFFFFFFFFF1FFFC7FFFFFFF
FFF80000000003FFFFF80000000003FF
FFFC7FFC7FFC07FFFFFC7FFC7FFE0FFF
FFFC3FFC7FFF1FFFFFFE3FFC7FFFFFFF
FFFE1FFC7FFFFFFFFFFE1FFC7FFFFFFF
FFFE0FFC7FFFFFFFFFFE03F87FFFFFFF
FFFF03F87FFFFFF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FFF81FFFFFFFFFFFFFF3FFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Loading

0 comments on commit cc8b23a

Please sign in to comment.