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


All forums · Statistics · Search ·

Two Pilots forum / For software developers / PDF Creator Pilot in C++Builder 2009?
Author Message
KarlMay
Member
# Posted: 13 Apr 2010 04:19


Hallo.

http://www.colorpilot.com/pdfcreatorpilotmanual/Ho w_to_create_a_new_PDF_document_4.html

I can not understand the example unfortunately, because it does not look so in C++Builder2009. Is there a C++Builder2009 example?

Another question which I imagine is registering the dll in the windows system. It is not enough to attach the dll to the project-folder?

I want use mixed texts out of database, like: TextOut("hello 排水量 welcome!")
Is it possible?

max.f
# Posted: 13 Apr 2010 07:50


Hello,
unfortunatelly we do not have C++ Builder 2009 wxamples.
But the steps to do are:
1) add a COM ("PDF Creator Pilot") to a project
2) create an instance of a "PDF Creator Pilot"
3) use it

"It is not enough to attach the dll to the project-folder?"
No it is not. You should call "regsvr32 PDFCreatorPilot.dll" on a target machine to register.

"I want use mixed texts..."
Just create the unicode string and call:
pdf->UnicodeTextOut(...);

--
Max Filimonov,
max.f@colorpilot.org

KarlMay
Member
# Posted: 13 Apr 2010 11:04


Thank you.
After a long search for add ActiveX(COM) i have founded it and create this:
(After add activeX dll i have PDFCreatorPilotLib_OCX.cpp and PDFCreatorPilotLib_TLB.cpp in my project)

[code]#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
#include "PDFCreatorPilotLib_TLB.h"
//------------------------------------------------ ---------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//------------------------------------------------ ---------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//------------------------------------------------ ---------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
PDFDocument4* PDF = NULL;
CLSID clsid;

HRESULT hr = CLSIDFromProgID(OLESTR("PDFCreatorPilot.PDFDocumen t4"), &clsid);
if(hr != S_OK)
{
// can't load. no such COM installed.
return;
}

hr = CoCreateInstance(clsid, 0, CLSCTX_ALL, __uuidof(IPDFDocument4), (LPVOID *)&PDF);
if(hr != S_OK)
{
// can't load. no such COM installed.
return;
}

PDF->SetLicenseData(L"demo@demo", L"demo");

PDF->SetTitle(L"PDF Creator Pilot Demo", fcDefault);
PDF->ProducePDFA = false;
PDF->Compression = coFlate;
}
//------------------------------------------------ ---------------------------[/code]

Now I get 2 Errors:
Undefined symbol 'fcDefault'
Undefined symbol 'coFlate'

What is missing?


Give it a tutorial to use the dll without admin password (regsvr32 access) on pc? We want start a small application to create report pdf on desktop pcs without admin access.

max.f
# Posted: 13 Apr 2010 11:21


> Now I get 2 Errors:
> Undefined symbol 'fcDefault'
> Undefined symbol 'coFlate'

You need to specify where those constants are defined.
Write
using namespace PDFCreatorPilotLib;

> Give it a tutorial to use the dll without admin password (regsvr32 access) on pc?
> We want start a small application to create report pdf on desktop pcs without
> admin access.

You can't. This is a COM library and it must be installed on a target computer. So you have to call "regsvr32 PDFCreatorPilot.dll" for it.

--
Max FIlimonov,
max.f@colorpilot.org

KarlMay
Member
# Posted: 13 Apr 2010 11:39 · Edited by: KarlMay


Write
using namespace PDFCreatorPilotLib;

Thats here not working. In PDFCreatorPilotLib_TLB:h is defined:

-------------------------------------------------- --------------------
namespace Pdfcreatorpilotlib_tlb
{
........
virtual HRESULT STDMETHODCALLTYPE SetTitle(BSTR author/*[in]*/,
Pdfcreatorpilotlib_tlb::fontCharset charset/*[in]*/) = 0; // [91]
.......
};

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace Pdfcreatorpilotlib_tlb;
#endif
-------------------------------------------------- -------------------

