Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support


All forums · Statistics · Search ·

Two Pilots forum / For software developers / Problem creating PDF larger then screen size
Author Message
Anonymous
# Posted: 29 Nov 2005 20:17


Hi everyone,

I'm having a bit of a problem using the PDF Creator Pilot library. I can create PDF's no problem as long as their size is smaller then the screen size, as soon as I go above the screen size it seems as though nothing is getting drawn in the areas that are larger then the screen?

So if the height if what I want to draw is 10 pixels larger then the screen, the resulting 10 pixels on the PDF are always drawn white. Has anyone else encountered this issue before?

In an effort to work around this problem I tried using the PutUseScreenDC(FALSE) function. This worked, however the resulting image drawn to the PDF was tiny in realation to the size of the actual PDF. So how do I use this funciton call? Do I have to set a scaling mode for the PDF CDC or for the PDF itself?

Anonymous
# Posted: 29 Nov 2005 20:18


Whoops I forgot to mention that I was doing this in VC++.

Thanks for all of your help in advance.

Stanislav
# Posted: 29 Nov 2005 20:26


Hello,

Please send us yourcode in zip archive using our support form.

Thank you very much !

Best regards,
Stanislav
Two Pilots

Anonymous
# Posted: 29 Nov 2005 20:35


Hi Stanislav,

Which code do you want to see? Did you want to see the PDF initialization code? Or our actual drawing code?

What about passing on some information regarding the usage of PutUseScreenDC(FALSE)? How can I scale the output so that it is not so small all the time?

Stanislav
# Posted: 29 Nov 2005 20:49


Hello,

I think you should scale output by getting used DC resolution (GetUsedDCResolution ).
If you draw directly on DC, you can calculate scale factor using value returned by GetUsedDCResolution function and use PDFPAGE_Scale to setup new scale factor.

Thank you very much !

Best regards,
Stanislav
Two Pilots

Anonymous
# Posted: 29 Nov 2005 21:26


Hi Stanislav,

Thanks for quick responses!

Yes we are drawing directly to the DC, but I'm having some trouble figuring out what I should pass to PDFPAGE_Scale function?

GetUsedDCResolution() is returning 600, but what do I do with that in order to caculate the scale?

Stanislav
# Posted: 29 Nov 2005 21:32


Hello,

You should calculate scale as a result of division 72 and 600.
72 is default resolution for all PDF documents, so i think your scale factor should be about 0.12 for both axes.

Thank you very much !

Best regards,
Stanislav
Two Pilots

Anonymous
# Posted: 29 Nov 2005 22:26


Hmm Stanislav, it still doesn't seem to be working. No matter what I put as the Scale values, the image the we draw to the DC is still very small in the upper left corner.

This is basically the code the we are using (with all error checking taken out):
//************************************
PDF->put_Resolution(nScreenXDpi);
VARIANT_BOOL vbScreen = 0;
PDF->PutUseScreenDC(vbScreen);

PDF->BeginDoc();

PDF->NewPage();
PDF->PDFPAGE_Scale(0.12,0.12);
PDF->PutPDFPAGE_Width((long)m_iWidth));
PDF->PutPDFPAGE_Height((long)m_iHeight));

DrawToDC(CDC::FromHandle((HDC)PDF>HDC));

PDF->EndDoc();
PDF->Release();
//************************************

DrawToDC basically just draws things to the DC.

Anonymous
# Posted: 30 Nov 2005 00:48


Hmm I still can't get this to work, maybe I'm missunderstanding what PutUseScreenDC() actually does. Would it be possible for you to exaplain to me what PutUseScreenDC() does and how one would use it?

Stanislav
# Posted: 30 Nov 2005 16:47


/*
PDFPAGE_Scale does not influence upon DC drawing operators
Read comment on line 45 to get solution
*/

#include "stdafx.h"

#import "PDFCreatorPilot2.dll"
using namespace PDFCreatorPilot2;

#pragma warning (disable: 4312) // conversion from 'unsigned long' to 'HDC' of greater size

