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!!
}
}
Comments
4 comments
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.
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:
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.
I understood.
Thank you for the advice.
Please sign in to leave a comment.