DrawToDC method

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

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, 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
mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

DrawToDC method

Post by mmasood » Tue Mar 28, 2017 3:18 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDC method

Post by Sasha - Tracker Dev Team » Wed Mar 29, 2017 8:42 am

Hello mmasood,

Please check out this topic, probably it should help:
http://www.tracker-software.com/forum3/ ... 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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

whoit
User
Posts: 271
Joined: Tue Jul 07, 2015 3:30 pm

Re: DrawToDC method

Post by whoit » Fri Apr 21, 2017 3:55 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDC method

Post by Sasha - Tracker Dev Team » Mon Apr 24, 2017 2:04 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

Re: DrawToDC method

Post by mmasood » Mon Apr 24, 2017 2:27 pm

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
Attachments
TrackerPrintNew.pdf
(22.51 KiB) Downloaded 102 times

User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDC method

Post by Sasha - Tracker Dev Team » Mon Apr 24, 2017 2:51 pm

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:
http://www.tracker-software.com/forum3/ ... 68#p112077

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

Re: DrawToDC method

Post by mmasood » Mon Apr 24, 2017 4:22 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDC method

Post by Sasha - Tracker Dev Team » Mon Apr 24, 2017 6:15 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

mmasood
User
Posts: 99
Joined: Fri Sep 18, 2015 9:49 pm

Re: DrawToDC method

Post by mmasood » Mon Apr 24, 2017 7:08 pm

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

User avatar
Sasha - Tracker Dev Team
User
Posts: 4522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: DrawToDC method

Post by Sasha - Tracker Dev Team » Mon Apr 24, 2017 8:05 pm

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
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply