DynaPDF Manual - Page 143

Previous Page 142   Index   Next Page 144

Function Reference
Page 143 of 839
Example (C#):
static int PDFError(IntPtr Data, int ErrCode, IntPtr ErrMessage, int ErrType)
{
MessageBox.Show( string.Format("{0}",
System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ErrMessage)));
return 0; // We try to continue if an error occurrs. Any other return value breaks processing.
}
private void button1_Click(object sender, EventArgs e)
{
CPDF pdf = new CPDF();
pdf.SetOnErrorProc(IntPtr.Zero, new TErrorProc(PDFError));
pdf.CreateNewPDF("e:/cppout.pdf");
// Do not convert pages to templates.
pdf.SetImportFlags(TImportFlags.ifImportAll | TImportFlags.ifImportAsPage);
// This flag reduces the memory usage drastically
pdf.SetImportFlags2(TImportFlags2.if2UseProxy);
pdf.OpenImportFile("c:/PDFs/testfile.pdf", TPwdType.ptOpen, null);
pdf.ImportPDFFile(1, 1.0, 1.0);
// Three header / footer strings should be output in this example
TPDFHdrFtr[]
hdr
= new TPDFHdrFtr[3];
TPDFHeaderFooter init = new TPDFHeaderFooter();
// Initialize the structures with default values
pdf.InitHeaderFooter(ref init, ref hdr);
init.InitColor
= 0;
init.InitCodepage
= TCodepage.cpUnicode;
init.InitEmbed
= true;
init.InitFont
= "Arial";
init.InitFontSize
= 8.0f;
init.Margin.Left
= 50.0f;
init.Margin.Right
= 50.0f;
init.Margin.Top
= 30.0f;
init.Margin.Bottom = 20.0f;
hdr[0].IsHeader
= true;
hdr[0].Text
= "This is a bates number: <<Bates#8#1>>";
hdr[0].Position
= TTextAlign.taCenter;
hdr[1].Color
= 255;
hdr[1].CS
= TExtColorSpace.esDeviceRGB;
hdr[1].Codepage
= TCodepage.cpUnicode;
hdr[1].Font
= "Arial,Italic";
hdr[1].FontSize
= 8.0f;
hdr[1].Embed
= true;
hdr[1].IsHeader
= true;
hdr[1].Text
= "Page numbering: <<Page 1 of n>>";
hdr[1].Position
= TTextAlign.taRight;
hdr[2].IsHeader
= false;
hdr[2].Text
= "Multiple formats: <<yyyy/mm/dd>> <<Bates#8#1>> <<Page 1 of n>>";
hdr[2].Position
= TTextAlign.taLeft;
pdf.AddHeaderFooter(ref init, ref hdr);
pdf.CloseFile();
}
 

Previous topic: Page numbering, Header / footer text, Header / footer types

Next topic: AddImage