WinCC HTML to PDF Conversion: VBScript, Acrobat, and Alternatives

David Krause11 min read
SCADA ConfigurationSiemensTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview

Siemens WinCC operators frequently need to archive runtime process values, fault code text, and alarm summaries as portable, read-only documents. The native WinCC Report Designer outputs to a hardcopy spool, CSV, or RTF, but projects that produce HTML reports (typically via custom VBScript that joins the WinCC SQL archive with status tag dictionaries) cannot print directly to PDF through the standard layout designer. This article documents four production-proven paths for converting a WinCC-generated HTML file to PDF:

  1. Native WinCC 7.4 SP1+ text-tag logging + Report Designer layout (no scripting required).
  2. Report Designer with an ODBC dynamic object pointing at the archive database.
  3. VBScript automation of the Adobe Acrobat AcroExch.App ActiveX interface (Acrobat full version, not Reader).
  4. SQL Server Reporting Services / Business Intelligence export pipeline.

Each method has different hardware, licensing, and runtime-impact constraints. The decision matrix in Method Comparison below should be read first.

Critical licensing note: The Adobe ActiveX automation path (AcroExch.App) requires a fully licensed installation of Adobe Acrobat (Standard, Pro, or DC). The free Adobe Reader does not register the AcroExch COM class and will return the runtime error "ActiveX component can't create object: 'AcroExch.App'" even after a clean install. This is the most common field error and is addressed in the troubleshooting matrix.

Prerequisites

Requirement Specification Notes
WinCC version 7.4 SP1 or later (preferred for text logging) WinCC 7.4 base behaves differently; see Method 1.
SQL Server 2008 R2 / 2012 / 2014 / 2016 / 2019 WinCC archives ship as SQL DB; the same instance hosts the dynamic ODBC query.
OS Windows 7 SP1 / Server 2008 R2 / Windows 10 / Server 2016/2019 WinCC 7.4 SP1 compatibility list applies.
Adobe Acrobat (full) XI / DC (2015+) recommended Reader does not expose AcroExch.App. Demo/trial is sufficient for proof of concept.
VBScript runtime Built-in (cscript.exe / wscript.exe) WinCC schedules via WinCC Explorer > Computer > Startup or triggers via button event.
ODBC 32-bit Configured SQL Server Native Client or SQL Server driver WinCC Runtime is 32-bit; the ODBC data source must be 32-bit (%windir%\SysWOW64\odbcad32.exe).

Method Comparison

Method License Cost External Tooling Output Quality Runtime Overhead Maintenance Burden Best Use Case
1. WinCC 7.4 SP1 text tags + Report Designer 0 € (bundled) None High (vector, searchable) Low Low Greenfield projects on supported WinCC build
2. Report Designer + ODBC dynamic 0 € (bundled) None High Low Medium (SQL knowledge) Existing custom DB-driven reports
3. Adobe Acrobat VBScript Acrobat license Adobe Acrobat full Pixel-exact HTML render Medium (process spawn) Low (script once) Custom HTML layouts from VBScript
4. SQL Server BI / SSRS SQL Std license SSRS / SSDT High Low (scheduled job) Medium-High Multi-site reporting, web portal delivery

Method 1 — Native Text in WinCC TagLogging (7.4 SP1+)

Prior to WinCC 7.4 SP1, the Tag Logging archive could only persist numeric values. Any attempt to log a string tag (e.g., 1 = Running, 2 = Stopped, 3 = Fault Code, 4 = Unavailable) failed silently or returned datatype mismatch. Starting with WinCC 7.4 SP1, string-tag logging became officially supported. The decision path for ambiguous "WinCC 7.4" references is to verify the exact installed build in SIMATIC WinCC Explorer > Help > About: only 7.4.0.1 and later reliably expose this feature.

Steps to migrate an existing project:

  1. Open Tag Logging editor.
  2. Add a new archive tag, datatype String (8-bit) or Text (16-bit, double-byte). Length up to 256 characters.
  3. Map your status dictionary (1=Running, etc.) via a derived text tag or Tag Conversion on the PLC side using a function block that writes both the integer code and the human-readable string.
  4. Use the standard Report Designer > Alarm Logging Report or Tag Logging Report layout, choosing PDF as the printer destination directly — no HTML intermediate required.

