You are here: GdPicture.NET > Documentation > Classes > GdPictureImaging Class > GdPictureImaging Methods > PDF Creation > Low-level Functions > PdfNewPdf > PdfNewPdf Method (Stream)
logo.gif
ContentsIndexHome
PreviousUpNext
GdPictureImaging.PdfNewPdf Method (Stream)

Creates a new PDF to a stream.

C#
public int PdfNewPdf(
    ref Stream PDFStream
);
Visual Basic
Public Function PdfNewPdf(
    ByRef PDFStream As Stream
) As Integer
Parameters
Parameters 
Description 
PDFStream 
The Stream object to create the PDF.  
Returns

0: The PDF could not created. Use the GetStat() function to determine the reason this function failed. 

Non-zero: A PDF Identifier.

A sample of PDF generation including basic elements such as image & texts.

Dim oGdPictureImaging As New GdPictureImaging
Dim PDFStream As IO.Stream = New IO.MemoryStream
Dim PdfID As Integer
Dim PDFImageID As Integer 'Pdf Image 1 idx
Dim Font1ID As Integer 'Pdf Font 1 idx
Dim Font2ID As Integer 'Pdf Font 2 idx
Dim Font3ID As Integer 'Pdf Font 3 idx
Dim Font4ID As Integer 'Pdf Font 4 idx
Dim Font5ID As Integer 'Pdf Font 5 idx
 
oGdPictureImaging.SetLicenseNumber("XXX") 'Replace XXX by a demo or commercial license key
 
PdfID = oGdPictureImaging.PdfNewPdf(PDFStream, False, "MyPdfTitle", "MyPdfAuthor", "MyPdfSubject", "MyPdfKeywords", "MyPdfCreator")
oGdPictureImaging.PdfSetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
 
'First Step: Add all ressources (fonts & images)
PDFImageID = oGdPictureImaging.PdfAddImageFromFile(PdfID, "oneimage.tif")
 
Font1ID = oGdPictureImaging.PdfAddTrueTypeFont(PdfID, "Arial", False, False) 'Add Arial font
Font2ID = oGdPictureImaging.PdfAddTrueTypeFont(PdfID, "Arial", True, False) 'Add Arial Bold font
Font3ID = oGdPictureImaging.PdfAddTrueTypeFont(PdfID, "Courier New", False, False) 'Add Courier new font
Font4ID = oGdPictureImaging.PdfAddTrueTypeFont(PdfID, "Symbol", False, False) 'Add symbol font
Font5ID = oGdPictureImaging.PdfAddTrueTypeFont(PdfID, "Times New Roman", False, True) 'Add Times NewRoman Italic
 
'Second Step: Make PDF
 
'Page 1
oGdPictureImaging.PdfNewPage(PdfID, 20, 15) 'Pages dimensions will be 20 x 15 cm
 
oGdPictureImaging.PdfDrawImage(PdfID, PDFImageID, 10, 10, 3, 2.5)
oGdPictureImaging.PdfDrawTextAlign(PdfID, 13, 9.5, "Arial Text Size 7 Align Right", Font1ID, 7, Color.Black, TextAlign.TextAlignRight)
oGdPictureImaging.PdfDrawText(PdfID, 5, 10, "Arial Text Size 7", Font1ID, 7, Color.Black, 0)
oGdPictureImaging.PdfDrawText(PdfID, 5, 9.5, "Arial Bold Text Bold Size 8", Font2ID, 8, Color.Black, 0)
oGdPictureImaging.PdfDrawText(PdfID, 5, 9, "Courier new Text Size 8", Font3ID, 8, Color.Black, 0)
oGdPictureImaging.PdfDrawText(PdfID, 5, 8.5, "ZapfDingbats Text Size 8", Font4ID, 8, Color.Black, 0)
oGdPictureImaging.PdfDrawText(PdfID, 5, 8, "Times NewRoman Text Italic Size 8", Font5ID, 8, Color.Black, 0)
oGdPictureImaging.PdfDrawText(PdfID, 8, 1, "Draw rotated text... http://www.gdpicture.com", Font5ID, 8, Color.Black, 0)
oGdPictureImaging.PdfDrawText(PdfID, 8, 1, "Draw rotated text... http://www.gdpicture.com", Font5ID, 8, Color.Black, 45)
oGdPictureImaging.PdfDrawText(PdfID, 8, 1, "Draw rotated text... http://www.gdpicture.com", Font5ID, 8, Color.Black, 90)
oGdPictureImaging.PdfDrawText(PdfID, 8, 1, "Draw rotated text... http://www.gdpicture.com", Font5ID, 8, Color.Black, 135)
oGdPictureImaging.PdfDrawText(PdfID, 8, 1, "Draw rotated text... http://www.gdpicture.com", Font5ID, 8, Color.Black, 180)
 
'Page 2
oGdPictureImaging.PdfNewPage(PdfID, 12, 12) 'Pages dimensions will be 12 x 12 cm
 
oGdPictureImaging.PdfDrawText(PdfID, 5, 10, "Red Color Text", Font2ID, 8, Color.Red, 0)
oGdPictureImaging.PdfDrawText(PdfID, 5, 9.5, "Green Color Text", Font2ID, 8, Color.Green, 0)
oGdPictureImaging.PdfDrawText(PdfID, 5, 9, "Blue Color Text", Font2ID, 8, Color.Blue, 0)
 
oGdPictureImaging.PdfSetTextHorizontalScaling(PdfID, 40)
oGdPictureImaging.PdfDrawText(PdfID, 5, 6, "Compressed Text", Font1ID, 10, Color.Black, 0)
 
oGdPictureImaging.PdfSetTextHorizontalScaling(PdfID, 200)
oGdPictureImaging.PdfDrawText(PdfID, 5, 5.5, "Extended Text", Font1ID, 10, Color.Black, 0)
 
oGdPictureImaging.PdfEndPdf(PdfID)
What do you think about this topic? Send feedback!
Copyright (c) 2009-2011 www.gdpicture.com. All rights reserved.