Black page using PXCV_DrawPageToDC() on a printer DC

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

omascia
User
Posts: 48
Joined: Thu Mar 11, 2010 7:07 pm

Black page using PXCV_DrawPageToDC() on a printer DC

Post by omascia »

Dear,

I have an issue with PXCV_DrawPageToDC when using it on a printer device context. The page prints black. If you look at the following code, until yesterday the lines CRect rect... and FillRect where NOT there and the green section was NOT commented out. So there was no attempt to FillRect and I was using the VectorRenderer (along with DrawRect = 0). All was fine, perfectly fine.

Except that on some matrix printers where the horizontal DPI is sometimes different than the vertical DPI (let's say 120x72 dpi typical on an Epson FX-890 for instance) the results where wrong because even though I correctly map the page (my line drawings are correct), it looks like the fonts are not scaled appropriately (with 120x72 dpi they get too wide, with 120x144 dpi they get too narrow).

I fear this is bug #1 and out of my control within PXCV_DrawPageToDC(). To attempt to work-around this, I decided to give a try to using the raster renderer instead of the vector one. (I'm ready to add some printer setting to my app along the line "in case of printing issue, try this alternate method, albeit slower and needed more memory".)

I commented out the green section below and tried to print. I got a black page (which on matrix printer is a terrible thing to hear). Tested on my laser printer to save my ears, and got the black page too.

I remembered that when I did my initial experiments drawing on screen I had to use a FillRect to paint a background color before letting PXCV_DrawPageToDC() draw over it. (I have actually stopped doing this on screen since I use PXCV_DrawPageToDIBSection() to double-buffer and avoid flicker). So I added the code below to FillRect with WHITE_BRUSH. Whole black output. I tested against 5 printers (2 BW laser printers, 2 color laser printers and 1 matrix printer - epson fx-890), whole black page.

This starts looking strange to me and I'm ready to think there might something odd with my printer DC, but I'm mostly puzzled because if I remove the code below and do some native TextOut to that device context, I get a page without that black background.

What should I have a look at first?

...
CRect rect(0, 0, GetDeviceCaps(hdc, PHYSICALWIDTH), GetDeviceCaps(hdc, PHYSICALHEIGHT));
FillRect(hdc, &rect, (HBRUSH)GetStockObject(WHITE_BRUSH));


PXV_CommonRenderParameters params;
params.WholePageRect = &pageRect;
params.DrawRect = ▭
params.RenderTarget = pxvrm_Printing;
params.Flags = /*pxvrpf_UseVectorRenderer |
pxvrpf_EmbeddedFontAsCurves |*/

(rotate ? pxvrpf_Rotate_Rotate90CW : pxvrpf_None);

HRESULT hr = PXCV_DrawPageToDC(doc, page, hdc, &params);
...

Best Regards,
--
Olivier Mascia
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by Stefan - PDF-XChange »

Hello Oliver,

Got your mail as well as this topic.
Passed to the people that will be best able to investigate the problem and we will get back to you when we have any news.

Kind Regards,
Stefan
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by Lzcat - Tracker Supp »

Hi Oliver.
Please try to pass pxvrpf_NoTransparentBkgnd flag when call PXCV_DrawPageToDC.
HTH.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
omascia
User
Posts: 48
Joined: Thu Mar 11, 2010 7:07 pm

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by omascia »

Tracker Supp-Stefan wrote:Got your mail as well as this topic.
Thanks Stefan. I indeed first wrote the mail then I saw the warning about spam issues and the hint to preferably use the forum, so I duplicated here. I'll switch to the forum from now on for anything non related to licensing / commercial / private matters.
Thanks !
omascia
User
Posts: 48
Joined: Thu Mar 11, 2010 7:07 pm

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by omascia »

Lzcat - Tracker Supp wrote:Hi Oliver.
Please try to pass pxvrpf_NoTransparentBkgnd flag when call PXCV_DrawPageToDC.
HTH.
This is it. I discovered it right before my noon break too.

Though I don't seem to even need it because the vector renderer works well even on the anisotropic coordinates system of the matrix printer as long as I add pxvrpf_AllFontsAsCuves flag too. The black page issue was indeed a secondary problem while trying to work-around the issue I had with the vector renderer on some class of printers.

I see that using pxvrpf_NoTransparentBkgnd or not has no effect when using pxvrpf_UseVectorRenderer. I assume this is expected, at least I don't see a problem with that.

I'm still cleaning my code from all the debug experiments of these last hours, then I'll re-run a full test suite and report here.

Thanks!
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by Lzcat - Tracker Supp »

Yes, pxvrpf_NoTransparentBkgnd does not work when pxvrpf_UseVectorRenderer is specified - it affects only raster renderer.
When pxvrpf_NoTransparentBkgnd is specified we fill background using white color, otherwise render transparent bitmap (and this may cause troubles with a printing black boxes).
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
omascia
User
Posts: 48
Joined: Thu Mar 11, 2010 7:07 pm

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by omascia »

omascia wrote:I'm still cleaning my code from all the debug experiments of these last hours, then I'll re-run a full test suite and report here.
Confirmation after cleanup and full test suite: issue fixed, case closed.
Thanks for your support.
:)
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Black page using PXCV_DrawPageToDC() on a printer DC

Post by Stefan - PDF-XChange »

The pleasure is ours Olivier :)

Enjoy the weekend!
Stefan