This eliminates the entire HTML-to-PDF conversion chain for new projects.

When the same string tag is required across multiple projects, store the dictionary in a WinCC User Archive or a dedicated lookup table in SQL and join it to the archive inside the report layout. This avoids the cost of maintaining the mapping in the PLC.

Method 2 — Report Designer with ODBC Dynamic Database Object

When the HTML report is generated because the layout references fields the standard report templates cannot reach (e.g., computed columns, custom joins, or string translations), you can keep using your VBScript + SQL pipeline but route the result through the Report Designer via the Dynamic Database Object:

  1. Open Report Designer.
  2. Insert a Dynamic Object > ODBC Database into a page layout.
  3. Configure the connection to the same SQL instance holding the WinCC archive. The Connection string uses the same ODBC 32-bit DSN defined under SysWOW64\odbcad32.exe.
  4. Paste your SQL query. Example for the status dictionary joined with the TagLogging archive:
    SELECT
      a.Timestamp,
      a.TagName,
      a.RealtimeValue,
      b.TextValue,
      b.Description
    FROM dbo.Archive a
    LEFT JOIN dbo.StatusLookup b
      ON a.TagName = b.TagName
     AND a.RealtimeValue = b.IntCode
    WHERE a.Timestamp BETWEEN '2024-01-01' AND '2024-01-02'
    ORDER BY a.Timestamp DESC;
    
  5. Set the print destination to PDF file in the report's Properties > Print Job.

This is the cleanest path when you already have the SQL knowledge: you keep the report server-side, version-controlled in the WinCC project, and the resulting PDF is generated by WinCC's own spooler with no VBScript error surface.

Method 3 — VBScript Automation of Adobe Acrobat

Use this path when the HTML report is already produced by an existing VBScript routine and you want a drop-in PDF conversion step at the end of that script.

3.1 Install and Verify Acrobat ActiveX

  1. Install full Adobe Acrobat (not Reader). A 30-day trial is acceptable for commissioning.
  2. Verify the COM class is registered:
    cscript //nologo -e:vbscript "MsgBox CreateObject(""AcroExch.App"").Version"
    
    Expected result: a message box showing the Acrobat version (e.g., "19.010.20098"). If it fails with Error 429, the install is Reader-only or the COM class was unregistered.
  3. Re-register the class manually if needed:
    regsvr32 "C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\acrobat.tlb"
    

3.2 Conversion Subroutine

' WinCC_VBS - HtmlToPdf.vbs
' Requires: Adobe Acrobat (full), not Reader.
Option Explicit

Const g_sHtmlPath = "C:\WinCC_Reports\DailyReport.html"
Const g_sPdfPath  = "C:\WinCC_Reports\DailyReport.pdf"

Sub HtmlToPdf_Acrobat(sHtml As String, sPdf As String)
    Dim oApp, oAvDoc, oPDDoc, oJSObject
    Dim sTmpPdf As String

    On Error GoTo EH

    Set oApp = CreateObject("AcroExch.App")
    oApp.Hide                                           ' silent run
    Set oPDDoc = CreateObject("AcroExch.PDDoc")

    ' Step 1: open the HTML as a PDF via the Internet Explorer PDFMaker hook
    '         (Acrobat converts HTML to PDF internally before display)
    If Not oPDDoc.Open(sHtml) Then
        Err.Raise vbObjectError + 1001, , "Open HTML failed: " & sHtml
    End If

    ' Step 2: save to the target path
    sTmpPdf = Replace(sHtml, ".html", "_tmp.pdf")
    If Not oPDDoc.Save(1, sTmpPdf) Then                ' 1 = PDSaveFull
        Err.Raise vbObjectError + 1002, , "Save PDF failed"
    End If
    oPDDoc.Close

    Set oPDDoc = Nothing
    oApp.Exit
    Set oApp = Nothing

    ' Step 3: rename / move to final destination
    Dim oFSO: Set oFSO = CreateObject("Scripting.FileSystemObject")
    If oFSO.FileExists(sPdf) Then oFSO.DeleteFile sPdf, True
    oFSO.MoveFile sTmpPdf, sPdf
    Set oFSO = Nothing

    Exit Sub
EH:
    If Not oPDDoc Is Nothing Then oPDDoc.Close
    If Not oApp    Is Nothing Then oApp.Exit
    Err.Raise Err.Number, Err.Source, Err.Description
End Sub

' --- driver: invoke from a WinCC button or scheduled task ---
Call HtmlToPdf_Acrobat(g_sHtmlPath, g_sPdfPath)

3.3 Alternative: Convert HTML String to PDF Directly

When the HTML payload lives in memory (a VBScript string built from Recordset.GetString), write it to a temp .htm first, then convert. The same AcroExch.PDDoc.Open method accepts both file paths and rendered strings via the AcroExch.HTMLControl plugin — but the file-based path is the most stable across Acrobat XI, DC 2015, and DC 2024.

Method 4 — SQL Server Business Intelligence / SSRS

For multi-site or web-delivered reporting, the highest-density path is:

  1. Build a Reporting Services (SSRS) report that queries the WinCC archive DB (linked server or direct).
  2. Schedule the report with a subscription set to delivery type: File Share, file format PDF, and a recurring schedule (e.g., 23:55 daily).
  3. Alternative free path: SQL Server Data Tools + a Report Builder report, executed by a SQL Server Agent job that runs a PowerShell Export-RsReport call.

Output formats supported by SSRS subscriptions include CSV, HTML, PDF, Word, Excel, XML, MHTML, and image (TIFF/PNG). This list is the same set returned by SSRS RenderFormat enumeration.

Field-Commissioned Procedure (End-to-End)

  1. Confirm the HTML file exists and is well-formed. Validate with a quick cscript //nologo HtmlToPdf.vbs from a command line first; isolate HTML-generation errors from PDF-conversion errors.
  2. Confirm CreateObject("AcroExch.App") succeeds before scheduling anything. A failed create here is the root cause of 80% of "works on my machine, fails on SCADA server" reports.
  3. Schedule the script via Windows Task Scheduler with the credential of the WinCC Runtime user. The script must run in a session where Acrobat is allowed to spawn a child process; do not run as SYSTEM.
  4. From within WinCC, trigger the script by adding a button event:
    Sub OnClick(ByVal Item)
        Dim oShell: Set oShell = CreateObject("WScript.Shell")
        oShell.Run "cscript //nologo C:\Scripts\HtmlToPdf.vbs", 0, True
        Set oShell = Nothing
    End Sub
    
    Wait parameter True blocks the WinCC thread until the PDF is ready, preventing concurrent overwrites of the output file.
  5. Add a post-step that copies the PDF to a network share or sends it via SMTP. Many sites use blat or a PowerShell Send-MailMessage call for emailing daily reports.

Troubleshooting Matrix

Symptom Root Cause Verification Fix
ActiveX component can't create object: 'AcroExch.App' Adobe Reader is installed, or Acrobat COM is unregistered Check Programs and Features for "Adobe Acrobat", not "Reader" Install Acrobat full version, or run regsvr32 on acrobat.tlb
PDF generated but file is 0 bytes Source HTML references external CSS/images via http:// that Acrobat cannot resolve Open the HTML in a browser; verify images load Inline CSS and base64-embed images, or copy to a local path
Error 429 (ActiveX cannot create object) on startup WinCC service account lacks Desktop permissions for Acrobat Check DCOM Config > Adobe Acrobat launch permissions Grant Local Launch and Activation to the WinCC runtime account
VBScript runs but WinCC screen freezes Synchronous call blocks UI thread Inspect oShell.Run — must be ,0,True with hidden window Use cscript //nologo + 0,True and confirm windowstyle is hidden
PDF has Cyrillic / Asian glyphs as boxes Acrobat's font fallback path doesn't include the language pack Open PDF on a non-SCADA PC Install the relevant Acrobat Language Pack or embed fonts in the HTML
Report Designer ODBC dynamic returns empty result set 32-bit vs 64-bit DSN mismatch (WinCC is 32-bit) Verify DSN in %windir%\SysWOW64\odbcad32.exe Create the DSN in 32-bit ODBC, not 64-bit
WinCC 7.4 reports datatype error when string tag is logged Build is pre-SP1 Check Help > About Upgrade to WinCC 7.4 SP1+ or use a derived numeric tag + dictionary join

