c# - Saving a binary file in PDF format -
I am trying to save a Web API response which is in PDF file in PDF file.
What I'm doing here:
filestream fs = file Create ("API_response.pdf", 5120, file option.); BinaryWriter F = new binary-vaitters (FS); // ASCIIEncoding asen = new ASCIIEncoding (); Byte [] Ba = encoding.unicode Gatebates (response data); F.Write (BA); F.Close (); Fs.Close (); But when I am trying to open the API_response.pdf file it says that the file is damaged and it can not be repaired. This is the response I get from APIs and what I am dumping in the API_response.pdf file, % PDF-1.3% one Pound a ?? ? 1 obj is & lt; & Lt; / Creator (htmldoc 1.8.27 Copyright 1997-2006 Easy Software Products, All Rights Reserved.) / CreationDate (D: 20140725043937 + 0500) & gt; & Gt; Endobj 2 0 obj & lt; & Lt; / Type / encoding / differences [32 / space / exclam / quotedbl / numbersign / dollars / per / Ampersand / quotesingle / parenleft / parenright / asterisk / plus / comma / hyphen / period / slash / zero / one / two / three / four / Five / six / seven / eight / nine / stomach / semicolon / less / equal to / greater / question / / a / b / c / d / e / f / g / h / i / j / k / l / M / N / O on / P / Q / R / S / T / U / V / W / X / Y / Z / bracketleft / backslash / bracketright / asciicircum / underlined / grave / A A / b / c / d / e / f / g / h / i / j / k / l / m / n / o / p / q / r / s / t / u / v / w / x / y / z / braceleft / bar / braceright / asciitilde 160 / space / Exclamdown / per / Sterling / currency / yen / Brokenbar / section / Dieresis / copyright / ordfeminine / guillemotleft / logicalnot / zero / registered / macron / degree / plusminus / twosuperior / threesuperior / Sharp / mu / paragraph / Periodcentered / cedilla / onesuperior / ordmasculine / guillemotright / onequarter / onehalf / threequarters / questiondown / agrave / aacute / Acircumflex / Atilde / Adieresis / aring / AE / Ccedilla / egrave / eacute / Ecircumflex / Edieresis / Igrave / Iacute / Icircumflex / Idieresis / Eth / Ntilde / ogr Ave / oacute / Ocircumflex / Otilde / Odieresis / Multiplied / Oslash / ugrave / Uacute / Ucircumflex / Udieresis / Yacute / Fork / germandbls / agrave / aacute / acircumflex / atilde / adieresis / aring / ae / ccedilla / egrave / eacute / ecircumflex / edieresis / igrave / iacute / icircumflex / idieresis / ETH / ntilde / ograve / oacute / ocircumflex / otilde / odieresis / division / oslash / ugrave / uacute / ucircumflex / udieresis / yacute / fork / ydieresis] & gt; & Gt; Endobj 3 0 obj & lt; & Lt; / Length1 .1279 / Length2 92,942 / Length3 544 / Filters / FlateDecode / Length 93901 & gt; & Gt; Stream XA? ?  »SA ???? Dm³ = X¶à ?? One ¥, wua ?? ¶mà ?? ¶mà ?? ¶mà ?? ¶à ?? One ?? EA ?? º] e ?? ~ A ¿»â» a ?? Oî au ³2Wžóì ?? One ?? Oda ?? Ga & LT; ¹â ???? One ???? P ^ a ?? ° F ?? One ?? One ?? One ?? Da ?? One ?? One ?? One ?? ¢ One ???? Åge kacè $ CG + ma £ hbà | ø²à ?? One ???? * [8 [â ?? ºÃ¼ / +  © ªâ ?? ° a ?? One ?? | - ÃÆ'à ¢ â,¬Å¡Ãƒâ € šÃ, I know what I'm missing?
binarywriter serial data in a binary format It is not for writing unchanged data in a stream. In fact, a stream can do this already.
Comments
Post a Comment