Web Connection
Web Connection 7.13 Print PDF Report Sample Returns Error
Gravatar is a globally recognized avatar based on your email address. Web Connection 7.13 Print PDF Report Sample Returns Error
  Peter H
  All
  May 30, 2020 @ 09:42am

I have upgraded to Web Connection 7.13 and tried the "Print PDF Report" button, but Chrome always returns an error "Failed to load PDF document". Microsoft Edge also returns a similar message.

After inspecting the HTML, the radio button "Display in browser" should be checked by default, but it is not checked on screen. Worse is neither "Display in browser" nor "Download" could be checked.

Tracing the button code to C:\wconnect\Samples\wwdemo\wwDemo.PRG, found FUNCTION PrintPdf() only handles either radio button being checked. If none checked, it simply exits!

So the issue is most likely in the rendering of the the radio buttons in the Demo page. Please help.

Gravatar is a globally recognized avatar based on your email address. re: Web Connection 7.13 Print PDF Report Sample Returns Error
  Rick Strahl
  Peter H
  May 30, 2020 @ 02:50pm

No that's not it. The problem with the check boxes is bad styling. It's using fonts for the radio buttons and the font values are actually incorrect so the checkboxes are not showing the right thing. They do work however.

You can fix this by going into the HTML for the default.htm and removing the class="with-font" from the radio buttons which makes them properly visible.

The problem you're seeing is likely your PDF output settings are not configured. The sample uses the Microsoft PDF driver for Windows 10. If you're not on Windows 10 or you don't have the driver installed the PDF generation won't work and you can switch to one of the other providers.

Please see wwPdf documentation here:

Class wwPdf

Thanks for reporting this - will be fixed in next update.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Web Connection 7.13 Print PDF Report Sample Returns Error
  Peter H
  Rick Strahl
  May 31, 2020 @ 10:50pm

Thanks Rick. Those 2 radio buttons are now rendered correctly and clickable after removing class="with-font" from C:\wconnect\Web\default.htm

With Print to PDF, the problem is PrintPdf() generating a PDF file which actually containing Postscript text!

There is no need to change C:\wconnect\WCONNECT.H as WWC_WWPDF is already predefined as wwPdfPrinterDriver.

On debugging using a Win 10 PC with "Microsoft Print to PDF", Ghostscript, FoxIt, PDF Architect 4, and "Xerox PS Class Driver", I found the function kept on using the "Xerox PS Class Driver". When the Xerox driver was removed from Windows Printers and Devices, it was still being used (see screenshot below) but now causing a VFP error on console "Error accessing printer spooler". Any suggestion Rick?

Gravatar is a globally recognized avatar based on your email address. re: Web Connection 7.13 Print PDF Report Sample Returns Error
  Rick Strahl
  Peter H
  Jun 1, 2020 @ 12:23pm

You can change the printer driver used in wcdemo.ini. Try changing it to:

Postscriptpdfprinterdriver=Microsoft Print to PDF

Looks like the default value has never been updated to reflect this driver.

Note - this value is just for the setting the printer driver for the demo - it's got nothing to do with setting the value in the processing - that's up to the application to set externally (as it does in the demo using that configuration value).

More info here in the docs: Generic PDF Printer Drivers and wwPdfPrinterDriver

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Web Connection 7.13 Print PDF Report Sample Returns Error
  Peter H
  Rick Strahl
  Jun 2, 2020 @ 03:55am

Thanks Rick for your help. Problem solved! This issue only occurs in the demo project. INI file for new projects are generated correctly.

There are 2 ways to fix the demo sample not generating PDF properly:

  • Add Postscriptpdfprinterdriver=Microsoft Print to PDF in the [Main] block of C:\wconnect\wcdemo.ini. This line is missing from the distro copy of wcdemo.ini.
  • Add oPdf.cPrinterDriver = "Microsoft Print to PDF" into Function PrintPDF() located in C:\wconnect\Samples\wwdemo\wwdemo.prg
Gravatar is a globally recognized avatar based on your email address. re: Web Connection 7.13 Print PDF Report Sample Returns Error
  Rick Strahl
  Peter H
  Jun 2, 2020 @ 12:11pm

You shouldn't have to set the value explicitly in wwDemo. I believe that's using the configuration settings - that's what it's there for.

*** WWC_WWPDF is defined in WCONNECT.H
*** or you can override it here 
*** wwGenericPdfDriver, wwGhostScript, wwXFRX, wwAmyUni
oPDF=CREATEOBJECT([WWC_WWPDF])     

*** Specify which printer driver to use for PostScript output with GhostScript
oPdf.cPrinterDriver = Server.oConfig.cPostScriptPdfPrinterDriver   && wcdemo.ini config setting

+++ Rick ---

© 1996-2020