0

I'm dynamically creating a PDF file using ABC PDF v8, then pushing that data to the screen using the File.ReadAllBytes method, then displaying it using MVC5's FileStreamResult from my controller.

The problem is, one of the links on my PDF is a mailto containing a hyphen (email-example@mydomain.com). This works exactly as intended when the physical PDF is created using ABC PDF, but when I grab the contents using File.ReadAllBytes and return it to my controller to display in my browser (Chrome 44.0.2403.130 m) it strips out everything before the hyphen - leaving the email as just example@mydomain.com.

EDIT:

Here's the code surrounding my File.ReadAllBytes:

        string pdfPath = generateOrderPdf();

        Byte[] pdf;

        if (!string.IsNullOrEmpty(pdfPath) && File.Exists(pdfPath))
            pdf = File.ReadAllBytes(pdfPath);
        else
            pdf = null;

        cleanUp();

        return pdf;

Another edit:

It looks like this is ONLY an issue displaying the PDF within Chrome - I think Chrome is modifying the mailto link behavior - this works fine in Internet Explorer.

someguy0005
  • 125
  • 2
  • 12
  • 3
    This somehow seems rather implausible. You have a PDF, and `File.ReadAllBytes` creates an exact copy, except that it changes one of the links embedded in the PDF? – chiastic-security Aug 10 '15 at 19:54
  • 1
    Can you show us the code surrounding `File.ReadAllBytes` so we could see whether something is affecting that call? – Adam V Aug 10 '15 at 20:06
  • 1
    Sounds like a possible issue with how it's being rendered? Just using `ReadAllBytes` will do exactly what you'd expect. I know for sure that Chrome's PDF rendering isn't completely up to spec (I've actually come across an issue with this before - it doesn't support postbacks from PDF documents, so it wouldn't be surprising if there were other flaws in it as well), you might try running it in IE (I know...) with Adobe Reader to see if it doesn't work as you'd expect it to there. – user2366842 Aug 10 '15 at 21:15
  • *I think Chrome is modifying the mailto link behavior* - are you sure there *is a link* in the PDF? Or is there merely an email address the viewers conveniently *display as a link*? The latter case may easily show different results in different viewers.... – mkl Aug 11 '15 at 04:15
  • Yes I am sure there is a mailto anchor link within my PDF. After identifying this as a Chrome specific issue, I found another user reporting the same exact thing: [link](http://stackoverflow.com/questions/6056682/default-mailto-in-chrome-pdf-cuts-emails) though the proposed solution doesn't work - HtmlEncoding rather than PHP's htmlspecialchars. – someguy0005 Aug 11 '15 at 12:44

0 Answers0