PXC_GetContentDC()

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics.

Moderators: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Sean - Tracker, Andrew - Tracker Support, Tracker - Clarion Support, John - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Support Staff, moderators

Post Reply
ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

PXC_GetContentDC()

Post by ken66 » Tue Jun 07, 2005 9:11 pm

Do you have any more documentation or examples of how PXC_GetContentDC() shouls be used? I am assuming that the HDC* can be used to create a windows DC using Attach(HDC).

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed Jun 08, 2005 9:03 am

Hi Ken,

have you looked in the standard help file and description therein:PDFLib30Help.chm

i.e. :
Function PXC_GetContentDC allows the creation of a context device, connected with any active content content and compatible with refDC.

This is then utilised with the active content and the help of standard Windows API GDI functions.

The function creates a context device cdc compatible with refdc to the page from which pass to the first parameter as 'content'
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Wed Jun 08, 2005 2:48 pm

Yeah, that is what the help says but I haven't been able to get it to work. I was looking for an example to or something to see if I could figure out what I am doing wrong.

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed Jun 08, 2005 3:29 pm

I am afraid we do not at this time - will see if we can 'rustle' something up - but there may be a delay as we are fully committed at this time with the Version 3.5 update and the Viewer development.

May be better if you zip up your sample so far that does not work and I will try and have this 'corrected' or altered as necessary.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Wed Jun 08, 2005 4:21 pm

Ok, I have attached a simple test project where I am trying to output a string to the PDF file using a CDC TextOut.

Thanks
Attachments
test.zip
(313.9 KiB) Downloaded 264 times

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu Jun 09, 2005 10:45 am

Thanks- please see advised with comments
Attachments
test_ContDC.zip
ContDC
(67.52 KiB) Downloaded 192 times
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Thu Jun 09, 2005 2:36 pm

It was a zip file. Here it is again.
Attachments
test.zip
(965.76 KiB) Downloaded 180 times

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Thu Jun 09, 2005 2:37 pm

Sorry, I miss read you post, I saw the last line and didn't realize you had attached a file for me. Please ignore my last post.

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Thu Jun 09, 2005 2:41 pm

Thank you, for your help

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu Jun 09, 2005 3:56 pm

No Prob ;)

Actually it was my fault I said 'Advised' and meant Attached !
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Mon Jun 13, 2005 6:12 pm

With the changes you made, I now try to draw a line from the top left corner of the page to the bottom right corner of the page. Notice that the line doesn't go clear to the bottom of the page. The diag line stops about 2/3 down the page. Is there something else that I need to setup?

Also, I noticed that the line stops in a different place when I run this on a Windows 98 system vs a Windows xp system. The Windows 98 system seem to draw the line down the page a little bit further.

I have attached the sample project again.[/url]
Attachments
test.zip
(966.32 KiB) Downloaded 188 times

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Tue Jun 14, 2005 11:04 am

Please find attached your code - corrected and commented appropriately
Attachments
_test_ContDC2.zip
Code updated
(68.04 KiB) Downloaded 196 times
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Tue Jun 14, 2005 9:52 pm

Those changes print the diag. line from bottom left corner to the top right corner of the page on my XP system. I ran the little test app on my win 98 system and the diag line goes from top left corner to the bottom right corner. I haven't sen differences like this between windows 98 and xp before. I have attached the two pdf files. Is this a windows issue or yours?
Attachments
pdfs.zip
(4.9 KiB) Downloaded 195 times

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Wed Jun 15, 2005 11:02 am

Hi Ken,

yes you are right - we have reproduced and corrected here - found an uncoumented 'feature' in W9x that allows a different mapping mode.

This will be updated in build 3.4083 issed later today/tomorrow
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Wed Jun 15, 2005 4:28 pm

Sounds good, thank you.

I do have another difference between win 98 and XP that might be related, but I'm not sure. I'm not sure if I should start another thread or not.

