Share via


LoadPDF Method in Class SMS_PDF_Package

The LoadPDF WMI class method imports a PDF into the store.

The following syntax is simplified from MOF code and is intended to show you the definition of the method.

sint32 LoadPDF(
  [in,SizeLimit("100")] string PDFFileName,
  [in] string PDFFile,
  [out] uint32 PDFID,
  [out] string RequiredIconNames[]
);

Parameters

  • PDFFileName
    Data type: string
    Qualifiers: In

    Full path and filename of the PDF file. The provider copies the file to the \Smsinstalldir\Scripts\<localeid>\Pdfstore\<pdfid> directory and replaces the .pdf extension with a .SMS extension.

  • PDFFile
    Data type: string
    Qualifiers: In

    Text of the PDF file itself.

  • PDFID
    Data type: uint32
    Qualifiers: Out

    Assigned PDF identifier.

  • RequiredIconNames
    Data type: string[]
    Qualifiers: Out

    List of icons referenced by this PDF, which need to be loaded separately through the LoadIconForPDF method.

Return Values

The LoadPDF method returns a sint32 containing 0 (zero) for success, or the following bit field warning flags.

Flag Description
WARN_BAD_RUN (0) Invalid run information specified.
WARN_BAD_RESTART (1) Invalid restart information specified.
WARN_BAD_CANRUNWHEN (2) Invalid CanRunWhen information specified.
WARN_BAD_ASSIGNMENT (3) Invalid assignment information specified.
WARN_BAD_DEPENDPROG (4) Invalid DependentProgram information specified.
WARN_BAD_SPECIFYDRIVE (5) Invalid SpecifyDrive information specified.
WARN_BAD_ESTDISKSPACE (6) Invalid EstimatedDiskSpace information specified.
WARN_NO_SUPPCLINFO (7) No SupportedClients information specified.
WARN_BAD_SUPPCLINFO (8) Invalid SupportedClients information specified.
WARN_VER1PDF (9) Version 1.0 file used.
WARN_REMPRONOUKEY (10) Remove-program is set but no uninstall key given.

Remarks

When you import a PDF that has the same Name, Publisher, Version, and Language properties as that of an existing PDF, the existing PDF is overwritten. This includes the existing PDF icons, programs, and PDF file. The PDFID value is retained.

Example Code

The following example shows you how to load a PDF into the SMS PDF package store.

    Const ForReading = 1

    Dim fs, f                         'File system object and file object
    Dim clsPDF As SWbemObject         'SMS_PDF_Package class definition
    Dim ReturnCode As Long            'Return code value from LoadPDF method
    Dim PDFID As Long                 'PDF identifier generated from LoadPDF
    Dim PDFContent As String          'PDF file content
    Dim ReqIconNames() As Variant     'Required icon names from LoadPDF
    Dim Icon() As Byte                'Icon used as input to LoadIconForPDF method
    Dim i, j As Integer
    Dim FileSize As Integer           'Size of the icon file


    Set Services = GetObject("winmgmts:\root\sms\<sitecode>")

    'Open the PDF file and read the content into a string.
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.OpenTextFile(<path\filename>, ForReading)
    PDFContent = f.ReadAll
    f.Close

    'Load the PDF into the PDF store. Use the PDFID and ReqIconNames
    'variables in the LoadIconForPDF method.
    Set clsPDF = Services.Get("SMS_PDF_Package")
    ReturnCode = clsPDF.LoadPDF(<path\filename>, _
                                PDFContent, _
                                PDFID, _
                                ReqIconNames)

    'You need to load all the icons for the PDF if the PDF contains icons.
    For i = LBound(ReqIconNames) To UBound(ReqIconNames)
        Open <path> & ReqIconNames(i) For Binary Access Read As #1
        FileSize = LOF(1) - 1
        ReDim Icon(FileSize)
        For j = 0 To FileSize
            Get #1, , Icon(j)
        Next
        Close #1

        clsPDF.LoadIconForPDF PDFID, ReqIconNames(i), Icon
    Next

See Also

Handling PDF Errors, LoadIconForPDF, ProcessInBox, SMS_PDF_Package