void CreateUsualPDF(IpiPDFDocument2* PDF)
{
PDF->FileName = "Usual.pdf";
PDF->AutoLaunch = true;
PDF->BeginDoc();
HDC DC = (HDC)(PDF->HDC);
RECT frame = { 100, 100, 200, 200 };
HPEN gray = CreatePen(PS_DOT, 1, RGB (128, 128, 128));
LOGBRUSH logBrush;
logBrush.lbStyle = BS_HATCHED;
logBrush.lbColor = RGB(0, 192, 192);
logBrush.lbHatch = HS_CROSS;
HBRUSH silver = CreateBrushIndirect(&logBrush);
HBRUSH hBrushOld = (HBRUSH)SelectObject(DC,silver);
HPEN hPenOld = (HPEN)SelectObject(DC,gray);
Rectangle (DC, frame.left, frame.top, frame.right, frame.bottom);
SelectObject(DC,hBrushOld);
SelectObject(DC,hPenOld);
DeleteObject(gray);
DeleteObject(silver);
PDF->EndDoc();
}

void CreatePDFWithoutUsingScreenDC(IpiPDFDocument2* PDF)
{
PDF->FileName = "NotUsingScreenDC.pdf";
PDF->AutoLaunch = true;
PDF->UseScreenDC = false;
PDF->Resolution = 600;
PDF->BeginDoc();

/*
Library renderer take into account default resolution for display driver,
not PDF. So, in scaling operations you should use value 96, not 72
*/

const double dDefaultResolution = 96;
double dCurrentResolution = PDF->GetUsedDCResolution();
double dScaleFactor = dCurrentResolution/dDefaultResolution;
HDC DC = (HDC)(PDF->HDC);
XFORM xForm;
xForm.eM11 = (FLOAT)dScaleFactor;
xForm.eM12 = (FLOAT) 0.0;
xForm.eM21 = (FLOAT) 0.0;
xForm.eM22 = (FLOAT)dScaleFactor;
xForm.eDx = (FLOAT) 0.0;
xForm.eDy = (FLOAT) 0.0;
SetWorldTransform(DC, &xForm);
RECT frame = { 100, 100, 200, 200 };
HPEN gray = CreatePen(PS_DOT, 1, RGB (128, 128, 128));
LOGBRUSH logBrush;
logBrush.lbStyle = BS_HATCHED;
logBrush.lbColor = RGB(0, 192, 192);
logBrush.lbHatch = HS_CROSS;
HBRUSH silver = CreateBrushIndirect(&logBrush);
HBRUSH hBrushOld = (HBRUSH)SelectObject(DC,silver);
HPEN hPenOld = (HPEN)SelectObject(DC,gray);
Rectangle (DC, frame.left, frame.top, frame.right, frame.bottom);
SelectObject(DC,hBrushOld);
SelectObject(DC,hPenOld);
DeleteObject(gray);
DeleteObject(silver);
PDF->EndDoc();
}

int _tmain(int argc, _TCHAR* argv[])
{

CoInitialize(NULL);

IpiPDFDocument2* PDF = NULL;
CLSID clsidpdf;
HRESULT hr;
hr = CLSIDFromProgID(OLESTR("PDFCreatorPilot2.piPDFDocument"), &clsidpdf);
if (FAILED(hr))
return 0;
hr = CoCreateInstance(clsidpdf, NULL, CLSCTX_ALL,__uuidof(IpiPDFDocument2), (LPVOID*)&PDF);
if (FAILED(hr) || (PDF == NULL ))
return 0;
PDF->StartEngine("demo@demo","demo");
CreateUsualPDF(PDF);
CreatePDFWithoutUsingScreenDC(PDF);
PDF->Release();
CoUninitialize();
return 0;
}


Thank you very much !

Best regards,
Stanislav
Two Pilots

Anonymous
# Posted: 2 Dec 2005 00:26


Thanks a lot Stanislav, with your help we have been able to get it to work!

Anonymous
# Posted: 26 Oct 2006 15:47


Hi Stanislav,

Could you please tell me how could we do that (previous code) in C# and also where is HDC object located (GC assembly maybe)?

Thanks in advance,
Ramiro

Stanislav
Member
# Posted: 27 Oct 2006 15:29


Dear Ramiro,

Yes, i'll post link to the example soon.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Anonymous
# Posted: 6 Nov 2006 11:45


Hi Stanislav,

Did you have time to look for the C# code sample you would post?
Thanks,
Ramiro

Stanislav
Member
# Posted: 6 Nov 2006 13:10


Dear Ramiro,

Yes, it'll be available soon.

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

 

 

Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.014

 

Page top