Solved

using iTextSharp to create PDF

Posted on 2014-01-15
5
626 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 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

26 Experts available now in Live!

Get 1:1 Help Now