We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PdfSaveOptions.ZoomBehavior in Aspose PDF Library for .NET

We 're currently evaluating Aspose Total for .NET. We need to set the PDF magnification property to default for compliance requirements. For word documents, we were able to specify the PdfSaveOptions.ZoomBehavior as PdfZoomBehavior.None (which leaves how documents are displayed to PDF viewer) using Aspose Word for .NET while saving them as PDFs. Is there a similar propery in Aspose .NET PDF library to configure or reset ZoomBehavior for existing PDF documents?

After thorough analysis we found that when we set Document.OpenAction to null, PDF magnification property is getting set to default (perfectly works as we expect). However, when we read or get the Document.OpenAction, Aspose PDF library for .NET throws object not set to an instance of an object error. Are there any Document.OpenAction example we can refer to?

Hi,


Thanks for using our products.

I have tested the scenario where I have tried getting the value of OpenAction property for Document object and I am able to notice the same problem. The issue might be occurring because no value has been specified for OpenAction. However I would suggest you to please try using the following code snippet.

[C#]

PdfPageEditor pageEditor = new PdfPageEditor();<o:p></o:p>

// open source PDF file

pageEditor.BindPdf("c:/pdftest/Table_Result.pdf");

// Get or sets zoom coefficient. Value 1.0 corresponds to 100%. Default value is 1.0.

pageEditor.Zoom = 1.5f;

// save updated document

pageEditor.Save("c:/pdftest/ZoomValue.pdf");

Thanks for your quick respose Nayyer. We do not want to set any value to the zoom. We want to check what is the current zoom behavior or open action. Primary we're interested in checking if the magnification is set to default for the existing PDF documents. We were able to set the magnification to default by assigning null to Document.OpenAction. We'll assume that it's not currently available.

Thanks,

Siva

Hi Siva,


Thanks for sharing the details.

I am afraid the feature to get Zoom value/factor of PDF file is currently not supported. However for the sake of implementation, I have logged this requirement as PDFNEWNET-34932 in our issue tracking system. We will further investigate this requirement
in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Hi Siva,


Thanks for your patience.

In order to get the Zoom factor/value of PDF file, please try using the following code snippet.

[C#]

// instantaite new Document object<o:p></o:p>

Document doc = new Document("c:/pdftest/Zoomed_pdf.pdf");

// create GoToAction object

GoToAction action = doc.OpenAction as GoToAction;

// get the Zoom factor of PDF file

Console.WriteLine((action.Destination as XYZExplicitDestination).Zoom);
// Document zoom value;



Please note that before you try to get the zoom value of PDF file, ensure that zoom factor is assigned to PDF file. You try using the following code snippet to add zoom factor for PDF file.

[C#]

double zoom = 5;<o:p></o:p>

Document doc = new Document("c:/pdftest/Form 1221.pdf");

GoToAction action = new GoToAction();

action.Destination = new XYZExplicitDestination(doc, 0, 0, 0, zoom);

doc.OpenAction = action;

doc.Save("c:/pdftest/Zoomed_pdf.pdf");

The issues you have found earlier (filed as PDFNEWNET-34932) have been fixed in Aspose.Pdf for .NET 7.8.0update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

hello i am having a problem… OpenAction is not identified. What is the library for that?:frowning:

Hi Hafsa,


Thanks for your inquiry. Please note OpenAction is property of Aspose.Pdf.Document class. Please check sample code snippet for the purpose. Please download and try latest version of Aspose.Pdf for .NET, it will help you to resolve the issue.

double zoom = 5;<o:p></o:p>

Aspose.Pdf.Document doc = new Aspose.Pdf.Document("Input.pdf");

Aspose.Pdf.InteractiveFeatures.GoToAction action = new Aspose.Pdf.InteractiveFeatures.GoToAction(new Aspose.Pdf.InteractiveFeatures.XYZExplicitDestination(doc.Pages[1], 0, doc.Pages[1].Rect.Height, zoom));

doc.OpenAction = action;

doc.Save("Zoomed_pdf.pdf");

Please feel free to contact us for any further assistance.


Best Regards,