1) We have an existing software product that produces PDF reports. The library we were using doesn’t support some of the languages we needed and they seem to have gone out of business; that is what has me evaluating your library. Our software uses GetDeviceCaps() with LOGPIXELSX and LOGPIXELSY. This gives the number of pixels per inch and we calculate the report layout using these values. Added your library in to use these values and I get a slight difference in how win 98 and win XP layout the page the win xp seem to be scaled slightly smaller that win 98. I have included sample reports from out application. You'll notice the extra white space around the XP report. If you need me too, I can try to make a test program to reproduce this. Unfortunately, I cannot send our whole application. It is quite large.

If I need to do everything using HIMETRIC then I will do some converting to get it all to work but if I do not have to that would make things much easier for me.

2) Another thing I noticed is the values returned by GetDeviceCaps() with HORZRES and VERTRES. The values returned match the resolution of my display not the resolution of the page. When printing to a printer via the print DC in MFC, the values returned are the page dimensions in pixels.

3) You'll also notice the text to the left of the graphs isn't being aligned correctly on win 98. I haven't been able to reproduce this in a test app so there may be something I am doing wrong but it aligns ok on win XP.

Thank you for looking into these things and let me know if I can do anything to help.
Attachments
pdfs.zip
(201.14 KiB) Downloaded 183 times

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Wed Jun 15, 2005 5:18 pm

Another thing I just noticed different between the XP PDF and the 98 PDF is the bitmaps that appear at the top of the page. They are very tiny in the Win 98 PDF. Any ideas why they would be different based on the OS?

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu Jun 16, 2005 7:49 am

Hi,

can I suggest you install build 83 and re-test - if the issue still exists, maybe a new, clean thread would be good reporting any remaining issues.

thanks
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

ken66
User
Posts: 50
Joined: Mon May 16, 2005 5:10 pm

Post by ken66 » Thu Jun 16, 2005 3:31 pm

The original problem of the diag. line drawn differently between win98 and winXP is fixed. However, the issues I added yesterday using the Pixels per inch to layout the pages still exist. I prefer to get this method working if we can; it matches how we do printouts directly to the printer and make the implementation of the library much easier.

In addition, in experimenting with using the HIMETRIC setting as you suggested. I have added a TextOut test to my test app. I was able to get text to draw on XP but when I try this on 98 the text doesn't draw. I can attach the project if you would like. Here is the code to draw the line and text.

dc.SetMapMode(MM_HIMETRIC);
dc.SetWindowOrg(0, rc.bottom);

CFont fnt;
fnt.CreatePointFont(120, "Arial", NULL);
CFont* oldfnt = dc.SelectObject(&fnt);
CString text = "testing";
dc.SetMapMode(MM_TEXT);
dc.SetTextAlign(TA_LEFT);

// draw text to upper left corner
dc.TextOut(0, rc.bottom, text);

// draw text about an inch lower
dc.TextOut(0, rc.bottom + 100, text);

CPen pen;
pen.CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
dc.SelectObject(&pen);
dc.SetMapMode(MM_HIMETRIC);

// draw line from bottom left corner to top right corner

dc.MoveTo(0, 0);
dc.LineTo(rc.right, rc.bottom);

if (oldfnt)
dc.SelectObject(oldfnt);
dc.Detach();

Let me know if you would like me to supply a test app that demonstrates the problems I am seeing between XP and 98. The only one I haven't been able to reproduce in a test app is the strange text alignment issues I get intermittently on 98.

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Post by John - Tracker Supp » Thu Jun 16, 2005 4:13 pm

Hi Ken,

please do supply a small test app and also please start a new thread/topic with any required resources or examples - or things could get a little confusing.

thanks. :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

sjrogers
User
Posts: 11
Joined: Tue Mar 03, 2015 8:38 pm

Re: PXC_GetContentDC()

Post by sjrogers » Tue Mar 03, 2015 9:43 pm

