PDF XChange and Delphi

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
kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

PDF XChange and Delphi

Post by kenbla » Wed Jun 21, 2006 1:33 pm

Has anyone used the combination of Delphi and PDF XChange? I would love to see some programming examples!
:lol:

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

Post by John - Tracker Supp » Wed Jun 21, 2006 1:47 pm

Hi,

There is an example in the SDK - albeit simple using the PDF-XChange drivers and there are plenty of Delphi developer's using PDF-XChange, what specifically were you hoping to see in the examples ?

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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Extract pages from a PDF document using Delphi

Post by kenbla » Mon Jul 31, 2006 7:45 am

Hello,
I would like to know how I programatically can extract certain pages from an existing pdf-file using PDF XChange. If I for example would like to extract page 7 and 8 from a pdf file that contains 50 pages. How do I do that??
My programming environment is Windows and Delphi 6.
Thanks!!

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

Post by John - Tracker Supp » Mon Jul 31, 2006 9:22 am

Hi,

I am afraid the Delphi application demonstrating this needs to be updated since a recent library change - due to developer holidays (sorry its that time of year) this cannot be done for another 2 weeks or so.

However - there is a suitable VB application demo which may well assist :

XCPro35Demo_VB.exe

HTH
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Extract pages from a PDF file

Post by kenbla » Mon Jul 31, 2006 10:31 am

Thanks for your response,
but where can I find the VB code that extracts pages from a PDF file (for the program XCPro35Demo_VB.exe)? I don't have Visual Studio installed!! Can you send a code example to me as a textfile?
Best regards,
Kenbla

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

Post by John - Tracker Supp » Mon Jul 31, 2006 11:10 am

Hi,

You can view all the VB source files without having VS installed - in Notepad or any suitable text editor.

Simply locate the folder 'VBExamples' and you will see all the VB projects available and source code files etc in a sub folder.

Hope that helps
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Mon Jul 31, 2006 1:09 pm

Hello again!
I have looked at the VB code in the folder you recommended but I can't locate where the "page extraction" takes place.
I would very much appreciate if you can explain in plain text how I extract for example pages 7-8 from a 50 page pdf document? Which PDFXChange functions do I have to use to facilitate this etc. etc.?
My current problem is to select/extract a few pages from a big pdf document and create a new pdf document with the selected/extracted pages.
Best regards,
Kenbla

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

Post by John - Tracker Supp » Tue Aug 01, 2006 10:13 am

Hi,

Here is some 'Pseudo' code of the required process.

++++++++++++
Here is sample (but a C++ notation) which should give you a basic outline of what is required - the VB should have been easier I believe for you - but as you appeared not to really be able to grasp that - I have provided this as it is notated better.
++++++++++++

PDFDocument source;
PDFDocument destination;

HRESULT result;

Initialise and open the source document

result = PXCp_Init(&source, NULL, NULL);
result = PXCp_ReadDocumentW(source, L"Source File Name.pdf", 0);


Assuming that the document has more than 8 pages - in reality you will need to check this using PXCp_GetPagesCount function

Create destination document

result = PXCp_Init(&destination, NULL, NULL);

Describe the ranges which we want to insert into the destination file- for example we will need to copy pages 3-5 and 7-8 so we need the array of the two PXCp_CopyPageRange structures

PXCp_CopyPageRange ranges[2];

The first element will describe the page range 3-5 (note that PDF page numbers are ALWAYS zero-based)

ranges[0].StartPage = 2;
ranges[0].EndPage = 4;

New Pages should be appended at the end of the process.

ranges[0].InsertBefore = -1;
ranges[0].Reserved = 0;

ranges[1].StartPage = 6;
ranges[1].EndPage = 7;
ranges[1].InsertBefore = -1;
ranges[1].Reserved = 0;

Note that pages 7-8 will be added after 3-5 because we insert all pages at the end.

Copy all the selected pages into the new document - note that we pass the pointer to the first element of the page ranges array and the elements count; function assumes that all elements follow previous with no padding of data

result = PXCp_InsertPagesTo(source, destination, &ranges[0], 2, 0);

In genera,l this function call can be replaced by two "simpler" calls with a pointer to only one page range structure (instead of an array in the example abouve)

result = PXCp_InsertPagesTo(source, destination, &ranges[0], 1, 0);
result = PXCp_InsertPagesTo(source, destination, &ranges[1], 1, 0);

The result of this subsequent calls will be a bit different: but the resulting file will look the same, but in the second case it may take up to two times more disk space this is because some pdf objects shared between pages (like fonts, common images, watermarks and so on) in the second case it will be copied twice (or more, if we will call PXCp_InsertPagesTo - more than twice - up to one copy of each shared object per one call)

It is therefore recomended to collect the info required from all subsequent calls to the PXCp_InsertPagesTo function and only then replace them with just one call with the page ranges array -

This will produce a smaller resulting file, this processes faster and uses less memory (of course if you need to copy pages from a different 2nd document you must call :

PXCp_InsertPagesTo function twice,

However it is recommended to copy all pages from one document first and then move onto to another)

Now we no longer need the source document, we can release it
result = PXCp_Delete(source);

Now write the destination file

result = PXCp_WriteDocumentW(destination, L"result file name.pdf", PXCp_CreationDisposition_Overwrite, PXCp_Write_NoRelease);

and release it

result = PXCp_Delete(destination);

The last two calls can be replaced by just one

result = PXCp_WriteDocumentW(destination, L"result file name.pdf", PXCp_CreationDisposition_Overwrite, PXCp_Write_Release)

Note that there is a possible problem here - causing the file to fail to write (for example because the disk is full) the document object will NOT be released and no memory will be freed !

so if you use this variant you must check the returned result code and correctly handle this situation (a call to PXCp_Delete function for a document already released is very dangerous and almost always will cause a GPF or similar.


Hope that helps.
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Tue Aug 01, 2006 1:15 pm

Thanks, this helps a lot!!
Best regards,
Kenbla

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

Post by John - Tracker Supp » Wed Aug 02, 2006 10:09 am

Pleased we got there - also will try and get the Delphi example revised and out ASAP

thanks for your patience.
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Thu Aug 03, 2006 8:48 am

Thank you very much.
A Delphi example will be greatly appreciated!
Best regards,
Kenbla

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

Post by John - Tracker Supp » Thu Aug 03, 2006 9:01 am

Pleasure - will advise when ready :)
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Thu Aug 03, 2006 12:40 pm

Do you know if there are any manuals which describes this type of functionality? I have looked at the help text manuals that I have access to but I can't find any information of this kind!
Best regards,
Kenbla
8)

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

Post by John - Tracker Supp » Thu Aug 03, 2006 2:52 pm

Sorry - not quite sure I understand ?

There are .CHM help files that come with the SDK when downloaded - could you be specific as to what else you require ?

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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Fri Aug 04, 2006 6:51 am

Hello again,
I have found the information I was looking for, it was part of the help system but I was looking in the wrong place!
Thanks again!
Best regards
Kenbla
:D

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

Post by John - Tracker Supp » Fri Aug 04, 2006 11:43 am

Hi,

It transpires that an xcpro35 demo did exist all along - in the install folder :

C:\Program Files\Tracker Software\PDF-XChange PRO 3 SDK\Examples\SDKExamples\DelphiExamples\PXCProSample

However it did not include an example of the functionality you requested (extract pages)

this has now been done and the next build will include this next week -however I attach this so you do not have to wait any longer

HTH
Attachments
DelphiPxcProSampleOnly.zip
Updated Delphi Example
(416.67 KiB) Downloaded 189 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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Tue Aug 08, 2006 6:46 am

