Returning Magnification as null for some of the PDF files

I am using Aspose pdf dll to get the details of Magnification of a pdf but for some of the pdf it is returning null

Document doc = new Document(“source.pdf”);

doc.OpenAction is null due to this I am not able to get the actual Magnification of a pdf. Tested pdf document has the magnification set to default.

Please do find the attached file.ema-cover.pdf (48.3 KB)

@sidcode

Could you please use the following code example to achieve your requirement? Hope this helps you.

Document doc = new Document(MyDir + "ema-cover.pdf");
double zoom;
GoToAction action;
if (doc.OpenAction == null)
{
    //Document has no action, magnification is null

    //Create new GoToAction
    action = new GoToAction(new XYZExplicitDestination(1, 0, doc.Pages[1].PageInfo.Height, 2));
    doc.OpenAction = action;
    zoom = (action.Destination as XYZExplicitDestination).Zoom;
}
else
{
    action = doc.OpenAction as GoToAction;
    if (action.Destination is XYZExplicitDestination)
    {
        zoom = ((XYZExplicitDestination)action.Destination).Zoom;
    }
}

Hi @tahir.manzoor,
According your solution, you are just creating new object as

action = new GoToAction(new XYZExplicitDestination(1, 0, doc.Pages[1].PageInfo.Height, 2));

in this case what ever values you give on Zoom values at fourth parameter it returns the same. But I want the original zoom value of the document.

Details:
When we try to retrieve document magnification, we first try to get the openAction of a document using below line of code.

GoToAction action = (GoToAction)pdfDoc.OpenAction;

When the action is retrieved then the document magnification value is returned correctly.

When the action returns null then we tried to get action by creating GoToAction using below code snippet.

if (pdfdoc.OpenAction == null)
{
   //Document has no action, magnification is null
   //Create new GoToAction
   action = new GoToAction(new XYZExplicitDestination(1, 0, pdfDoc.Pages[1].PageInfo.Height,3));
}

In the above code snippet.

When we try to create new GoToAction().

The 4th parameter double zoom passed will return same value when we try to extract destination Zoom value.

For example, in the below code snippet we are passing value as 3

//Create new GoToAction
  action = new GoToAction(new XYZExplicitDestination(1, 0, pdfDoc.Pages[1].PageInfo.Height,3));

When we try to get the zoom value using below code snippet

XYZExplicitDestination dest = null;

if ((dest = gotoaction.Destination as XYZExplicitDestination) != null)
{
    double value = dest.Zoom;
}

The dest.zoom returns whatever we have passed as 4th parameter in create GoToAction. We have passed 3 in create GoToAction hence we get dest.zoom value as 3.

If we pass 4 we will get 4 which is incorrectly determining the zoom factor.

The Magnification of a document with action null is incorrectly returning the zoom factor using above code snippet.

@sidcode

We have logged your requirement as PDFNET-52221 in our issue tracking system. We will inform you via this forum thread once this feature is available.

We apologize for your inconvenience.

Hello @tahir.manzoor,
Any updates on this ticket? Could you please assist me here after such a long time?

With Regards,
Sid

@sidcode

Regretfully, the earlier logged ticket could not get resolved due to other pending issues in the queue. However, we have recorded your concerns and will surely inform you as soon as we have some updates in this regard. Please spare us some time.

We are sorry for the inconvenience.

Hi @asad.ali,
ETA or any updates.
Some of our products have been having problems for many months. Can you please expedite?

With Regards,
Sid

@sidcode

We are afraid that the ticket has not been yet resolved due to other issues in the queue logged prior to it. In case the issue is blocker for you, you may please check priority support option where this ticket can be expedited to the highest priority. We will however inform you here once we have some definite updates about its resolution. We apologize for the inconvenience.

@asad.ali, Any luck on this issue?

@sidcode

We are afraid that the issue could not get resolved yet due to other issues in the queue. We will surely inform you as soon as we have some updates about its resolution. Please spare us some time.

We are sorry for the inconvenience.