Use C # To generate PDF documents (original code)

Source: Internet
Author: User
Tags generator generator

Use C # To generate PDF documents (original code)

// Write by wenhui.org
Using System;
Using System. IO;
Using System. Text;
Using System. Collections;
Namespace generator Generator
{
Public class extends Generator
{
Static float pageWidth = 594.0f;
Static float pageDepth = 828366f;
Static float pageMargin = 30366f;
Static float fontSize = 20366f;
Static float leadSize = 10.0f;
Static StreamWriter pPDF = new StreamWriter ("E: mystreamwriter ");
Static MemoryStream mPDF = new MemoryStream ();
Static void ConvertToByteAndAddtoStream (string strMsg)
{
Byte [] buffer = null;
Buffer = ASCIIEncoding. ASCII. GetBytes (strMsg );
MPDF. Write (buffer, 0, buffer. Length );
Buffer = null;
}
Static string xRefFormatting (long xValue)
{
String strMsg = xValue. ToString ();
Int iLen = strMsg. Length;
If (iLen <10)
{
StringBuilder s = new StringBuilder ();
Int I = 10-iLen;
S. Append ('0', I );
StrMsg = s. ToString () + strMsg;
}
Return strMsg;
}
Static void Main (string [] args)
{
ArrayList xRefs = new ArrayList ();
// Byte [] buffer = null;
Float yPos = 0f;
Long streamStart = 0;
Long streamEnd = 0;
Long streamLen = 0;
String strPDFMessage = null;
// PDF document header information
StrPDFMessage = "% PDF-1.1 ";
ConvertToByteAndAddtoStream (strPDFMessage );
XRefs. Add (mPDF. Length );
Str1_message = "1 0 obj ";
ConvertToByteAndAddtoStream (strPDFMessage );
Str1_message = "</Length 2 0 R> ";
ConvertToByteAndAddtoStream (strPDFMessage );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.