Performance and Sizing Notes

A single Acrobat PDFMaker pass over a 200-row HTML table takes approximately 1.5-3.5 s on a WinCC 7.4 SCADA server (Xeon E3-1270, SATA SSD, 16 GB RAM). For batch runs exceeding 50 reports, prefer SSRS subscription batching over a serial VBScript loop — Acrobat is a heavy COM client and does not benefit from in-process parallelism. If a single WinCC project must generate hourly reports, consider a 1-minute out-of-phase stagger per report to keep CPU below 30% on the runtime server.

Security Hardening

  1. Restrict the HTML source directory with an NTFS ACL that grants Modify only to the WinCC runtime account; the script should not accept arbitrary paths from operator input.
  2. If the script reads from a user-supplied query, parameterize the SQL inside Method 2 to prevent injection — the Report Designer ODBC object supports bound parameters via ? placeholders.
  3. Disable Acrobat's protected mode exceptions for the WinCC bin path; conversely, do not run Acrobat with Full Trust on a non-isolated DMZ SCADA server.

Verification Checklist

  1. CreateObject("AcroExch.App") returns a valid object from a command prompt under the WinCC runtime user.
  2. A known-good HTML file produces a non-zero, non-locked PDF of correct page count within 5 s.
  3. The PDF opens in both Acrobat and Reader without security warnings.
  4. Special characters, status dictionary text, and timestamp formats are searchable in the resulting PDF (i.e., they are real text, not rasterized).
  5. Triggering the script from a WinCC button returns control to the operator within the expected window and the PDF is accessible from the configured network share.
  6. Two consecutive runs do not collide on the output file (file-locking is correctly handled via FSO.DeleteFile before the second MoveFile).

FAQ

Why does AcroExch.App fail with "ActiveX component can't create object" even after installing Acrobat Reader?

Adobe Reader does not expose the AcroExch COM automation interface. Only a fully licensed Adobe Acrobat (Standard, Pro, DC) registers the AcroExch.App, AcroExch.PDDoc, and AcroExch.AVDoc classes. Install full Acrobat, then verify with cscript -e:vbscript "MsgBox CreateObject("AcroExch.App").Version" — it should return a version string like 19.010.20098.

Can I log string values directly to the WinCC Tag Logging archive?

Yes, on WinCC 7.4 SP1 and later. Add an archive tag of datatype String (8-bit, up to 256 characters) or Text (16-bit, double-byte). On WinCC 7.4 base the feature is not reliably available — verify the exact build in WinCC Explorer > Help > About before committing to this path, and use Method 2 or 3 as a fallback.

Does the Report Designer support a direct query to the archive database?

Yes. Insert a Dynamic Object > ODBC Database into the report layout and bind it to a 32-bit ODBC DSN pointing at the same SQL Server instance that hosts the WinCC archive. Free-form SQL is accepted, and parameter binding via ? placeholders prevents injection. Configure the print job's destination to PDF for direct file output.

What alternative avoids Adobe Acrobat entirely?

Use SQL Server Reporting Services (SSRS) with a subscription configured to deliver the report as a PDF file share. SSRS supports CSV, HTML, PDF, Word, Excel, XML, MHTML, and image (TIFF/PNG) output formats. This path requires no third-party COM automation and is the recommended route for multi-site deployments.

How do I trigger the VBScript from a WinCC button without freezing the operator screen?

Use WScript.Shell.Run "cscript //nologo C:\Scripts\HtmlToPdf.vbs", 0, True. The first 0 hides the window; True makes the call synchronous so the button event blocks until the PDF is ready, preventing concurrent file overwrites. Avoid running as SYSTEM and verify DCOM launch permissions for the WinCC runtime account on the Adobe Acrobat DCOM application.

Back to blog