コミュニティ

Multi Page object Replace Error 回答済み

Hello!

When setting a layout object as a page object, an error occurs if there are multiple pages.
Please tell me the workaround.

Error: System.AccessViolationException
Detail: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Code:


int iTargetPage = 1;
FRPage page = document.Pages.Item(iTargetPage - 1);
page.Layout = layout;
List<FRPage> lPage = new List<FRPage>(); for (int iIndex = document.Pages.Count - 1; iIndex >= 0; iIndex--) { lPage.Add(document.Pages.Item(iIndex)); document.Pages.DeleteAt(iIndex); }
// Ascending Order lPage.Reverse();
// Exec Replace for (int iIndex = 0; iIndex < lPage.Count; iIndex++) { if (iIndex + 1 == iTargetPage) { // Replace document.AddPage(page); } else { // Not Replace document.AddPage(lPage[iIndex]); // Error!! } }

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

4件のコメント

  • Avatar
    Permanently deleted user

    Hello,

    When you assign a Layout object to FREngine.Layout property (for example, when transferring data from one page to another), the logical structure of the corresponding document becomes invalid. It is necessary to restore the document structure by calling one of the synthesis methods. However, you do not need to perform synthesis for the whole document, it is only necessary to synthesize changed pages, e.g. using the Synthesize method.

    0
  • Avatar
    Permanently deleted user

    Hello!

    Thank you for your reply.
    I corrected the points pointed out and confirmed that no error occurred.
    I will post the corrected source, so please let me know if it is wrong.
    I appreciate it very much.

    Code:

    
    int iTargetPage = 1;
    FRPage page = document.Pages.Item(iTargetPage - 1);
    page.Layout = layout;
    page.Synthesize();    // Add Code
    List<FRPage> lPage = new List<FRPage>(); for (int iIndex = document.Pages.Count - 1; iIndex >= 0; iIndex--) { document.Pages.Item(iIndex).Synthesize(); // Add Code lPage.Add(document.Pages.Item(iIndex)); document.Pages.DeleteAt(iIndex); }
    // Ascending Order lPage.Reverse();
    // Exec Replace for (int iIndex = 0; iIndex < lPage.Count; iIndex++) { if (iIndex + 1 == iTargetPage) { // Replace document.AddPage(page); } else { // Not Replace document.AddPage(lPage[iIndex]); } }
    0
  • Avatar
    Permanently deleted user

    The code you posted is OK, but it might not work for some OCR scenarios different from yours. In this case, we would recommend calling Document.Synthesize() at the end.

    1
  • Avatar
    Permanently deleted user

    I understood.
    Thank you for the advice.

    0

サインインしてコメントを残してください。