wxPdfDocument - odd behaviour under Vista Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
Pat Verner
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Sep 06, 2010 6:58 am

wxPdfDocument - odd behaviour under Vista

Post by Pat Verner »

I have been using the wxPdfDocument component for some years very happily:
I do the basic software development under linux, using wxWidgets-2.8.10 (GTK), and wxpdfdoc (libwxpdfdoc.so.0).
When I am happy with a build, I transfer the source to a Win98 host and recompile it using MSyS / MinGW, with the appropriate MSW components.
The resultant executables work well under Win98, Win2000, WinXP and Windows 7.

However, the same executable when run under Vista fails to produce readable PDF files! In this case, the PDF file is much smaller; trying to convert it to PS using ghostscript I get:
-----------------

**** Warning: File has an empty MediaBox. Using the current page size instead.
**** Warning: File has an empty MediaBox. Using the current page size instead.
**** Unknown operator: '-0.-0', processed as number, value: 0.0

**** Warning: Invalid 0.0 font scale given for Tf ****

**** Warning: Invalid 0.0 font scale given for Tf ****
**** Unknown operator: '-0.-0', processed as number, value: 0.0
**** Unknown operator: '-0.-0', processed as number, value: 0.0
---------------
The last few lines repeat a number of times...

I don't have a Vista machine available on which I can install the development environment, so I am hoping that someone may have some suggestions!

Regards
=Pat
utelle
Moderator
Moderator
Posts: 1128
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxPdfDocument - odd behaviour under Vista

Post by utelle »

Pat Verner wrote:I have been using the wxPdfDocument component for some years very happily:
Which version of wxPdfDocument do you use? During the last months I fixed some bugs. I'd recommend you get the latest version from the wxCode SVN.
Pat Verner wrote:I do the basic software development under linux, using wxWidgets-2.8.10 (GTK), and wxpdfdoc (libwxpdfdoc.so.0).
When I am happy with a build, I transfer the source to a Win98 host and recompile it using MSyS / MinGW, with the appropriate MSW components.
The resultant executables work well under Win98, Win2000, WinXP and Windows 7.

However, the same executable when run under Vista fails to produce readable PDF files! In this case, the PDF file is much smaller; trying to convert it to PS using ghostscript I get:
This is really weird. Could you provide sample PDF files? One which is ok, and one you produced under Vista? If possible produce the PDFs without page compression (use method SetCompression(false) right after instantiating the wxPdfDocument object).
Pat Verner wrote:I don't have a Vista machine available on which I can install the development environment, so I am hoping that someone may have some suggestions!
I don't have a Vista machine available either, but from sample PDFs I might be able to track down the problem.

Regards,

Ulrich
Pat Verner
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Sep 06, 2010 6:58 am

Post by Pat Verner »

Hi Ulrich

Thanks for the reply.

The version of wxPdfDocument in use is 0.8.0

I edited the source on the Win98 host, added the pdf.SetCompression(false) immediately after instantiating the wxPdfDocument, and recompiled.
I then generated a one page report on the W98 machine.
Next, I copied the executable to the vista machine, and generated what should be exactly the same report.

As before, the Vista report gives me a "junk" report!

Both PDF files attached.

Thanks, and Regards
=Pat
Attachments
pdf_samples.tar
The Correct version, from W98 machine, and the version generated on the Vista host.
(10 KiB) Downloaded 168 times
utelle
Moderator
Moderator
Posts: 1128
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Post by utelle »

Pat Verner wrote:The version of wxPdfDocument in use is 0.8.0
You should consider to update. The current version is 0.8.5 plus several bug fixes in wxCode SVN. Version 0.8.6 will hopefully be available by the end of the year.
Pat Verner wrote:I edited the source on the Win98 host, added the pdf.SetCompression(false) immediately after instantiating the wxPdfDocument, and recompiled.
I then generated a one page report on the W98 machine.
Next, I copied the executable to the vista machine, and generated what should be exactly the same report.

As before, the Vista report gives me a "junk" report!
Thanks for the sample files. SetCompression(false) certainly doesn't solve anything, but allows for easier inspection of the resulting PDF.

From the broken PDF I see that page width and height are both written as zero. The same with all text positions. I remember there was a problem with format codes in method Double2String.

Please change the format codes "%.0lf" at lines 2092 and 2098 in pdfdoc.cpp to "%.0f".

If this doesn't solve the problem, please check whether the paper size is correctly determined. Add the following code to your main application and output the resulting string str where it can be inspected.

Code: Select all

  // Set the page format you use (default wxPAPER_A4)
  wxPaperSize format = wxPAPER_A4

  wxPrintPaperDatabase* printPaperDatabase = new wxPrintPaperDatabase;
  printPaperDatabase->CreateDatabase();
  wxPrintPaperType* paperType = printPaperDatabase->FindPaperType(format);
  if (paperType == NULL)
  {
    paperType = printPaperDatabase->FindPaperType(wxPAPER_A4);
  }
  wxSize paperSize = paperType->GetSize();
  double fwPt = paperSize.GetWidth() / 254. * 72.;
  double fhPt = paperSize.GetHeight() / 254. * 72.;
  wxString str.Printf(wxT("w=%f h=%d"), fwPt, fhPt);
  delete printPaperDatabase;
Regards,

Ulrich
[/code]
Pat Verner
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Sep 06, 2010 6:58 am

Post by Pat Verner »

Voila - magic.

Made the 2 changes in pdfdoc.cpp, rebuilt, copied the DLLs over to the Vista machine, and out came the PDF reports as required. I find it amazing this problem has only manifested itself after several years of use on several machines.

I will also take schedule an upgrade to the latest release.

Thank you very much for your help, and for a very useful component.

Regards
=Pat
utelle
Moderator
Moderator
Posts: 1128
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Post by utelle »

Pat Verner wrote:I find it amazing this problem has only manifested itself after several years of use on several machines.
To my knowledge this particular bug surfaced only in MinGW run time library later than 3.14.

Just as a note to other users of wxPdfDocument:

Unfortunately this bug is also present in the file releases for wxPdfDocument version 0.8.5.

It was fixed about 4 months ago in the wxCode SVN. It is strongly recommended to download the latest version from the wxCode SVN. (There is a link at the bottom of the page for downloading a GNU tar ball.)

Regards,

Ulrich
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2409
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Post by evstevemd »

take back accepted answer to Utelle :wink:
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply