Pearl
Pearl

Reputation: 9445

Is it possible to retain Hyperlinks from PDF

  string ghostScriptPath = @"C:\Program Files (x86)\gs\gs9.09\bin\gswin32.exe";

  string inputFileName = Server.MapPath("pdf/myprofile.pdf");

  string outputFileName = @"D:\";

  string ars = "-dNOPAUSE -sDEVICE=jpeg -r300 -o" + output + "-%d.jpg " + input;

    Process proc = new Process();

    proc.StartInfo.FileName = ghostScriptPath;

    proc.StartInfo.Arguments = ars;

    proc.StartInfo.CreateNoWindow = true;

    proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

    proc.Start();

    proc.WaitForExit();

I'm using asp.net application with c# language. I'm using the code above to convert the PDF to images using Ghost Script. Is it possible to retain Hyperlinks from PDF?

Upvotes: 1

Views: 130

Answers (1)

online Thomas
online Thomas

Reputation: 9401

You can use PDFParser to read the PDF as text (into a string) and then parse the string yourself for "http". Just for completeness:

// create an instance of the pdfparser class
PDFParser pdfParser = new PDFParser();

// extract the text
String result = pdfParser.ExtractText(pdfFile);
if(result.ToLower().Contains("http"))
{
//split the string on known factors like a "\n" and "/" for ending the url. 
}

Upvotes: 1

Related Questions