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


All forums · Statistics · Search ·

Two Pilots forum / For software developers / 3.6 does not work
Author Message
mindgen
Member
# Posted: 12 Jul 2007 01:26


What's happend with PDF LIb Creator Pilot 3.6?!!!!!!!!!!!!!!!!!!

mindgen
Member
# Posted: 12 Jul 2007 04:18


if you can use HDC then all text does not print in PDF. :(

mvf
Member
# Posted: 12 Jul 2007 05:19


Can you show us you code sample, please?

mindgen
Member
# Posted: 12 Jul 2007 05:31


Standard sample:
..PDF Creator SamplesExamplesVisualCHelloPDF (using HDC)

mvf
Member
# Posted: 12 Jul 2007 05:53


And what happens when this test run? Some error occurred, resulting
PDF document is incorrect or else?

mindgen
Member
# Posted: 12 Jul 2007 06:29


Resulting PDF document is incorrect.(Empty)

mvf
Member
# Posted: 12 Jul 2007 08:13


What version of the PDFCreator? If it is not 3.6.360.0 then download please the latest version from our site.

mindgen
Member
# Posted: 12 Jul 2007 22:54


3.6.360.0 :(
if I used methods PDF Lib (Ex. PDFPAGE_TextOut) then resulting doc is correct, but if i used HDC then all text smal & scale is strange.

I have solutionon the MS Visual Studio 2005, if I used v.3.5 then resulting pdf correct, but if I used 3.6.360.0 then .... :(

mvf
Member
# Posted: 13 Jul 2007 05:34


Starting from version 3.06.360.0 you have to use coefficient based on relation of PDF page's dpi and virtual context's dpi to synchronize font sizes (and line widths as well).

Look this example:

// initialize PDF Engine
PDF->StartEngine("demo","demo");
PDF->FileName = "test.pdf";
PDF->AutoLaunch = true;

PDF->Resolution = 72;
PDF->BeginDoc();
PDF->put_UseScreenDC(VARIANT_TRUE);
HDC hDC = 0;

// hDC = PDF page's virtual context
PDF->get_HDC((long*)&hDC);

// font size in points
int fontSizeInPoints = 12;

// string to out in usual way
char* sText = "PDF text: Arial, 12pt; PDF coords: left=10, top=100";

// string to out using virtual context
char* sTextGdi = "GDI text: Arial, 12pt; PDF coords: left=10, top=120";

long lPDFResolution = PDF->Resolution;
long lDCResolution = PDF->GetUsedDCResolution();

//!!! here is scale factor !!!//
double dScale = (double)lPDFResolution / (double)lDCResolution;

// out string in usual way
int coordLeft = 10;
int coordTop = 100;
PDF->PDFPAGE_SetActiveFont("Arial", false, false, false, false, fontSizeInPoints, charsetANSI_CHARSET);
PDF->PDFPAGE_TextOut(coordLeft, coordTop, 0, sText);

// out string using virtual context
int fontSizeDC = -(int)(fontSizeInPoints * lDCResolution / 72.0f);
HFONT fnt = CreateFont(fontSizeDC, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0, 0, 0, "Arial");
HFONT oldFnt = (HFONT)SelectObject(hDC, fnt);
// calculate coorditates with scale factor
double dGDILeft = 10 * dScale; // analogue of PDF coord 10
double dGDITop = 120 * dScale; // analogue of PDF coord 120
ExtTextOut(hDC, (int)dGDILeft, (int)dGDITop, 0, 0, sTextGdi, strlen(sTextGdi), 0);
SelectObject(hDC, oldFnt);
PDF->EndDoc();

// disconnect from library
PDF->Release();

mindgen
Member
# Posted: 17 Jul 2007 02:12


if I need to use DPI = 600?
Not DCResolution.

mindgen
Member
# Posted: 17 Jul 2007 06:19


I have fucntion which draw anything on the Gdiplus::Graphics. How I can use PDFLibCreator 3.6?

I constructing Gdiplus::Graphics on the virtual context(PDF->HDC).
On the 3.5 working, but on the 3.6 is incorrect!

mvf
Member
# Posted: 17 Jul 2007 07:11


If you don't want to use virtual context then just don't use it and set desired resolution.
Remember, higher resolution means higher values for width and height - point with coordinates (100, 100) for dpi=300 is closer to upper left corner then the point with the same coordinates but for dpi=100.

Look this example:

// initialize PDF Engine
PDF->StartEngine("demo","demo");
PDF->FileName = "test.pdf";
PDF->AutoLaunch = true;

PDF->Resolution = 300;
PDF->BeginDoc();

// font size in points
int fontSizeInPoints = 12;

// string to out in usual way
char* sText1 = "PDF text: Arial, 12pt; PDF coords: left=500, top=800. Dpi = 300.";
char* sText2 = "PDF text: Arial, 12pt; PDF coords: left=500, top=800. Dpi = 600.";

// out string in usual way
int coordLeft = 500;
int coordTop = 800;
PDF->PDFPAGE_SetActiveFont("Arial", false, false, false, false, fontSizeInPoints, charsetANSI_CHARSET);
PDF->PDFPAGE_TextOut(coordLeft, coordTop, 0, sText1);

PDF->Resolution = 600;
PDF->NewPage();

PDF->PDFPAGE_SetActiveFont("Arial", false, false, false, false, fontSizeInPoints, charsetANSI_CHARSET);
PDF->PDFPAGE_TextOut(coordLeft, coordTop, 0, sText2);
PDF->EndDoc();

// disconnect from library
PDF->Release();

mindgen
Member
# Posted: 17 Jul 2007 22:40


IN {# Posted: 13 Jul 2007 05:34} use PDF>put_UseScreenDC(VARIANT_TRUE); (default:96)

How I can get correct PDF if I draw on the virtual context(without PDF>put_UseScreenDC(VARIANT_TRUE);)? I put HDC in the function which draw on the Gdiplus::Graphics and set scale on the grpahics.

mindgen
Member
# Posted: 18 Jul 2007 02:47


This code create correct PDF on 3.5. On 3.6 resulting PDF is incorrect.

Example:

PDF->ComStartEngine(_bstr_t("demo"), _bstr_t("demo"));
PDF->FileName = "test.pdf";
PDF->DocumentInfo_Title = "PDF Test And DC";
PDF->OnePass = true;
PDF->AutoLaunch = true;
PDF->Compression = TxCompressionType(1);
PDF->BeginDoc();

GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
{
long used_dc = PDF->HDC;
HDC dc = (HDC)used_dc;
Graphics Gr(dc);

double ScaleX = PdfPtPerInch / Gr.GetDpiX();
double ScaleY = PdfPtPerInch / Gr.GetDpiY();

double Height = PDF->PDFPAGE_Height;

PDF->PDFPAGE_Translate(0, Height * ScaleY);
PDF->PDFPAGE_Scale(ScaleX, ScaleY);

SolidBrush sBrush(Color(255,255,0,0));
Gdiplus::Font myFont(L"Arial", 12, 3);
SolidBrush blackBrush(Color(0, 0, 0));

PointF Point;
Pen penThin(&sBrush, 0.2f);
Pen penMedium(&sBrush, 0.4f);
Pen penThick(&sBrush, 0.9f);

penThin.SetDashStyle(DashStyleSolid);
penMedium.SetDashStyle(DashStyleSolid);
penThick.SetDashStyle(DashStyleSolid);
{
Point.X = 20;
Point.Y = 80;
Gr.DrawString(L"Width : 0.2", -1, &myFont, Point, &blackBrush);
Gr.DrawLine(&penThin, 20, 100, 100, 100);
}
{
Point.X = 20;
Point.Y = 130;
Gr.DrawString(L"Width : 0.4", -1, &myFont, Point, &blackBrush);
Gr.DrawLine(&penMedium, 20, 150, 100, 150);
}
{
Point.X = 20;
Point.Y = 180;
Gr.DrawString(L"Width : 0.9", -1, &myFont, Point, &blackBrush);
Gr.DrawLine(&penThick, 20, 200, 100, 200);
}

penThin.SetDashStyle(DashStyleDashDotDot);
penMedium.SetDashStyle(DashStyleDashDotDot);
penThick.SetDashStyle(DashStyleDashDotDot);
{
Point.X = 300;
Point.Y = 80;
Gr.DrawString(L"Width : 0.2", -1, &myFont, Point, &blackBrush);
Gr.DrawLine(&penThin, 300, 100, 380, 100);
}
{
Point.X = 300;
Point.Y = 130;
Gr.DrawString(L"Width : 0.4", -1, &myFont, Point, &blackBrush);
Gr.DrawLine(&penMedium, 300 ,150, 380, 150);
}
{
Point.X = 300;
Point.Y = 180;
Gr.DrawString(L"Width : 0.9", -1, &myFont, Point, &blackBrush);
Gr.DrawLine(&penThick, 300, 200, 380, 200);
}
}
PDF->EndDoc();
PDF->Release();
GdiplusShutdown(gdiplusToken);

Stanislav
Member
# Posted: 19 Jul 2007 00:25


Hello,

You don't need to use PDFPAGE_Translate and PDFPAGE_Scale.
Please try to use document Resolution property:

PDF->Resolution = 300; //for example

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

mindgen
Member
# Posted: 19 Jul 2007 04:58


Where is compatibility and old version support? :(

 

 

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

 

Page top