Hi,
I am using aspose.pdf to convert pdf/a. But it gives me an exception for one PDF.
Pdf download link;
The code below;
Using pdf_document As New Aspose.Pdf.Document(pOutputFilepath)
For Each page As Page In pdf_document.Pages
If page.Resources.Fonts IsNot Nothing Then
For Each pageFont As Aspose.Pdf.Text.Font In page.Resources.Fonts
'Check if font is already embedded
If Not pageFont.IsEmbedded Then
pageFont.IsEmbedded = True
End If
Next
End If
'Check for the Form objects
For Each form As XForm In page.Resources.Forms
If form.Resources.Fonts IsNot Nothing Then
For Each formFont As Aspose.Pdf.Text.Font In form.Resources.Fonts
'Check if the font is embedded
If Not formFont.IsEmbedded Then
formFont.IsEmbedded = True
End If
Next
End If
Next
Next
pdf_document.Convert(pTempFilePath4Log, PdfFormat.PDF_A_1A, ConvertErrorAction.Delete)
Dim optimizeOptions As New Aspose.Pdf.Optimization.OptimizationOptions()
optimizeOptions.RemoveUnusedObjects = True
'optimizeOptions.RemoveUnusedStreams = True
optimizeOptions.UnembedFonts = False
optimizeOptions.SubsetFonts = True
optimizeOptions.AllowReusePageContent = True
pdf_document.OptimizeResources(optimizeOptions)
pdf_document.Save(pOutputFilepath)
Try
System.IO.File.Delete(pTempFilePath4Log)
Catch
'NOLOG
End Try
End Using
Error;
An entry with the same key already exists.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.TreeSet1.AddIfNotPresent(T item) at System.Collections.Generic.SortedDictionary
2.Add(TKey key, TValue value)
at #=zwN7gV$i3ZWLK_lDIOJyCPbp4y2eeM2tANV4XsrEOHTjAEfR4Qg==.#=zwDHfAWC4hgB6()
at #=zqw9ISzvB3tQKO7TL$dspb318g8$9UGOTeALZC$NB2R062AjsRUhM3zpT3zCT.#=zWIK7pfrH53YObwENUA==()
at #=zqw9ISzvB3tQKO7TL$dspb318g8$9UGOTeALZC$NB2R062AjsRUhM3zpT3zCT.#=z4i2s6L7htg7g(BaseOperatorCollection #=zrhapXy0=, Resources #=zeo2FNI8=)
at #=zqw9ISzvB3tQKO7TL$dspb318g8$9UGOTeALZC$NB2R062AjsRUhM3zpT3zCT.#=zcXOshpM=()
at #=zqw9ISzvB3tQKO7TL$dspb318g8$9UGOTeALZC$NB2R062AjsRUhM3zpT3zCT…ctor(Page #=z1mwwV1s=, TextSearchOptions #=ziKTNgYLRKixX, Resources #=zeo2FNI8=, BaseOperatorCollection #=z_yOqpvg=)
at #=zqw9ISzvB3tQKO7TL$dspb318g8$9UGOTeALZC$NB2R062AjsRUhM3zpT3zCT…ctor(Page #=z1mwwV1s=, Resources #=zeo2FNI8=, BaseOperatorCollection #=z_yOqpvg=)
at #=zXVlFEEh4xBtU6NeQ7RfG7bZZYdqTo5TaNMXAA$7k6k9dn0s_MgUL1CY=.#=zHQ$v4KDtvaaE(Page #=z1mwwV1s=, OperatorCollection #=zrhapXy0=, Resources #=zeo2FNI8=, Int32 #=zyk9RmRUDYCJB, #=z$zbkIeXhJXncVj5AwTO1lO3ZiW4AanAqZ3nyo2drhd3lMnPAsg== #=zhX6lThofGato)
at #=zXVlFEEh4xBtU6NeQ7RfG7bZZYdqTo5TaNMXAA$7k6k9dn0s_MgUL1CY=.#=zNZGRSand7y1b(Page #=z1mwwV1s=, #=z$zbkIeXhJXncVj5AwTO1lO3ZiW4AanAqZ3nyo2drhd3lMnPAsg== #=zhX6lThofGato)
at #=zXVlFEEh4xBtU6NeQ7RfG7bZZYdqTo5TaNMXAA$7k6k9dn0s_MgUL1CY=.#=zvTnI0Y8=()
at #=zXVlFEEh4xBtU6NeQ7RfG7bZZYdqTo5TaNMXAA$7k6k9dn0s_MgUL1CY=.#=zv9OzZ_8=()
at #=zkz44GdPYlcd5RjCgaE0BUQx0vHBqK0sI9NAuoquF0IOzaHP64wuCI$U=.#=zTol2npc=()
at #=zXVlFEEh4xBtU6NeQ7RfG7bZZYdqTo5TaNMXAA$7k6k9dn0s_MgUL1CY=.#=zxu3C9F4=(XmlTextWriter #=zqIDLf_Y=, PdfFormat #=zhpl2_D8=, Document #=zx8MBJi0=, Boolean #=z$Nzjd5356YXh, ConvertErrorAction #=zdKmfLp0=)
at Aspose.Pdf.Document.#=z4VYcFJ0=(XmlTextWriter #=zqIDLf_Y=, PdfFormat #=zhpl2_D8=, Boolean #=z$Nzjd5356YXh, ConvertErrorAction #=zdKmfLp0=)
at Aspose.Pdf.Document.#=zfYeD98hMVN6_(Stream #=zDrP5f$U=, SaveOptions #=zLc_YMqUK9KcV)
at Aspose.Pdf.Document.#=z6kAOwZAWlPGY(String #=zknH$69bRkHRh)
at Aspose.Pdf.Document.Save(String outputFileName)