Page 1 of 1
DrawToDC method
Posted: Tue Mar 28, 2017 3:18 pm
by mmasood
Hi,
I am using the function DrawToDC but it is taking too long to print the vector pages. Even on the text pages it takes upto 2-5 seconds per page to draw that page. Is there any sample that I can see that prints a simple file (a pdf) using this method so that I can follow the code?
I am currently using VB6 but am open to C# as well.
Regards,
M
Re: DrawToDC method
Posted: Wed Mar 29, 2017 8:42 am
by Sasha - Tracker Dev Team
Hello mmasood,
Please check out this topic, probably it should help:
https://forum.pdf-xchange.com/ ... 66&t=27826
If not, please provide a small sample with the code that you are using, so that we can look whether it can be optimized in your case.
Cheers,
Alex
Re: DrawToDC method
Posted: Fri Apr 21, 2017 3:55 pm
by whoit
Hi Alex -
The post you refer to talks about DrawToIXCPage.
If mmassod is trying to print directly to a printer is DrawToIXCPage still a viable (and faster) option?
Or is the original DrawToDC still the proper way?
Also, I have noticed delays of up to 30 seconds when trying to print a vector page.
So when I'm printing a PDF of a few pages it's not too noticeable, but when I try to print a PDF of 20+ pages,
the delays add up to several minutes. A 60 page document can take 15 minutes or more to print !
I tried using a bitmap option but the resulting printed output was not very good, regardless of my resolution.
Only vector output will work for me.
I will try to get some sample code and a document for you to review, but my clients documents all require NDAs.
I will probably have to make one up that has the same issue.
-Wayne
Re: DrawToDC method
Posted: Mon Apr 24, 2017 2:04 pm
by Sasha - Tracker Dev Team
Hello whoit,
The correct method is to use the IPXC_Page::DrawToDevice method with the DDF_AsVector flag (if you want to print the vector pages that is) and omit using the IIXC_Page.
Cheers,
Alex
Re: DrawToDC method
Posted: Mon Apr 24, 2017 2:27 pm
by mmasood
Hi Alex,
I am using the following code to print out a 8.5 x 11 page:
Code: Select all
Dim oPage As IPXC_Page
Set oPage = pDoc.Pages.Item(l_currentPage)
Dim oMatrix As PXC_Matrix
oMatrix.a = 1
oMatrix.b = 1
oMatrix.c = 1
oMatrix.d = 1
oMatrix.e = 1
oMatrix.f = 1
renderRect.Top = 0
renderRect.Left = 0
renderRect.bottom = 6120 '7920 '6120 '850 '612
renderRect.Right = 7920 '6120 '7920 '1100 '792
Dim oParams As IPXC_PageRenderParams
Set oParams = Form1.pInst.CreateRenderParams
oParams.PageViewBox = PBox_MediaBox
oParams.RenderFlags = RF_DisplayLargeImages & RF_SmoothImages
oParams.TextSmoothMode = TSM_ClearType
Dim oContext As IPXC_OCContext
Set oContext = Form1.pInst.CreateStdOCCtx
oContext.RenderType = RenderType_ModePrint
oContext.Resolution = 300
oContext.PrintContentFlags = CF_SETACTIVATEDEFAULT
oContext.ZoomLevel = 100
oPage.DrawToDevice Form1.clP.hdc, renderRect, oMatrix, DDF_AsVector, oParams, oContext
The output is just a thumbnail. I have attached the file with the post.
What should I be doing to get the output page to be resized correctly?
Regards,
M
Re: DrawToDC method
Posted: Mon Apr 24, 2017 2:51 pm
by Sasha - Tracker Dev Team
Hello mmasood,
Well, you will need to specify a correct transformation matrix. Here's a big topic and a post that starts the discussion about matrices:
https://forum.pdf-xchange.com/ ... 68#p112077
Cheers,
Alex
Re: DrawToDC method
Posted: Mon Apr 24, 2017 4:22 pm
by mmasood
Hi Alex,
Can you please describe or provide a link where the description of how the matrix is constructed? I have went through the link that you provided and could not find it there.
I am using the Core Api if that makes any difference.
Regards,
M
Re: DrawToDC method
Posted: Mon Apr 24, 2017 6:15 pm
by Sasha - Tracker Dev Team
Hello mmasood,
Well, the link I gave you implies that you will need to construct the matrix for yourself as it's a part of the PDF Specification, not the SDK. Also in that topic there is a pointer to the PDF Specification:
You can read the PDF Specification to understand the matrices more:
8.3 Coordinate systems
8.9 Images
Cheers,
Alex
Re: DrawToDC method
Posted: Mon Apr 24, 2017 7:08 pm
by mmasood
Hi Alex,
I am still not able to figure out the matrix. Can you provide a sample matrix and render rectangle so that I can print a Letter size Portrait pdf onto a Letter size Portrait paper at 300 DPI?
Regards,
M
Re: DrawToDC method
Posted: Mon Apr 24, 2017 8:05 pm
by Sasha - Tracker Dev Team
Hello mmasood,
Writing custom code is not a part of the SDK support. Though I have a sample that you might want to check out:
https://gist.github.com/Polaringu/0c7a1191ec1ff1e38176
Also, searching through forums (both Core and Editor) might be helpful.
PS: The methods used with matrices in the sample I gave are now a part of the SDK, though their naming is slightly modified - search the sdkhelp wiki for those.
Cheers,
Alex