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


All forums · Statistics · Search ·

Two Pilots forum / For software developers / Watermark and text align?
Author Message
Anonymous
# Posted: 29 Mar 2005 11:30


Hi Stanislav ,

I evaluate PDF Creator. I want to use watermark, so how can I create PDF files with watermark and set text align in right.

ps.Could you tell me if it possiple to know each function or method meaning and use it correctly.Please give me some suggestion (My company alreary ordered your product and my boss told me that you didn't give us the document of product).

thanks
Jan

Stanislav
# Posted: 29 Mar 2005 12:28


Hi Jan,

If you don't have documentation, you can get it by downloading demo version of the PDF Creator Pilot (http://www.colorpilot.com/load/pdflib.exe). But i don't understand why your boss told you that - documentation comes with library in same distributive. Also, you can find samples of how to use library in C:\Program Files\PDF Creator Pilot 2\Examples (if library is installed in C:\Program Files\PDF Creator Pilot 2). So, please look in this folder for examples and documentation.

About your question - to use watermarks, you can look at the following sample:

Set PDF = CreateObject("PDFCreatorPilot2.piPDFDocument")

PDF.StartEngine "demo@demo","demo"

PDF.DocumentInfo_CreationDate = Now
PDF.Filename = "Data\PDFFiles\waterMark.pdf"
PDF.DocumentInfo_Title = "PDF Creator Pilot Demo (WaterMark)"
PDF.OnePass = true
PDF.AutoLaunch = true
PDF.COmpression = 1 ' 1 = ctFlate

PDF.BeginDoc

J = PDF.CreateWatermark

PDF.SwitchedToWaterMark = true ' now we work with watermark as with

current page and use PDFPAGE_ commands

PDF.PDFPAGE_Width = 376
PDF.PDFPAGE_Height = 373
PDF.PDFPAGE_PlayMetaFileFromFileName "Data\Images\logo.emf"

PDF.SwitchedToWaterMark = false


PDF.PDFPAGE_Width = 376
PDF.PDFPAGE_Height = 373
PDF.PDFPAGE_WaterMark = J
PDF.PDFPAGE_TextOut (PDF.PDFPAGE_Width -
PDF.PDFPAGE_GetTextWidth("Watermark usage example.")) / 2, 100, 0, "Watermark
usage example."

PDF.EndDoc

First of all, you should create watermark - J = CreateWatermark , and use returned value (J in this example) as watermark ID. Then, use PDF.SwitchedToWaterMark = true to switch to the watermark layer, output some text or draw some graphics like in the provided example,then switch back to the PDF main layer by PDF.SwitchedToWaterMark = false. Then, if you want to assign watermark ID for some PDF page, set watermark ID PDF.PDFPAGE_WaterMark = J

About text align - you can use PDFPAGE_TextBox method to set text align property for text output. For example, add following lines to the sample
PDF.PDFPAGE_TextBox 150, 100, 50, 50, "Test String", 0, 1
PDF.PDFPAGE_TextBox 150, 150, 50, 50, "Test String", 1, 1
PDF.PDFPAGE_TextBox 150, 200, 50, 50, "Test String", 2, 1
And you will see text align is different for each line.
Complete description of this method you can find in documentation.

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 31 Mar 2005 13:00


Hi Stanislav,
I try to use PDFPAGE_PlayMetaFileFromFileName method on this command
"PDF->PDFPAGE_PlayMetaFileFromFileName("c:\\inetpub\\wwwroot\\krungsri \\pic\\main\\bayLogo.jpg");" in Visual C++ and can complie it to DLL without error. But after that I use this DLL in another program and it have an error on that command.

Can you help me? What I am wrong?

Thanks
Jan.

Stanislav
# Posted: 31 Mar 2005 13:21


Dear Jan,

To add image file to PDF document, you should use AddImageFromFileName method,
then, to show it on the page, PDFPAGE_ShowImage method

J = PDF.AddImageFromFileName("Data\Images\logo.bmp",0) ' 0=itcFlate -
****see all possible compressions at bottom of the topic
Here J is an index of the image

PDF.PDFPAGE_Width = 310
PDF.PDFPAGE_Height = 310

PDF.PDFPAGE_ShowImage J,5,5,224,183,0

Possible image compressions is:

itcFlate - store image with "Flate" algorithm
itcJpeg - store image with JPEG algorithm
itcCCITT3 - store b/w images with CCITT3 algorithm
itcCCITT32d - store b/w images with CCITT3(2D) algorithm
itcCCITT4 - store b/w images with CCITT4 algorithm

They defined as

itcFlate = $00000000;
itcJpeg = $00000001;
itcCCITT3 = $00000002;
itcCCITT32d = $00000003;
itcCCITT4 = $00000004;

Here is description of PDFPAGE_ShowImage from documentation:

PDFPAGE_ShowImage(ImageIndex as long,X as double,Y as double,W as double,H as double,Angle as double)
Description
This procedure place the image data of size (w, h) with one corner at (x,y), and angle, specified in degrees (ImageIndex is returned by the AddImageFromFilename function) into the current content stream for the page.

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 1 Apr 2005 07:20


Hi Stanislav,

Can I use "J = PDF.AddImageFromFileName" and "PDFPAGE_ShowImage" to create PDF file that has watermark? I used "PDF.PDFPAGE_PlayMetaFileFromFileName "full path filename" " like above example you suggest to me...but it wasn't work have an error on that line. What is the command that use to create watermark from file(picture)?

Thanks
Jan.

Anonymous
# Posted: 1 Apr 2005 07:28


Hi Stanislav,

Watermark for me,means you cannot see it but when you print or copy it you can see it.
Am I misunderstand of watermark cause I used "J = PDF.AddImageFromFileName" and "PDFPAGE_ShowImage" I an see it?
Here is a code:

long img_index;
img_index = PDF->AddImageFromFilename("c:\\inetpub\\wwwroot\\krungsri\\pic\\main\\ bayLogo.jpg",itcJpeg );

long j;
j = PDF->CreateWaterMark();
printf("set j = watermark\n");
PDF->SwitchedToWatermark = true;
printf("SwitchedToWatermark to true\n");

//PDF->PDFPAGE_PlayMetaFileFromFileName("c:\\inetpub\\wwwroot\\krungsr i\\pic\\main\\bayLogo.jpg");
PDF->PDFPAGE_ShowImage(img_index,20,510,200,36,0);


printf("set filename\n");
PDF->SwitchedToWatermark = false;
printf("SwitchedToWatermark to false\n");
PDF->PDFPAGE_Watermark = j;
printf("set watermark = j\n");

Thanks
Jan.

Stanislav
# Posted: 1 Apr 2005 14:33


Dear Jan,

Yes, you'll see watermark in all modes - not just in printed copy.
You can use watemark as another layer in PDF document.

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 5 Apr 2005 05:59


Hi Stanislav,

I have question:

1. Should I use PDFPAGE_ShowImage instead of PDFPAGE_PlayMetaFileFromFileName (that you used to suggest to me) to create watermark?
2. I can choose any position to put on the watermark in PDFPAGE_ShowImage ,right?

Here is my code:

long img_index;
img_index = PDF->AddImageFromFilename("c:\\inetpub\\wwwroot\\krungsri\\pic\\main\\ bayLogo.jpg",itcJpeg );

long j;
j = PDF->CreateWaterMark();
PDF->SwitchedToWatermark = true;

PDF->PDFPAGE_ShowImage(img_index,20,510,200,36,0);


PDF->SwitchedToWatermark = false;
PDF->PDFPAGE_Watermark = j;

On above code,Is it method to create watermark that I understand fro you?

Thanks.
Jan.

Stanislav
# Posted: 5 Apr 2005 22:55


Dear Jan,

Yes, i think your code is right.

You can use any method to create watermark - PDFPAGE_ShowImage or PDFPAGE_PlayMetaFileFromFileName, and you can specify any position for the image, you are right.

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 7 Apr 2005 07:13


Hi Stanislav,

What is difference between PDFPAGE_ShowImage and PAGE_PlayMetaFileFromFileName?

Thanks.
Jan.

Anonymous
# Posted: 7 Apr 2005 07:14


Hi Stanislav,

What is difference between PDFPAGE_ShowImage and PAGE_PlayMetaFileFromFileName?Because I had an error when I used PAGE_PlayMetaFileFromFileName method.

Thanks.
Jan.

Stanislav
# Posted: 7 Apr 2005 08:35


Dear Jan,

PAGE_PlayMetaFileFromFileName is used to render emf metafiles to PDF. PDFPAGE_ShowImage is used with jpeg, bmp files - raster images. So, main difference in supported file formats - you should use PAGE_PlayMetaFileFromFileName only for emf files.

Thank you very much !

Best regards,
Stanislav

 

 

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

 

Page top