In Unit.cpp add additional
using namespace Pdfcreatorpilotlib_tlb;
its not working here, the two errors already exists. :(

max.f
# Posted: 13 Apr 2010 12:02


See the answer above.

--
Max Filimonov,
max.f@colorpilot.org

KarlMay
Member
# Posted: 13 Apr 2010 12:35 · Edited by: KarlMay


I have look in PDFCreatorPilotLib_TLB.h and change it and works now:
-------------------------------------------------- --------------
PDF->SetTitle(L"PDF Creator Pilot Demo", __MIDL_IPDFDocument4_0005::fcDefault);
PDF->ProducePDFA = false;
PDF->Compression = __MIDL_IPDFDocument4_0001::coFlate;

PDF->ShowTextAt(10, 40, L"Simple test");
PDF->ShowText(L"Other text.");
-------------------------------------------------- --------------

after i want test a ellipse and a rectangle
http://www.colorpilot.com/pdfcreatorpilotmanual/Ho w_to_draw_simple_elements__such_as_a_line__circle_ _or_arc__with_different_attributes_4.html
-------------------------------------------------- --------------
PDF->SetColorStroke(0,0,0,0); // black color
PDF->SetLineWidth(2);
PDF->DrawEllipse(60, 70, 140, 130);
PDF->DrawRectangle(10, 10, 40, 20,45);
-------------------------------------------------- --------------
but nothing happen. what is missing?

now i want test unicodetext your example dont exists.
I look again in PDFCreatorPilotLib_TLB.h and found:
-------------------------------------------------- --------------
// [230] Draws an Unicode text using the current font starting at location (X, Y) and Orientation (in degrees).
virtual HRESULT STDMETHODCALLTYPE PDFPAGE_UnicodeTextOut(double x/*[in]*/, double y/*[in]*/, double orientation/*[in]*/, BSTR unicodeText/*[in]*/) = 0;
-------------------------------------------------- --------------
This is in interface IPDFDocument3 and not IPDFDocument4 :confused:
IPDFDocument4 have no unicode textout.

Thanks for your help. :)

max.f
# Posted: 13 Apr 2010 12:50


> PDF->DrawEllipse(60, 70, 140, 130);
> PDF->DrawRectangle(10, 10, 40, 20,45);
> but nothing happen. what is missing?

You've constructed a graphics path, but it will not be drawn untill you call
PDF->Stroke();
or
PDF->Fill();
or
PDF->FillAndStroke();

(the example you mention does have this call)

> This is in interface IPDFDocument3 and not IPDFDocument4 :confused:

Yes, the library has 2 interfaces, we recommend to use IPDFDocument4. IPDFDocument3 is used for backward compatibility for old versions.

> IPDFDocument4 have no unicode textout.

Of course it has :)
For example - the ShowUnicodeTextAt method.

You may find more information of methods, properties and samples here:
http://www.colorpilot.com/pdfcreatorpilotmanual/IP DFDocument4.html

--
Max Filimonov,
max.f@colorpilot.org

KarlMay
Member
# Posted: 13 Apr 2010 13:03 · Edited by: KarlMay


Thanks for your fast big help! ;)

Ellipse and Rectangle working now fine and ShowUnicodeTextAt is available too.
This line working fine:
PDF->ShowUnicodeTextAt(200,200,L"Text ???"); // "???" are german "umlauts", the forum display this not correctly
But with chinese characters its draw nothing.
PDF->ShowUnicodeTextAt(200,200,L"Text 排水量 ???");

I have add before:
fnt = PDF->AddFont(L"Verdana", false, true, false, false, __MIDL_IPDFDocument4_0005::fcChineseBIG5);
PDF->UseFont(fnt, 14);
This not helping.

max.f
# Posted: 13 Apr 2010 13:15


> But with chinese characters its draw nothing.

Well, not every font contain glyphs for Chinede (or Japanese, Arabic, etc.) language.
There two ways to do that.
1) Use a ASCII text with a font added in a proper codepage

fnt = PDF->AddFont(L"Verdana", false, true, false, false, fcChineseBIG5);
PDF->UseFont(fnt, 14);
PDF->ShowTextAt(200,200, "here_is_chenese_text");

2) Add a font that contain needed glyphs and use unicode string

fnt = PDF->AddFont(L"Arial Unicode MS", false, true, false, false, fcDefault);
PDF->UseFont(fnt, 14);
PDF->ShowUnicodeTextAt(200,200, "here_is_unicode_chenese_text");

--
Max Filimonov,
max.f@colorpilot.org

 

 

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

 

Page top