• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Best design to create a document

Community Beginner ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

Hi all,

I am creating a PDF document from scratch with the Adobe SDK Library. My first version of the code is working but I would like to improve the speed of the algorithm.

Here is the initial workflow :

1 - Create a new empty document via

     * PDDocCreate

     * PDDocCreatePage

     * PDDocSave

2 - For each text element to add

     * PDDocOpen

     * PDDocAquirePage

     * PDPageAcquirePDEContent

     * PDEContentAddElem

     * PDPageSetPDEContent

     * PDDocSave

As I said, this process works fine but it's not efficient because each time we open and save the same file. So my second thought was to do :

1 - Create a new empty document via

     * PDDocCreate

     * PDDocCreatePage

     * PDDocSave

     * return pdDoc

2 - For each text element to add, using the already known pdDoc

     * PDDocOpen

     * PDDocAquirePage

     * PDPageAcquirePDEContent

     * PDEContentAddElem

     * PDPageSetPDEContent

     * PDDocSave

In this way it seems to be two times faster. It is great but I would like to know if it is possible to avoid the PDDocSave and doing it only one time at the end. Here is the Idea :

1 - Create a new empty document via

     * PDDocCreate

     * PDDocCreatePage

     * PDDocAquirePage

     * PDPageAcquirePDEContent

     * PDDocSave

     * return pdeContent

2 - For each text element to add, using the already known pdeContent

     * PDDocOpen

     * PDDocAquirePage

     * PDPageAcquirePDEContent

     * PDEContentAddElem

     * PDPageSetPDEContent

     * PDDocSave

3 - Save the Document

    * ???

The Question are :

- How can I deal with the multiple page ? Is PDEContentAddPage the answer ?

- I think I could use PDPageSetPDEContent to send the pdeContent to a pdPage but what is the pdDoc for PDDocSave ? How could I set it with pdPage ?

Thank you in advance for your help.

TOPICS
Acrobat SDK and JavaScript

Views

581

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 08, 2018 Aug 08, 2018

1. Return also PDDoc

3. Save using PDDoc Returned in 1.

Votes

Translate

Translate
Community Expert ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

With PDDocCreatePage you can add new empty pages.

You don't need PDDocAquirePage after PDDocCreatePage.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

1. Return also PDDoc

3. Save using PDDoc Returned in 1.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

- Since, I add each Text in the pdeContent I will not have any pdPage in 2 ?

- Probably a related question, how can the pdDoc return in 1 know what I have Added in the pdeContent ?

According to both answers, Is it correct to do :

1 - Create a new empty document via

     * PDDocCreate

     * PDDocCreatePage

     * PDDocAquirePage

     * PDPageAcquirePDEContent

     * PDDocSave

     * return pdeContent pdPage and pdDoc

2 - For each text element to add, using the already known pdeContent

     * PDEContentAddElem

     * PDPageSetPDEContent

3 - Save the Document

    * PDDocSave using pdDoc

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

You need the PDPageSetPDEContent only once after adding all elements.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

Thank you very much Bernd Alheit​ and Test Screen Name​ it seems to work.

It took me roughly roughly 28 sec to insert 400 elements with the first process, 14 sec with the second and about 0.5 sec now !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

In general, it works more like:

  • PDDoc newDoc = PDDocCreate

  • For each page

  • PDPage newPage = PDDocCreatePage( newDoc )

  • PDEContent cont = PDPageAcquirePDEContent( newPage )

  • For each element

  • PDEContentAddElem( cont )

  • PDEPageSetPDEContent( newPage, cont )

  • PDDocSave( newDoc )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 08, 2018 Aug 08, 2018

Copy link to clipboard

Copied

LATEST

The PDDoc is not a frozen copy of a file, or a name of a file on disk, it holds all the contents as you change them. These changes are in memory or temporary files. When you save, all changes are saved.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines