A PLUGIN to copy an object from a pdf file into another pdf file

A PLUGIN to copy an object from a pdf file into another pdf file

Post by Gandal » Fri, 16 Nov 2001 01:30:37



THIS IS A CORRIGENDUM OF THE PREVIOUS POST

-----------------------------------------

I'm writing a plugin copying into an open pdf files (doc1) all the objects
(images, etc.) from another pdf files (doc2).
So far, this is the main procedure (no error checkings to have a more
readable code):

/////////////////////////////////////////////////////////////////////////
//
 char* IMG_PATH = "c:\\Logo1.pdf"; // Logo1.pdf is the doc2 containing the
objects (an image for example)

 ASInt32 numElem; // Number of PDEElents objects into doc2

 //The file into which objects must be copied
 AVDoc avDoc1;
 PDDoc pdDoc1;
 PDPage pdPage1;
 AVPageView avPageView1;
 PDEContent pdeContent1;
 PDEElement pdeElem1[200]; // Just to simplify for the moment I use a fixed
length array of objects

 //The file from which objects must be copied
 ASPathName path2;
 AVDoc avDoc2;
 PDDoc pdDoc2;
 PDPage pdPage2;
 PDEContent pdeContent2;

 // Get doc1 data
 avDoc1 = AVAppGetActiveDoc(); // Get AVDoc of current open file
 pdDoc1 = AVDocGetPDDoc(avDoc1); // Get PDDoc from AVDoc
 pdPage1 = PDDocAcquirePage (pdDoc1, 1); // Get first page
 pdeContent1 = PDPageAcquirePDEContent (pdPage1, gExtensionID); // Get page
content, gExtensionID defined elsewhere

 // Open doc2 and get its data
 path2 = ASFileSysCreatePathName (NULL, ASAtomFromString("Cstring"),
IMG_PATH, 0); // Create a path to load doc2
 avDoc2 = AVDocOpenFromFile(path2, ASGetDefaultFileSys(), NULL); // Open
doc2
 pdDoc2 = AVDocGetPDDoc(avDoc2); // Get PDDOc
 pdPage2 = PDDocAcquirePage (pdDoc2, 0); // Get first page
 pdeContent2 = PDPageAcquirePDEContent (pdPage2, gExtensionID); // Get page
content

 numElem = PDEContentGetNumElems(pdeContent2); // Get num of elems from
doc2's PDEContent

 // Store doc2's elements into an array
 for (int i=0; i<=numElem; i++)
 {
  pdeElem1[i] = PDEContentGetElem(pdeContent2, i);
 }

 // IF I COMPILE AND RUN, TILL HERE EVERYTHING IS OK AND NO ERROR MESSAGES
OR EXCEPTIONS ARISE

 // Add to doc1's PDEContent all the stored elements/objects from the array
 for (int j=0; j<=numElem; j++)
 {
  PDEContentAddElem (pdeContent1, kPDEAfterLast, pdeElem1[j]);
 }

 // AT THIS POINT, IF I COMPILE AND RUN THE EXCEPTION
"peErrWrongPDEObjectType" ARISE and the error message "Incorrect PDEObject
type" is displayed

 // Save changes to the doc1's PDEContent
 PDPageSetPDEContent(pdPage1, gExtensionID);
 PDPageNotifyContentsDidChange (pdPage1);

 // Release all objects
 ...
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////

I hope the above makes sense. Could someone help me?
Many thanks.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

 
 
 

1. Copy and object from a pdf file into another pdf file

I'm writing a plugin copying into an open pdf files (doc1) all the objects
(images, etc.) from another pdf files (doc2).
So far, this is the main procedure (no error checkings to have a more
readable code):

/////////////////////////////////////////////////////////////////////////
//
 char* IMG_PATH = "c:\\Logo1.pdf"; // Logo1.pdf is the doc2 containing the
objects (an image for example)

 ASInt32 numElem; // Number of PDEElents objects into doc2

 //The file into which objects must be copied
 AVDoc avDoc1;
 PDDoc pdDoc1;
 PDPage pdPage1;
 AVPageView avPageView1;
 PDEContent pdeContent1;
 PDEElement pdeElem1[200]; // Just to simplify for the moment I use a fixed
length array of objects

 //The file from which objects must be copied
 ASPathName path2;
 AVDoc avDoc2;
 PDDoc pdDoc2;
 PDPage pdPage2;
 PDEContent pdeContent2;

 // Get doc1 data
 avDoc1 = AVAppGetActiveDoc(); // Get AVDoc of current open file
 pdDoc1 = AVDocGetPDDoc(avDoc1); // Get PDDoc from AVDoc
 pdPage1 = PDDocAcquirePage (pdDoc1, 1); // Get first page
 pdeContent1 = PDPageAcquirePDEContent (pdPage1, gExtensionID); // Get page
content, gExtensionID defined elsewhere

 // Open doc2 and get its data
 path2 = ASFileSysCreatePathName (NULL, ASAtomFromString("Cstring"),
IMG_PATH, 0); // Create a path to load doc2
 avDoc2 = AVDocOpenFromFile(path2, ASGetDefaultFileSys(), NULL); // Open
doc2
 pdDoc2 = AVDocGetPDDoc(avDoc2); // Get PDDOc
 pdPage2 = PDDocAcquirePage (pdDoc2, 0); // Get first page
 pdeContent2 = PDPageAcquirePDEContent (pdPage2, gExtensionID); // Get page
content

 numElem = PDEContentGetNumElems(pdeContent2); // Get num of elems from
doc2's PDEContent

 // Store doc2's elements into an array
 for (int i=0; i<=numElem; i++)
 {
  pdeElem1[i] = PDEContentGetElem(pdeContent2, i);
 }

 // IF I COMPILE AND RUN, TILL HERE EVERYTHING IS OK AND NO ERROR MESSAGES
OR EXCEPTIONS ARISE

 // Add to doc1's PDEContent all the stored elements/objects from the array
 for (int j=0; j<=numElem; j++)
 {
  PDEContentAddElem (pdeContent1, kPDEAfterLast, pdeElem1[i]);
 }

 // AT THIS POINT, IF I COMPILE AND RUN THE EXCEPTION
"peErrWrongPDEObjectType" ARISE and the error message "Incorrect PDEObject
type" is displayed

 // Save changes to the doc1's PDEContent
 PDPageSetPDEContent(pdPage1, gExtensionID);
 PDPageNotifyContentsDidChange (pdPage1);

 // Release all objects
 ...
//
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////

I hope the above makes sense. Could someone help me?
Many thanks.

-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

2. DVDecProperties : changing PropDisplay

3. How to copy several pdf-files in one pdf-file?

4. Full-sized keyboard for the Psion 3 ?

5. PDF Internals: object references in pdf file

6. Server Error when Publishing FP98

7. Word file with PDF object - Can't turn it into a PDF !

8. Remove Database Icon After Browsing

9. Best way to save multiple PDF files into one PDF file?

10. Adding one pdf file to the end of another pdf file

11. Pdf-files to 1 Pdf-file ??

12. How to convert a pdf file to to a 2-up or 4-up pdf file?

13. Building Two PDF file contents on one PDF File with VB