Hello again,
I'm now getting ready to install PDF XChange to our Delphi development environment and that raises a couple of additional questions:
1. Shold I install PDF XChange as a package or as an Active X control? I would prefer a Delhi package if possible.
2. An application question: In the "extract pages" part of my application I get my "source PDF document" from a blob in an SQL Server database. Is it possible to use a blob in the function PXCp_CopyPageRange or do I have to create a PDF document first?
Best regards,
Kenbla
:)
Regards,
Kenbla

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

Post by John - Tracker Supp » Tue Aug 08, 2006 8:11 am

Hi,

As you will know - for the XCPRO35 functionality we do not provide an ActiveX ourselves - so simply installing the required dll's in the same folder as your application on the users system is all that you need do from our prespective.

With regards the blob issue - sorry for now you must create the PDF first.

HTH
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Tue Aug 08, 2006 12:55 pm

Hello again,
Sorry to disturb you with so many questions!
Anyway, I forgot to mention that we run Delphi 6 and not a .net version, and I don't think that it works by simply copying the DLL files (I have tried but couldn't make it work). Do you have another solution to the problem?
Best regards,
Kenbla
Regards,
Kenbla

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

Post by John - Tracker Supp » Tue Aug 08, 2006 1:20 pm

Hi,

The example recently given is not .NET and shoudl work without problems provided the dll's are located with your application .exe/dll's etc did you try this ?
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Tue Aug 08, 2006 1:40 pm

Yes, I have copied approximately 15 dll's to the same folder as my .exe file! and then tried to use any of your functions but my program does not compile!!
Best regards,
Kenbla
Regards,
Kenbla

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

Post by John - Tracker Supp » Tue Aug 08, 2006 2:11 pm

Can you please try and compile the demo application supplied on this thread several messages ago and advise if you are successful/

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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Wed Aug 09, 2006 6:06 am

Hi,
I can now compile my application!! It was the .dcu files that were missing. I copied them into my folder and then it worked!
Thanks again for your assistance!
:)
Regards,
Kenbla

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

Post by John - Tracker Supp » Wed Aug 09, 2006 9:52 am

Excellent - pleased all is well :)
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Wed Aug 16, 2006 12:54 pm

Hi,
My Delphi code which now involves PDF XChange funtionality works very well!!
We have purchased your product BUT I still get the your "star-icons" at the top left and right on my created pdf documents! How do I get rid of those icons?
I have a serial number and a Devcode but I don't know where to enter them! Please advice!
Best regards,
Kenbla
Regards,
Kenbla

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

Post by John - Tracker Supp » Wed Aug 16, 2006 7:03 pm

Hi,

Please see the XCPRO35.chm help file - specifically the topic :

High Level API functions - > Document operations - PXCp_Init

Please come back if you are still having problems.
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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Thu Aug 17, 2006 6:38 am

Hi again,
I have added the code according to the help file BUT it still doesn't work!
Below is part of my Delphi code:
pxDevcode : LPCSTR;
pxDevcode := 'PDFX3$Our developer code#';
pxRC := PXCp_Init(@hNewPDFDocument, nil, pxDevcode);

Best regards,
Kenbla
Regards,
Kenbla

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Post by kenbla » Thu Aug 17, 2006 6:45 am

Hi,
I got it to work now!! I added the Developer code but I forgot to add the license key!! But now everything works just fine.
Thanks for your excellent assistance!
Best regards,
Kenbla
Regards,
Kenbla

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

Post by John - Tracker Supp » Thu Aug 17, 2006 6:46 am

Hi,

You may want to try and use the example aplication and simply copy/paste the serial number and devcode as appropriate into that to check you have all working correctly - i.e. :

In the PxcProSample in the Delphi project file Common.pas in function

DoFileOpen at lines 150-152 you will find the following code :

sKey := '<Enter here valid key>';
sDevCode := '<Enter here a valid developer''s code>';
Result := PXCp_Init(@hDoc, PChar(sKey), PChar(sDevCode));


HTH
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

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

Post by John - Tracker Supp » Thu Aug 17, 2006 6:47 am

Excellent !

Pleased all is now well :)
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