I am having issues getting PXC_GetContentDC to work. I have read this thread and would like to look at the sample apps that are attached, but none of the file links work or are to the wrong file. Are there any examples of using PXC_GetContentDC available?


I am trying to use the PDF SDK in my application to create .pdf files by rendering directly to the device context created by PXC_GetContentDC. I am having problems getting this to work. I think my problem is that I don't understand how to correctly use the Draw Rect, Page Rect, and Page size. I have written a simple test app to try to understand how it works, but I still haven't figured it out. My output that I render with GDI does appear in the created .PDF FIle, but it is zoomed very close in and the coordinate system I expect it to be using doesn't seem to be the case. My sample code is below. Can anyone help me understand how these rect parameters should be specified in relation to the page or what else I could be doing wrong? I would expect the graphics I drew to be complete and very small, but instead is very very large.


_PXCDocument* pdf = NULL;
if (IS_DS_FAILED(PXC_NewDocument(&pdf, "<YOUR REG KEY>", "<YOUR DEV CODE>"))) return;
PXC_SetDocumentInfoA(pdf, InfoField_Author, "GTPlot");
PXC_SetDocumentInfoA(pdf, InfoField_Title, "Test Plot");
PXC_SetDocumentInfoA(pdf, InfoField_Creator, "GTPlot");
PXC_SetDocumentInfoA(pdf, InfoField_Keywords, "GTPlot");
PXC_EnableLinkAnalyzer(pdf, TRUE);
PXC_SetCompression(pdf, FALSE, FALSE, ComprType_C_Auto, 75, ComprType_I_Auto, ComprType_M_Auto);
PXC_SetEmbeddingOptions(pdf, TRUE, TRUE, TRUE);
HRESULT res = S_OK;

_PXCPage* page = NULL;
double pageWidth = I2L(8.5);
double pageHeight = I2L(11);
res = PXC_AddPage(pdf, pageWidth, pageHeight, &page);
if (IS_DS_FAILED(res))
{
// error adding page
return;
}
_PXCContent* pContent = (_PXCContent*)page;
// Drawing rectangle
RECT drawRect;
drawRect.left = 0;
drawRect.top = 0;
drawRect.right = pageWidth;
drawRect.bottom = pageHeight;

// Document rectangle
PXC_RectF pageRect;
pageRect.left =0;
pageRect.right = pageWidth;
pageRect.top = 0;
pageRect.bottom = pageHeight;

// hdc for drawing
HDC hdc;
HRESULT hr = PXC_GetContentDC(pContent, NULL, &drawRect, &pageRect, &hdc);
if (IS_DS_FAILED(hr))
{
// Handle error
return;
}

// Now hdc could be used for GDI operations
CDC *cdc = CDC::FromHandle(hdc);
CPen red(0,1,RGB(255,0,0));
cdc->SelectObject(&red);
cdc->MoveTo(10,10);
cdc->LineTo(90,90);
cdc->MoveTo(10,90);
cdc->LineTo(90,10);
cdc->MoveTo(10,10);
cdc->LineTo(10,90);
cdc->LineTo(90,90);
cdc->LineTo(90,10);
cdc->LineTo(10,10);

// After all drawings are done hdc must be released
PXC_ReleaseContentDC(pContent, FALSE);
char fname[MAX_PATH]= "m:\\temp\\test.pdf";
DWORD fl = 0;//WEF_ShowSaveDialog;
res = PXC_WriteDocumentExA(pdf, fname, sizeof(fname), fl, NULL);
PXC_ReleaseDocument(pdf);

if (IS_DS_ERROR(res))
{
// error - to do
}
Attachments
test.pdf
.pdf file that is created
(7.9 KiB) Downloaded 101 times

John - Tracker Supp
Site Admin
Posts: 8201
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Re: PXC_GetContentDC()

Post by John - Tracker Supp » Thu Mar 12, 2015 6:24 am

If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

Post Reply