test.docx (15.7 KB)
test.pdf (19.2 KB)
test.docx (15.7 KB)
Hello,
When I convert word to pdf file I have a “Evaluation” watermak on my Datamatrix but I use a Aspsose.total License. My QRCode works.
Could you help me ?
Imports System
Imports System.IO
Imports System.Timers
Imports System.Net
Imports System.Xml
Imports System.IO.Compression
Imports System.CodeDom.Compiler
Imports TESTOPM.AIRS
<a class="attachment" href="/uploads/default/101082">test.docx</a> (15.7 KB)
Module Module1
Sub Main()
Dim LicWords As New Aspose.Words.License
LicWords.SetLicense("C:\OPM\DLL\lic.lic")
Dim LicPDF As New Aspose.Pdf.License
LicWords.SetLicense("C:\OPM\DLL\lic.lic")
Dim LicBC As New Aspose.BarCode.License
LicBC.SetLicense("C:\OPM\DLL\lic.lic")
Dim AsposeWord = New Aspose.Words.Document("X:\NPA\fichier-word-webai\licence-full\test.docm")
'Ouvre le document
AsposeWord.FieldOptions.BarcodeGenerator = New CustomBarcodeGenerator()
'Dim gen As New Aspose.BarCode.Generation.BarcodeGenerator(Aspose.BarCode.Generation.EncodeTypes.DataMatrix, "123456789")
AsposeWord.Save("X:\NPA\fichier-word-webai\licence-full\test.pdf", Aspose.Words.SaveFormat.Pdf)
End Sub
End Module
Public Class CustomBarcodeGenerator
Implements Aspose.Words.Fields.IBarcodeGenerator
Private Shared Function ConvertColor(ByVal inputColor As String) As System.Drawing.Color
Dim color As Integer = Integer.MinValue
Integer.TryParse(inputColor.Replace("0x", ""), color)
If color = Integer.MinValue Then
Throw New Exception("Error! Incorrect color - " & inputColor & ".")
Else
Return System.Drawing.Color.FromArgb((color + 16), ((color And 65280) + 8), (color And 255))
End If
End Function
Private Function IBarcodeGenerator_GetBarcodeImage(parameters As Aspose.Words.Fields.BarcodeParameters) As System.Drawing.Image Implements Aspose.Words.Fields.IBarcodeGenerator.GetBarcodeImage
If parameters.BarcodeType Is Nothing OrElse parameters.BarcodeValue Is Nothing Then Return Nothing
Dim type As String = parameters.BarcodeType.ToUpper()
Dim encodeType = Aspose.BarCode.Generation.EncodeTypes.None
Select Case type
Case "QR"
encodeType = Aspose.BarCode.Generation.EncodeTypes.QR
Case "CODE128"
encodeType = Aspose.BarCode.Generation.EncodeTypes.Code128
Case "CODE39"
encodeType = Aspose.BarCode.Generation.EncodeTypes.Code39Standard
Case "EAN8"
encodeType = Aspose.BarCode.Generation.EncodeTypes.EAN8
Case "EAN13"
encodeType = Aspose.BarCode.Generation.EncodeTypes.EAN13
Case "UPCA"
encodeType = Aspose.BarCode.Generation.EncodeTypes.UPCA
Case "UPCE"
encodeType = Aspose.BarCode.Generation.EncodeTypes.UPCE
Case "ITF14"
encodeType = Aspose.BarCode.Generation.EncodeTypes.ITF14
Case "DATAMATRIX"
encodeType = Aspose.BarCode.Generation.EncodeTypes.DataMatrix
Case "CASE"
encodeType = Aspose.BarCode.Generation.EncodeTypes.None
End Select
If encodeType.Equals(Aspose.BarCode.Generation.EncodeTypes.None) Then Return Nothing
Dim generator As New Aspose.BarCode.Generation.BarcodeGenerator(encodeType)
generator.CodeText = parameters.BarcodeValue
If encodeType.Equals(Aspose.BarCode.Generation.EncodeTypes.QR) Then generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = parameters.BarcodeValue
If parameters.ForegroundColor IsNot Nothing Then generator.Parameters.Barcode.BarColor = ConvertColor(parameters.ForegroundColor)
If parameters.BackgroundColor IsNot Nothing Then generator.Parameters.BackColor = ConvertColor(parameters.BackgroundColor)
generator.Parameters.Barcode.CodeTextParameters.Location = Aspose.BarCode.Generation.CodeLocation.None
generator.Parameters.Barcode.QR.QrVersion = Aspose.BarCode.QRVersion.Version01
generator.Parameters.AutoSizeMode = Aspose.BarCode.Generation.AutoSizeMode.None '.Interpolation
generator.Parameters.Barcode.Padding.Left.Point = 3
generator.Parameters.Barcode.Padding.Top.Point = 3
generator.Parameters.Barcode.Padding.Right.Point = 3
generator.Parameters.Barcode.Padding.Bottom.Point = 3
generator.Parameters.ImageWidth.Point = CInt(parameters.ScalingFactor) - 6
generator.Parameters.ImageHeight.Point = CInt(parameters.ScalingFactor) - 6
Return generator.GenerateBarCodeImage()
End Function
Private Function IBarcodeGenerator_GetOldBarcodeImage(parameters As Aspose.Words.Fields.BarcodeParameters) As System.Drawing.Image Implements Aspose.Words.Fields.IBarcodeGenerator.GetOldBarcodeImage
Throw New NotImplementedException()
End Function
End Class