We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Illegal character in path

Hello,


I´m using the aspose.pdf liberary version 10.0
When I try to create a PDFA merging a pdf with a xml I run into an exception because of illegal characters in my pdf path. My path contains blank spaces all methods to escape these could not help to fix my problem.

Here´s an example of my code:

These are my variables
Dim nPDFpath As String = “”“C:\Temp\Rechnung 160060.pdf”""
Dim nXMLpath As String = “”“C:\Temp\ZUGFeRD-invoice.xml”""
And this is the function which merges the pdf and xml file.
Dim pdfDocument As New Document(infile)
Dim fileSpecification As New FileSpecification(xmlName, Path.GetFileName(xmlName))
pdfDocument.Convert(dataDir & “log.xml”, PdfFormat.PDF_A_3B, ConvertErrorAction.Delete)
pdfDocument.EmbeddedFiles.Add(fileSpecification)
fileSpecification.Params = New FileParams(fileSpecification)
fileSpecification.Params.ModDate = DateTime.Now
pdfDocument.Save(infile)

The error occurs in the first line new Document.

Do you got any advices or any suggestions how to fix the problem?

Kind regards
Andreas

Hi Andreas,


Thanks for your inquriy. We are looking into it and will update you soon.

Best Regards,

Hi Andreas,


Thanks for contacting support.

I have tested the scenario using one of my sample PDF and XML file and have managed to reproduce ArgumentException. In fact the issue occurring because you are using wrong path for loading PDF and XML file (three double quotes to reference files). Please try using following code snippet.

[VB.NET]

Dim nPDFpath As String = “C:\pdftest\TableBorderIssue.pdf”<o:p></o:p>

Dim nXMLpath As String = "C:\pdftest\P030Test.xml"

'And this Is the function which merges the pdf And xml file.

Dim pdfDocument As New Document(nPDFpath)

Dim fileSpecification As New FileSpecification(nXMLpath)

pdfDocument.Convert("c:/pdftest/conversion_log.xml", PdfFormat.PDF_A_3B, ConvertErrorAction.Delete)

pdfDocument.EmbeddedFiles.Add(fileSpecification)

fileSpecification.Params = New FileParams(fileSpecification)

fileSpecification.Params.ModDate = DateTime.Now

pdfDocument.Save("c:/pdftest/PDF_A_3b_with_Attachment.pdf")

Hi Nayyer,


thank you for your quick answer. Your example uses a path without blank spaces in it, my problem is i may get pathes with blank spaces. How am I able to escape them?

Best Regards
Andreas

Hi Andreas,


Thanks for sharing the details.

I have again tested the scenario where I have added multiple spaces between file name and I am still unable to notice any issue. The PDF file is properly being generated.

[VB.NET]

Dim nPDFpath As String = “C:\pdftest</span>OutOfRange Exception Test.pdf<o:p></o:p>

Dim nXMLpath As String = "C:\pdftest\P030Test.xml"

'And this Is the function which merges the pdf And xml file.

Dim pdfDocument As New Document(nPDFpath)

Dim fileSpecification As New FileSpecification(nXMLpath)

pdfDocument.Convert("c:/pdftest/conversion_log.xml", PdfFormat.PDF_A_3B, ConvertErrorAction.Delete)

pdfDocument.EmbeddedFiles.Add(fileSpecification)

fileSpecification.Params = New FileParams(fileSpecification)

fileSpecification.Params.ModDate = DateTime.Now

pdfDocument.Save("c:/pdftest/PDF_A_3b_with_Attachment.pdf")