You must Sign In to post a response.
  • Category: Sharepoint

    Convert hyperliks from a pdf document to a word document ?

    HI

    am facing a problem is am try try to convert a pdf document to aword document. it working fine, but if a pdf document having a hyperlink it dosent convert into a hyperlink format it is convert simply text format please help me fast...
    below is my code.


    private void button1_Click(object sender, EventArgs e)
    {
    OpenFileDialog dlg = new OpenFileDialog();
    string filepath;
    dlg.Filter = "PDF Files(*.PDF)|*.PDF|All Files (*.*)|*.*";
    if (dlg.ShowDialog() == DialogResult.OK)
    {

    filepath = dlg.FileName.ToString();

    string strtext = string.Empty;
    try
    {
    PdfReader reader = new PdfReader(filepath);
    for (int page = 1; page <= reader.NumberOfPages; page++)
    {
    //PdfDictionary PageDictionary = reader.GetPageN(page);
    //PdfArray Annots = PageDictionary.GetAsArray(PdfName.ANNOTS);
    ////var Links =Annots
    ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.LocationTextExtractionStrategy();
    string s = PdfTextExtractor.GetTextFromPage(reader, page, its);
    s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
    //if(Annots!=null)
    strtext = strtext + s;
    richTextBox1.Text = strtext;
    }
    reader.Close();
    }
    catch (Exception ex)
    {

    MessageBox.Show(ex.Message);
    }
    }
    StreamWriter File = new StreamWriter("E://testing//" + dlg.SafeFileName + DateTime.Now.Millisecond + ".doc" + "");
    File.Write(richTextBox1.Text);
    File.Close();

    }

    Thanks in advance,
  • #737764
    Does your hyperlink in pdf has got complete URL? As per my understanding by default if you have full URL it will show as hyperlink.
    Can you show us the hyperlink you are trying to convert in your pdf file?


    Regards,
    Asheej T K

  • #737803
    Thanks Asheej T k

    http://www.google.com this is the url(in Hyperlink Format) in pdf. ok if i try to convert into word document it is like http://www.google.com (simple text fromat)
    ok did you got it or do you want any clarification i will explain once again but its very urgent ple help me fast

    Thanks in Advance

  • #738895
    I got solution for this senario is here we cant convert the hyperlinks to a txt file in a hyperlink format because txt document dosent accepts hyplinks it accepts only simple text.

    Any how thank you all for supporting me on this thread finally i achive this


  • Sign In to post your comments