DrawToDevice only shows thumbs of the pages pages

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Hi,

I want to Print PDF Files directly.
I tried it with the DrawToDevice function.
I run into the problem, that I only get a thumbnail in the upper left corner.

I tried it with the MFC Sample to print the file directly and there is the same prblem.

Here is my sample code:
private void PrintPage(object sender, PrintPageEventArgs ev)
{
var page = Pages[m_currentPageIndex];
double page_w, page_h;
page.GetDimension(out page_w, out page_h);

page_w = (page_w / 72.0) * 100;
page_h = (page_h / 72.0) * 100;
double k1 = (double)ev.PageSettings.PaperSize.Width / (double)ev.PageSettings.PaperSize.Height;
double k2 = page_w / page_h;
if (k1 < k2)
{
page_w = Math.Min(page_w, (double)ev.PageSettings.PaperSize.Width);
page_h = page_w / k2;
}
else
{
page_h = Math.Min(page_h, (double)ev.PageSettings.PaperSize.Height);
page_w = page_h * k2;
}

SFDebug.LogDebug(string.Format("Nach rumrechnen page_w: {0} page_h: {1}", page_w, page_h));

tagRECT adjustedRect = new tagRECT();
adjustedRect.left = (int)(ev.PageSettings.HardMarginX + (double)ev.PageSettings.PaperSize.Width - page_w) / 2;
adjustedRect.right = adjustedRect.right + (int)page_w;
adjustedRect.top = (int)(ev.PageSettings.HardMarginY + (double)ev.PageSettings.PaperSize.Height - page_h) / 2;
adjustedRect.bottom = adjustedRect.top + (int)page_h;

adjustedRect.left *= ev.PageSettings.PrinterResolution.X / 100; // convert to device units
adjustedRect.right *= ev.PageSettings.PrinterResolution.X / 100; // convert to device units
adjustedRect.top *= ev.PageSettings.PrinterResolution.Y / 100; // convert to device units
adjustedRect.bottom *= ev.PageSettings.PrinterResolution.Y / 100; // convert to device units

var pROpt = g_Inst.CreateStdOCCtx();
pROpt.PrintContentFlags = (uint)PXC_RenderType.RenderType_ModePrint;

hDC = ev.Graphics.GetHdc();
var dm = page.GetMatrix(PXC_BoxType.PBox_MediaBox);
dm.e = adjustedRect.left;
dm.f = adjustedRect.top;

page.DrawToDevice((uint)hDC, ref adjustedRect, dm, (uint)PXC_DrawToDeviceFlags.DDF_AsVector, null, pROpt, null);

m_currentPageIndex++;
ev.HasMorePages = (m_currentPageIndex < Pages.Count);

}

Whats wrong?

Regards,
Christian
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

I'm guessing that you've specified the matrix incorrectly, though we will need a working sample project to tell you more.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Hi,
sorry for the late answer. I was in vacation.

I used your MFCSample (the last entry in the tree)
MFCSample.zip
(190.31 KiB) Downloaded 168 times
You can see it in the sf.pdf.print too.
SF.PDF.Print.zip
(162.38 KiB) Downloaded 168 times
Regards,
Christian
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

This positioning is being defined by the PXC_Matrix in the DrawToDevice method. In this sample, the page is being defined like that for the demonstration. If you need the whole page value - then either specify the null matrix argument (that cannot be done in .Net) or specify the correct matrix. In your case - it's a simple rect to rect matrix calculation:

Code: Select all

PXC_Rect rcPageBox = page.get_Box(PXC_BoxType.PBox_PageBox);
PXC_Rect rcAR = new PXC_Rect();
rcAR.left = adjustedRect.left;
rcAR.right = adjustedRect.right;
rcAR.top = adjustedRect.top;
rcAR.bottom = adjustedRect.bottom;
PXC_Matrix dm = g_AUX.MathHelper.Matrix_RectToRect(ref rcPageBox, ref rcAR);

page.DrawToDevice((uint)hDC, ref adjustedRect, dm, (uint)PXC_DrawToDeviceFlags.DDF_AsVector, null, pROpt, null);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Hi,

ok, I put it into my code and got a complete page.
But it lasts 3 Seconds to print one page.

What can be the reason for that?

Best regards,
Christian
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

Have you tried printing different types of files (file complexity)? Do they give the same time frames?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Yes, I tried a very simlpe one generated with MS Word.
See attachment.
SF.PDF.Print.zip
(252.66 KiB) Downloaded 167 times
Regards,
Christian
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

I've asked a developer who can say more about this one - though it would be better if you experiment with few more files to make some statistical data. Also, try printing in the End-User Editor and see what time does it take to do so.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

I Tried it in the enduser editor and it prints the complex pages immediately.
In the downloadlink before, you got the simplest pages I can get.

Regards,
Christian
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

I see, well, we will wait for the reply then.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Ivan - Tracker Software »

If you are drawing on your screen, do not use PXC_DrawToDeviceFlags.DDF_AsVector flag.
Use it only when you print.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

I want to Print.
So it maybe the right one.
Or not?

But for Printing 7 Pages I have to wait 21 seconds?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Freund,

Please try using the DDF_EmbeddedFontAsCurves flag and tell us the results.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Hi,

I changed the line

page.DrawToDevice((uint)hDC, ref adjustedRect, dm, (uint)PXC_DrawToDeviceFlags.DDF_AsVector, null, pROpt, null);
to
page.DrawToDevice((uint)hDC, ref adjustedRect, dm, (uint)PXC_DrawToDeviceFlags.DDF_EmbeddedFontAsCurves, null, pROpt, null);
in the code i posted.

Nothings changed.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Freund,

Have you tried using both flags?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Yes, but no difference.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Freund,

The developer who is responsible for this will investigate it and will reply here.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Ok thanks.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17824
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Tracker Supp-Stefan »

:)
Freund
User
Posts: 42
Joined: Fri Mar 16, 2018 9:51 am

Re: DrawToDevice only shows thumbs of the pages pages

Post by Freund »

Hi,

any news here?
In the Editor SDK is the performance much better.
How could that be?

Regards
Christian
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

The developer who can look at this won't be able to do so for a week or so, so bump this thread again in a week time please.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDevice only shows thumbs of the pages pages

Post by Sasha - Tracker Dev Team »

Hello Christian,

We've investigated the problem and found an explanation why it takes so much time to print a simple 2 words document. The answer is - Demo Labels. You have not specified the valid license key, thus the demo labels are also being printed as images with opacity - thus it takes you approximately 2 seconds for each page.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply