PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

Rendering in Browser
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2515
Page 1 of 1

Author:  jmccullough [ Thu Jul 11, 2013 6:22 pm ]
Post subject:  Rendering in Browser

I have had this code for quite some time and it has worked flawlessly. We use PDF sharp to import PDF files that have been sent to use via FTP. About 2 days ago the PDFs just began not rendering in any browser(IE, firefox, Chrome). There were not any code changes. Here is the code that I am using the resulting output.

This grabs the binary data from the database and serves it up to a web page(This is asp.net with VB)
Dim img As B2BBusinessObjects.RepositoryDocument = New RepositoryDocument(imageID)
Dim buf As Byte() = RepositoryDocument.GetDocument(imageID)
Response.BinaryWrite(buf)

This HTML grabs the document from the served page above(GetDocumentURL() returns the URL of the page that uses the above code)
<div id="objImage" height="100%" runat="server">
<object width="100%" height="800px" classid="CLSID:106E49CF-797A-11D2-81A2-00E02C015623">
<param name="src" value="<%= GetDocumentURL() %>" />
<embed width="100%" height="800px" src="<%= GetDocumentURL() %>" type="application/pdf" />
</object>
</div>

This results in the following output which used to be a nice PDF up until a few days ago. This is just a snippet
%PDF-1.4 %���� % PDFsharp Version 1.32.2608.0 (verbose mode) % Creation date: 4/25/2013 3:00:13 PM % Creation time: 0.047 seconds % File size: 120623 bytes % Pages: 1 % Objects: 7 %-------------------------------------------------------------------------------------------------- 1 0 obj % PdfSharp.Pdf.PdfDocumentInformation << /CreationDate (D:20130425150013-04'00') /Creator () /Producer (PDFsharp 1.32.2608-g \(www.pdfsharp.net\)) /Title (Page 1 of ) >> endobj %-------------------------------------------------------------------------------------------------- 2 0 obj % PdfSharp.Pdf.Advanced.PdfCatalog << /Pages 3 0 R /Type /Catalog >> endobj %-------------------------------------------------------------------------------------------------- 3 0 obj % PdfSharp.Pdf.PdfPages << /Count 1 /Kids [7 0 R] /Type /Pages >> endobj %-------------------------------------------------------------------------------------------------- 4 0 obj % PdfSharp.Pdf.PdfDictionary << /ProcSet [/PDF /ImageB] /XObject << /Im1 5 0 R >> >> endobj %-------------------------------------------------------------------------------------------------- 5 0 obj % PdfSharp.Pdf.PdfDictionary << /BitsPerComponent 1 /ColorSpace /DeviceGray /DecodeParms << /Columns 2552 /Rows 3300 >> /Filter /CCITTFaxDecode /Height 3300 /Length 118042 /Subtype /Image /Type /XObject /Width 2552 >> stream YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYi�� "6b���ي��.�j��1Pvh��LU�2�C�� ��f��D�D��!d��4°�ؒBM���:���!e��W\Ou���…���P�C�Q��C��G��O&Āf�U��N���z~r���%vt8'a�8H�lHvi�u��J��8��Ghq� w�c��Cŋ��!���f}~<��>:�t?��S�;���m�b�4�-����1�,��N�C�������up���+�Z� �v���7C̗����

Author:  Thomas Hoevel [ Mon Jul 15, 2013 7:48 am ]
Post subject:  Re: Rendering in Browser

Not my area of expertise, but IMHO it can't hurt to specify on the server that it is sending a PDF file:
Code:
  Response.Clear();
  Response.ContentType = "application/pdf";
  Response.AddHeader("content-length", stream.Length.ToString());


See also:
http://www.pdfsharp.net/wiki/Clock-sample.ashx

Author:  jmccullough [ Mon Jul 15, 2013 7:47 pm ]
Post subject:  Re: Rendering in Browser

This did not correct the issue.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/