Solved

using iTextSharp to create PDF

Posted on 2014-01-15
5
620 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now