Solved

using iTextSharp to create PDF

Posted on 2014-01-15
5
637 Views
Last Modified: 2014-01-16
I'm using ItextSharp to create pdf documents. At the end of the document it adds this text.

{"appName":"Unknown","requestId":"38675e673dc54c2682dec4f3e6c0bfb4"}

What is this and how can I get ride of it??
0
Comment
Question by:NickMalloy
  • 3
  • 2
5 Comments
 
LVL 23

Expert Comment

by:wdosanjos
ID: 39785212
It looks like JSON, most likely your own application is writing it to the PDF file.  Can you share part of your code?
0
 

Author Comment

by:NickMalloy
ID: 39785989
Here is my code for generating the pdf.

using (MemoryStream myMemoryStream = new MemoryStream())
                {

                    Document myDocument = new Document(PageSize.A1, 10f, 10f, 10f, 0f);
                    PdfWriter myPDFWriter = PdfWriter.GetInstance(myDocument, myMemoryStream);
                    myDocument.Open();
                    WebClient wc = new WebClient();
                    string htmlText = wc.DownloadString("http://localhost:59392/GeneratePDF/CreatePDF.aspx?pid=" + bb);
                    Response.Write(htmlText.Replace("\r", "").Replace("\n", "").Replace("  ", ""));
                    List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StringReader(htmlText), null);
                    for (int k = 0; k < htmlarraylist.Count; k++)
                    {
                        myDocument.Add((IElement)htmlarraylist[k]);
                    }
                    myDocument.Close();
                    byte[] content = myMemoryStream.ToArray();
                    using (FileStream fs = File.Create("PayEval" + bb + ".pdf"))
                    {

                        fs.Write(content, 0, (int)content.Length);
                        var p5 = new tblAttachment();
                        p5.ApplicationID = RecID;
                        p5.DocName = "Eval" + bb + ".pdf";
                        p5.DocType = "pdf";
                        p5.DocByteSize = Convert.ToInt32(fs.Length);
                        p5.DocBinary = content;
                        ctx1.tblAttachments.Add(p5);
                        ctx1.SaveChanges();
                        Int32 Attach = p5.AttachmentID;

                    }
					
					}

Open in new window

0
 
LVL 23

Expert Comment

by:wdosanjos
ID: 39786211
What's the content of htmlText?  Does it happen to include the string "{"appName":"Unknown","requestId":"38675e673dc54c2682dec4f3e6c0bfb4"}"?
0
 

Author Comment

by:NickMalloy
ID: 39786425
it contains this. It isn't something I added to the page. How can I get ride of this???

<!</div>\r\n\r\n-- Visual Studio Browser Link -->\r\n<script type=\"application/json\" id=\"__browserLink_initializationData\">\r\n    {\"appName\":\"Unknown\",\"requestId\":\"84aee9b329d54004969ddcdae2b993c9\"}\r\n</script>\r\n<script type=\"text/javascript\" src=\"http://localhost:54202/6e500d6e2c2e40b19d14bdc8bb202bb4/browserLink\" async=\"async\"></script>\r\n<!-- End Browser Link -->\r\n\r\n</body>\r\n</html>"
0
 
LVL 23

Accepted Solution

by:
wdosanjos earned 500 total points
ID: 39786538
That code is injected on the page by the VS2013 debugger to support the Browser Link feature.  Please follow the instructions on the link below to disable it.

Using Browser Link in Visual Studio 2013: Disabling Browser Link
http://www.asp.net/visual-studio/overview/2013/using-browser-link#disabling

I hope this helps.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question