Free source code and tutorials for Software developers and Architects.; Updated: 6 Jun 2017. 13,832,097 members. I will suggest you to use iTextSharp to generate PDF. How to convert a byte array to a pdf file in vb.net. Sep 19, 2013 Generate a PDF using iText as a byte array Just the other day I had a really simple task: using some web services, that return images in the form of a byte array, generate a PDF. Apr 09, 2015 We were using C# and needed to convert a well-formed string of HTML to a PDF file. Using iTextSharp (5.5.5) and itextsharp. Matt Pavey is a Microsoft Certified software developer who specializes in ASP.Net, VB.Net, C#, AJAX, LINQ, XML, XSL, Web Services, SQL, jQuery, and more. Now the Result.Data byte array should have the bytes that you. A user can upload any type of data like.txt,.doc,.rtf,.jpg,.gif,.xls,.pdf through upload control. Which will converts the uploaded file into Byte array. Now we need to convert that uploaded file into PDF and save it into the files. Aug 10, 2010 Free source code and tutorials for Software developers and Architects.; Updated: 11 Aug 2010. 13,831,763 members. How to convert a byte array to a pdf file in vb.net. Convert 2d byte array into pdf using itext or any other thing. Convert an integer array to a byte array. Convert a pdf file into byte. Read a pdf in an array byte.
Insert manual page breaks excel. Cooper Security 9651 User Manual. However, neither the authors nor Cooper Security Limited accept any liability for loss or damage caused or alleged to be caused directly or indirectly by this book. The contents of this book are subject to change without notice.
![Kadhala](https://pp.userapi.com/c837322/u185365294/video/l_2e4679ea.jpg)
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
/* |
This file is part of the iText (R) project. |
Copyright (c) 1998-2019 iText Group NV |
Authors: iText Software. |
This program is free software; you can redistribute it and/or modify |
it under the terms of the GNU Affero General Public License version 3 |
as published by the Free Software Foundation with the addition of the |
following permission added to Section 15 as permitted in Section 7(a): |
FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY |
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT |
OF THIRD PARTY RIGHTS |
This program is distributed in the hope that it will be useful, but |
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
or FITNESS FOR A PARTICULAR PURPOSE. |
See the GNU Affero General Public License for more details. |
You should have received a copy of the GNU Affero General Public License |
along with this program; if not, see http://www.gnu.org/licenses or write to |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
Boston, MA, 02110-1301 USA, or download the license from the following URL: |
http://itextpdf.com/terms-of-use/ |
The interactive user interfaces in modified source and object code versions |
of this program must display Appropriate Legal Notices, as required under |
Section 5 of the GNU Affero General Public License. |
In accordance with Section 7(b) of the GNU Affero General Public License, |
a covered work must retain the producer line in every PDF that is created |
or manipulated using iText. |
You can be released from the requirements of the license by purchasing |
a commercial license. Buying such a license is mandatory as soon as you |
develop commercial activities involving the iText software without |
disclosing the source code of your own applications. |
These activities include: offering paid services to customers as an ASP, |
serving PDFs on the fly in a web application, shipping iText with a closed |
source product. |
For more information, please contact iText Software Corp. at this |
address: [email protected] |
*/ |
usingSystem; |
usingSystem.IO; |
usingSystem.Net; |
usingiTextSharp.text.io; |
usingiTextSharp.text.pdf.collection; |
usingiTextSharp.text.error_messages; |
usingiTextSharp.text.pdf.intern; |
namespaceiTextSharp.text.pdf { |
/** Specifies a file or an URL. The file can be extern or embedded. |
* |
* @author Paulo Soares |
*/ |
publicclassPdfFileSpecification : PdfDictionary { |
protectedPdfWriterwriter; |
protectedPdfIndirectReferencerefi; |
/** Creates a new instance of PdfFileSpecification. The static methods are preferred. */ |
publicPdfFileSpecification() : base(PdfName.FILESPEC) { |
} |
/** |
* Creates a file specification of type URL. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param url the URL |
* @return the file specification |
*/ |
publicstaticPdfFileSpecificationUrl(PdfWriterwriter, Stringurl) { |
PdfFileSpecificationfs=newPdfFileSpecification(); |
fs.writer=writer; |
fs.Put(PdfName.FS, PdfName.URL); |
fs.Put(PdfName.F, newPdfString(url)); |
returnfs; |
} |
/** |
* Creates a file specification with the file embedded. The file may |
* come from the file system or from a byte array. The data is flate compressed. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param filePath the file path |
* @param fileDisplay the file information that is presented to the user |
* @param fileStore the byte array with the file. If it is not <CODE>null</CODE> |
* it takes precedence over <CODE>filePath</CODE> |
* @throws IOException on error |
* @return the file specification |
*/ |
publicstaticPdfFileSpecificationFileEmbedded(PdfWriterwriter, StringfilePath, StringfileDisplay, byte[] fileStore) { |
returnFileEmbedded(writer, filePath, fileDisplay, fileStore, PdfStream.BEST_COMPRESSION); |
} |
/** |
* Creates a file specification with the file embedded. The file may |
* come from the file system or from a byte array. The data is flate compressed. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param filePath the file path |
* @param fileDisplay the file information that is presented to the user |
* @param fileStore the byte array with the file. If it is not <CODE>null</CODE> |
* it takes precedence over <CODE>filePath</CODE> |
* @param compressionLevel the compression level to be used for compressing the file |
* it takes precedence over <CODE>filePath</CODE> |
* @throws IOException on error |
* @return the file specification |
* @since 2.1.3 |
*/ |
publicstaticPdfFileSpecificationFileEmbedded(PdfWriterwriter, StringfilePath, StringfileDisplay, byte[] fileStore, intcompressionLevel) { |
returnFileEmbedded(writer, filePath, fileDisplay, fileStore, null, null, compressionLevel); |
} |
/** |
* Creates a file specification with the file embedded. The file may |
* come from the file system or from a byte array. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param filePath the file path |
* @param fileDisplay the file information that is presented to the user |
* @param fileStore the byte array with the file. If it is not <CODE>null</CODE> |
* it takes precedence over <CODE>filePath</CODE> |
* @param compress sets the compression on the data. Multimedia content will benefit little |
* from compression |
* @throws IOException on error |
* @return the file specification |
*/ |
publicstaticPdfFileSpecificationFileEmbedded(PdfWriterwriter, StringfilePath, StringfileDisplay, byte[] fileStore, boolcompress) { |
returnFileEmbedded(writer, filePath, fileDisplay, fileStore, null, null, compress?PdfStream.BEST_COMPRESSION:PdfStream.NO_COMPRESSION); |
} |
/** |
* Creates a file specification with the file embedded. The file may |
* come from the file system or from a byte array. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param filePath the file path |
* @param fileDisplay the file information that is presented to the user |
* @param fileStore the byte array with the file. If it is not <CODE>null</CODE> |
* it takes precedence over <CODE>filePath</CODE> |
* @param compress sets the compression on the data. Multimedia content will benefit little |
* from compression |
* @param mimeType the optional mimeType |
* @param fileParameter the optional extra file parameters such as the creation or modification date |
* @throws IOException on error |
* @return the file specification |
*/ |
publicstaticPdfFileSpecificationFileEmbedded(PdfWriterwriter, StringfilePath, StringfileDisplay, byte[] fileStore, boolcompress, StringmimeType, PdfDictionaryfileParameter) { |
returnFileEmbedded(writer, filePath, fileDisplay, fileStore, mimeType, fileParameter, compress?PdfStream.BEST_COMPRESSION:PdfStream.NO_COMPRESSION); |
} |
/** |
* Creates a file specification with the file embedded. The file may |
* come from the file system or from a byte array. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param filePath the file path |
* @param fileDisplay the file information that is presented to the user |
* @param fileStore the byte array with the file. If it is not <CODE>null</CODE> |
* it takes precedence over <CODE>filePath</CODE> |
* @param mimeType the optional mimeType |
* @param fileParameter the optional extra file parameters such as the creation or modification date |
* @param compressionLevel the level of compression |
* @throws IOException on error |
* @return the file specification |
* @since 2.1.3 |
*/ |
publicstaticPdfFileSpecificationFileEmbedded(PdfWriterwriter, StringfilePath, StringfileDisplay, byte[] fileStore, StringmimeType, PdfDictionaryfileParameter, intcompressionLevel) { |
PdfFileSpecificationfs=newPdfFileSpecification(); |
fs.writer=writer; |
fs.Put(PdfName.F, newPdfString(fileDisplay)); |
fs.SetUnicodeFileName(fileDisplay, false); |
PdfEFStreamstream; |
Streaminp=null; |
PdfIndirectReferencerefi; |
PdfIndirectReferencerefFileLength=null; |
try { |
if (fileStorenull) { |
refFileLength=writer.PdfIndirectReference; |
if (File.Exists(filePath)) { |
inp=newFileStream(filePath, FileMode.Open, FileAccess.Read); |
} |
else { |
if (filePath.StartsWith('file:/') ||filePath.StartsWith('http://') ||filePath.StartsWith('https://')) { |
WebRequestwr=WebRequest.Create(filePath); |
wr.Credentials=CredentialCache.DefaultCredentials; |
inp=wr.GetResponse().GetResponseStream(); |
} |
else { |
inp=StreamUtil.GetResourceStream(filePath); |
if (inpnull) |
thrownewIOException(MessageLocalization.GetComposedMessage('1.not.found.as.file.or.resource', filePath)); |
} |
} |
stream=newPdfEFStream(inp, writer); |
} |
else |
stream=newPdfEFStream(fileStore); |
stream.Put(PdfName.TYPE, PdfName.EMBEDDEDFILE); |
stream.FlateCompress(compressionLevel); |
PdfDictionaryparam=newPdfDictionary(); |
if (fileParameter!=null) |
param.Merge(fileParameter); |
if (!param.Contains(PdfName.MODDATE)) { |
param.Put(PdfName.MODDATE, newPdfDate()); |
} |
if (fileStorenull) { |
stream.Put(PdfName.PARAMS, refFileLength); |
} else { |
param.Put(PdfName.SIZE, newPdfNumber(stream.RawLength)); |
stream.Put(PdfName.PARAMS, param); |
} |
if (mimeType!=null) |
stream.Put(PdfName.SUBTYPE, newPdfName(mimeType)); |
refi=writer.AddToBody(stream).IndirectReference; |
if (fileStorenull) { |
stream.WriteLength(); |
param.Put(PdfName.SIZE, newPdfNumber(stream.RawLength)); |
writer.AddToBody(param, refFileLength); |
} |
} |
finally { |
if (inp!=null) |
try{inp.Close();}catch{} |
} |
PdfDictionaryf=newPdfDictionary(); |
f.Put(PdfName.F, refi); |
f.Put(PdfName.UF, refi); |
fs.Put(PdfName.EF, f); |
returnfs; |
} |
/** |
* Creates a file specification for an external file. |
* @param writer the <CODE>PdfWriter</CODE> |
* @param filePath the file path |
* @return the file specification |
*/ |
publicstaticPdfFileSpecificationFileExtern(PdfWriterwriter, StringfilePath) { |
PdfFileSpecificationfs=newPdfFileSpecification(); |
fs.writer=writer; |
fs.Put(PdfName.F, newPdfString(filePath)); |
returnfs; |
} |
/** |
* Gets the indirect reference to this file specification. |
* Multiple invocations will retrieve the same value. |
* @throws IOException on error |
* @return the indirect reference |
*/ |
virtualpublicPdfIndirectReferenceReference { |
get { |
if (refi!=null) |
returnrefi; |
refi=writer.AddToBody(this).IndirectReference; |
returnrefi; |
} |
} |
/** |
* Sets the file name (the key /F) string as an hex representation |
* to support multi byte file names. The name must have the slash and |
* backslash escaped according to the file specification rules |
* @param fileName the file name as a byte array |
*/ |
virtualpublicbyte[] MultiByteFileName { |
set { |
Put(PdfName.F, newPdfString(value).SetHexWriting(true)); |
} |
} |
/** |
* Adds the unicode file name (the key /UF). This entry was introduced |
* in PDF 1.7. The filename must have the slash and backslash escaped |
* according to the file specification rules. |
* @param filename the filename |
* @param unicode if true, the filename is UTF-16BE encoded; otherwise PDFDocEncoding is used; |
*/ |
virtualpublicvoidSetUnicodeFileName(Stringfilename, boolunicode) { |
Put(PdfName.UF, newPdfString(filename, unicode?PdfObject.TEXT_UNICODE:PdfObject.TEXT_PDFDOCENCODING)); |
} |
/** |
* Sets a flag that indicates whether an external file referenced by the file |
* specification is volatile. If the value is true, applications should never |
* cache a copy of the file. |
* @param volatile_file if true, the external file should not be cached |
*/ |
virtualpublicboolVolatile { |
set { |
Put(PdfName.V, newPdfBoolean(value)); |
} |
} |
/** |
* Adds a description for the file that is specified here. |
* @param description some text |
* @param unicode if true, the text is added as a unicode string |
*/ |
virtualpublicvoidAddDescription(Stringdescription, boolunicode) { |
Put(PdfName.DESC, newPdfString(description, unicode?PdfObject.TEXT_UNICODE:PdfObject.TEXT_PDFDOCENCODING)); |
} |
/** |
* Adds the Collection item dictionary. |
*/ |
virtualpublicvoidAddCollectionItem(PdfCollectionItemci) { |
Put(PdfName.CI, ci); |
} |
publicoverridevoidToPdf(PdfWriterwriter, Streamos) { |
PdfWriter.CheckPdfIsoConformance(writer, PdfIsoKeys.PDFISOKEY_FILESPEC, this); |
base.ToPdf(writer, os); |
} |
} |
} |
Copy lines Copy permalink
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
The size of this Top Spin 2 Emulator/ROM is just 10.2MB only and around 566 people already downloaded and played it. NOTE: Most of the Antivirus warn or alert you for this Emulator / Rom files, as they mistaken these files as a virus or malware. If you like this Top Spin 2, we request you to give suitable ratings. Top spin 4 pc download emulator games. Happy Gaming!!
Sign upC# Convert Byte Array To Pdf
Find file Copy path
Byte Array To File
Cannot retrieve contributors at this time
C++ Byte Array
![Byte Byte](https://images.cnitblog.com/blog2015/28036/201503/041339435073209.png)
usingSystem; |
/* |
* Copyright 2003-2008 by Paulo Soares. |
* |
* This code was originally released in 2001 by SUN (see class |
* com.sun.media.imageioimpl.plugins.tiff.TIFFLZWDecompressor.java) |
* using the BSD license in a specific wording. In a mail dating from |
* January 23, 2008, Brian Burkhalter (@sun.com) gave us permission |
* to use the code under the following version of the BSD license: |
* |
* Copyright (c) 2005 Sun Microsystems, Inc. All Rights Reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistribution of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* |
* - Redistribution in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in |
* the documentation and/or other materials provided with the |
* distribution. |
* |
* Neither the name of Sun Microsystems, Inc. or the names of |
* contributors may be used to endorse or promote products derived |
* from this software without specific prior written permission. |
* |
* This software is provided 'AS IS,' without a warranty of any |
* kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND |
* WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, |
* FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY |
* EXCLUDED. SUN MIDROSYSTEMS, INC. ('SUN') AND ITS LICENSORS SHALL |
* NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF |
* USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS |
* DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR |
* ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, |
* CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND |
* REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR |
* INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE |
* POSSIBILITY OF SUCH DAMAGES. |
* |
* You acknowledge that this software is not designed or intended for |
* use in the design, construction, operation or maintenance of any |
* nuclear facility. |
*/ |
namespaceiTextSharp.text.pdf.codec { |
/** |
* A class for performing LZW decoding. |
* |
* |
*/ |
publicclassTIFFLZWDecoder { |
byte[][] stringTable; |
byte[] data=null; |
byte[] uncompData; |
inttableIndex, bitsToGet=9; |
intbytePointer; |
intdstIndex; |
intw, h; |
intpredictor, samplesPerPixel; |
intnextData=0; |
intnextBits=0; |
int[] andTable= { |
511, |
1023, |
2047, |
4095 |
}; |
publicTIFFLZWDecoder(intw, intpredictor, intsamplesPerPixel) { |
this.w=w; |
this.predictor=predictor; |
this.samplesPerPixel=samplesPerPixel; |
} |
/** |
* Method to decode LZW compressed data. |
* |
* @param data The compressed data. |
* @param uncompData Array to return the uncompressed data in. |
* @param h The number of rows the compressed data contains. |
*/ |
publicbyte[] Decode(byte[] data, byte[] uncompData, inth) { |
if (data[0] (byte)0x00&&data[1] (byte)0x01) { |
thrownewInvalidOperationException('TIFF 5.0-style LZW codes are not supported.'); |
} |
InitializeStringTable(); |
this.data=data; |
this.h=h; |
this.uncompData=uncompData; |
// Initialize pointers |
bytePointer=0; |
dstIndex=0; |
nextData=0; |
nextBits=0; |
intcode, oldCode=0; |
byte[] strn; |
while ( ((code=GetNextCode()) !=257) && |
dstIndex<uncompData.Length) { |
if (code256) { |
InitializeStringTable(); |
code=GetNextCode(); |
if (code257) { |
break; |
} |
WriteString(stringTable[code]); |
oldCode=code; |
} else { |
if (code<tableIndex) { |
strn=stringTable[code]; |
WriteString(strn); |
AddStringToTable(stringTable[oldCode], strn[0]); |
oldCode=code; |
} else { |
strn=stringTable[oldCode]; |
strn=ComposeString(strn, strn[0]); |
WriteString(strn); |
AddStringToTable(strn); |
oldCode=code; |
} |
} |
} |
// Horizontal Differencing Predictor |
if (predictor2) { |
intcount; |
for (intj=0; j<h; j++) { |
count=samplesPerPixel* (j*w+1); |
for (inti=samplesPerPixel; i<w*samplesPerPixel; i++) { |
uncompData[count] +=uncompData[count-samplesPerPixel]; |
count++; |
} |
} |
} |
returnuncompData; |
} |
/** |
* Initialize the string table. |
*/ |
publicvoidInitializeStringTable() { |
stringTable=newbyte[4096][]; |
for (inti=0; i<256; i++) { |
stringTable[i] =newbyte[1]; |
stringTable[i][0] = (byte)i; |
} |
tableIndex=258; |
bitsToGet=9; |
} |
/** |
* Write out the string just uncompressed. |
*/ |
publicvoidWriteString(byte[] strn) { |
// Fix for broken tiff files |
intmax=uncompData.Length-dstIndex; |
if (strn.Length<max) |
max=strn.Length; |
System.Array.Copy(strn, 0, uncompData, dstIndex, max); |
dstIndex+=max; |
} |
/** |
* Add a new string to the string table. |
*/ |
publicvoidAddStringToTable(byte[] oldString, bytenewString) { |
intlength=oldString.Length; |
byte[] strn=newbyte[length+1]; |
Array.Copy(oldString, 0, strn, 0, length); |
strn[length] =newString; |
// Add this new String to the table |
stringTable[tableIndex++] =strn; |
if (tableIndex511) { |
bitsToGet=10; |
} elseif (tableIndex1023) { |
bitsToGet=11; |
} elseif (tableIndex2047) { |
bitsToGet=12; |
} |
} |
/** |
* Add a new string to the string table. |
*/ |
publicvoidAddStringToTable(byte[] strn) { |
// Add this new String to the table |
stringTable[tableIndex++] =strn; |
if (tableIndex511) { |
bitsToGet=10; |
} elseif (tableIndex1023) { |
bitsToGet=11; |
} elseif (tableIndex2047) { |
bitsToGet=12; |
} |
} |
/** |
* Append <code>newString</code> to the end of <code>oldString</code>. |
*/ |
publicbyte[] ComposeString(byte[] oldString, bytenewString) { |
intlength=oldString.Length; |
byte[] strn=newbyte[length+1]; |
Array.Copy(oldString, 0, strn, 0, length); |
strn[length] =newString; |
returnstrn; |
} |
// Returns the next 9, 10, 11 or 12 bits |
publicintGetNextCode() { |
// Attempt to get the next code. The exception is caught to make |
// this robust to cases wherein the EndOfInformation code has been |
// omitted from a strip. Examples of such cases have been observed |
// in practice. |
try { |
nextData= (nextData<<8) | (data[bytePointer++] &0xff); |
nextBits+=8; |
if (nextBits<bitsToGet) { |
nextData= (nextData<<8) | (data[bytePointer++] &0xff); |
nextBits+=8; |
} |
intcode= |
(nextData>> (nextBits-bitsToGet)) &andTable[bitsToGet-9]; |
nextBits-=bitsToGet; |
returncode; |
} catch (IndexOutOfRangeException) { |
// Strip not terminated as expected: return EndOfInformation code. |
return257; |
} |
} |
} |
} |
Copy lines Copy permalink