URL Encoding

Hi,

I am trying to generate a pdf.
In that PDF we need to show some URL’s.
i am able to generate the pdf but after the pdf generated those url’s got encoded.

is there any possibilities to avoid the encoding?

So that am facing some issues.could you please help me to fix this?

Note : i have tried the same steps in word doc and its working fine ter. am facing this while generating the PDF alone.

Thanks,
Govendan

@govendan,

Thanks for your inquiry. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output PDF file that shows the undesired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we’ll start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi,

Thanks for the reply.
I have use the below code snippet to generate the PDF and i have attached the generated PDF.

CODE SNIPPET:
Aspose.Words.Document doc = new Aspose.Words.Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertCell();
builder.Write("Please make sure to visit ");
builder.Font.Color = Color.Blue;
builder.Font.Underline = Underline.Single;
builder.InsertHyperlink(“Aspose Website”, “oauth implementation c# - Google Search”, false);
builder.EndRow();
builder.RowFormat.HeightRule = HeightRule.Auto;
builder.EndTable();
Aspose.Words.PageSetup ps = builder.CurrentSection.PageSetup;
ps.Orientation = Orientation.Landscape;
string fileName = “testc”;
doc.Save(@"C:\PDF" + fileName + “.pdf”);

After the Report generation the given url has saved like:
oauth implementation c%23 - Google Search

Note: Actually what is happening is some of the special characters are encoded while generating PDF.(i.e: symbols like “+,/,%,=”).Please compare the above mentioned URL’s.

Aspose Test Doc.pdf (22.1 KB)

@govendan,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. If you create the same link in MS Word and save it to PDF, you will get the same output.

Hi Tahir,

As per your suggestion, i have created a MS Word Doc and Manually i have converted as PDF by using SAVE AS feature and it is working fine.

@NOTE: Generated by Aspose.zip (26.4 KB)
URL(Google) which i tried to show in PDF.

Herewith i have attached 3 documents.
Details of the attached documents.
1.Generated by Aspose.pdf : It is generated by Aspose and it has encrypted the URL(Google).
2.Generated by Aspose.doc : It is generated by Aspose and it has saved the URL in exact format which we passing (Google).
3.Manually Saved from Word Doc.pdf : this is saved my manually from word document and it has exact url(Google).

Please review the attached documents and help me to fix this.

Thanks.

@govendan,

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16229. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@govendan,

Thanks for your patience. It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-16229) as ‘Not a Bug’.

According to RFC-3986 specification the “%” character is a special character for escape purposes. Quote from the specification:

Because the percent ("%") character serves as the indicator for percent-encoded octets, it must be percent-encoded as “%25” for that octet to be used as data within a URI.

In the your code “%” is not followed by two hexadecimal digits so it’s treated as a simple character and it’s properly escaped.