PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Apr 22, 2018 5:08 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: PDF Viewer Settings
PostPosted: Thu May 07, 2009 1:25 pm 
Offline

Joined: Mon May 04, 2009 2:12 pm
Posts: 2
Hi!

AmI able to configure the pdf file I generate in the way that the pdf viewer will start maximized, showing the whole first page ?

hanappol


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu May 07, 2009 2:17 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2807
Location: Cologne, Germany
I dunno if this is implemented in current versions of PDFsharp ...

... but this old sample should still work:
http://www.pdfsharp.de/PDFsharp/index.p ... &Itemid=32

Look here for other options beside "/FitV":
http://partners.adobe.com/public/develo ... meters.pdf

I guess "/Fit" is the one.

No idea about Maximize ...

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 11, 2009 1:13 pm 
Offline

Joined: Mon May 04, 2009 2:12 pm
Posts: 2
Thank you for your information! I will try it soon and report my results here.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon May 11, 2009 1:43 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2807
Location: Cologne, Germany
I just saw that PdfDocument has members PageLayout and PageMode.
Code:
PdfDocument outputDocument = new PdfDocument();
outputDocument.PageLayout = PdfPageLayout.SinglePage;

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Viewer Settings
PostPosted: Thu Nov 17, 2011 11:36 am 
Offline

Joined: Thu Nov 17, 2011 11:31 am
Posts: 2
Hello

I tried to get the example shown her to work:
http://www.pdfsharp.de/PDFsharp/index.p ... &Itemid=32

I want to set a default zoom level of 100% in the pdf files i create..

However the example on the above URL does not seem to work..

For instance the PdfInternals.GetXRef method does not seem to exist?
And which namespace is PdfXRef in?

Is there a new and improved way of doing this or?

Any help would be greatly appreciated!

Thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Viewer Settings
PostPosted: Thu Nov 17, 2011 3:09 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2807
Location: Cologne, Germany
The current sample is here:
http://www.pdfsharp.net/wiki/WorkOnPdfO ... ample.ashx

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Viewer Settings
PostPosted: Fri Nov 18, 2011 11:03 am 
Offline

Joined: Thu Nov 17, 2011 11:31 am
Posts: 2
Thanks for the fast reply!

So.. I tried to follow the example and looked at the specification pdf to look for the right action.
Seems like there is a zoom property

zoom=scale
zoom=scale,left,top
Sets the zoom and scroll factors, using float or integer values.
For example, a scale value of 100 indicates a zoom value of 100%.
Scroll values left and top are in a coordinate system where 0,0 represents the top left corner of the visible page, regardless of document rotation.

But when i try to use it i just get an unknown destination type error the same happens when i try the example below

Here is the code:

PdfDocument pdf = new PdfDocument();
PdfPage page = pdf.AddPage();
PdfDictionary dict = new PdfDictionary(pdf);
dict.Elements["/S"] = new PdfName("/GoTo");
PdfArray array = new PdfArray(pdf);
dict.Elements["/D"] = array;
PdfReference iref = PdfInternals.GetReference(pdf.Pages[0]);
array.Elements.Add(iref);
array.Elements.Add(new PdfName("/XYZ 0 0 100"));
pdf.Internals.AddObject(dict);
pdf.Internals.Catalog.Elements["/OpenAction"] = PdfInternals.GetReference(dict);

pdf.Save(path + pdf_name + ".pdf");

Based on this thread:
viewtopic.php?f=2&t=1586&hilit=zoom+level

Any ideas?

Edit:
When i try this approach the pdf changes the zoom, only it changes it to 6400% instead of the 100% i want it to be..

array.Elements.Add(new PdfName("/XYZ"));
array.Elements.Add(new PdfInteger(0));
array.Elements.Add(new PdfInteger(0));
array.Elements.Add(new PdfInteger(100));

Solved:
So zoom here is not the zoom level in percent but the zoom factor, changing from 100 to 1 did the trick :)
PdfDictionary dict = new PdfDictionary(pdf);
dict.Elements["/S"] = new PdfName("/GoTo");
PdfArray array = new PdfArray(pdf);
dict.Elements["/D"] = array;
PdfReference iref = PdfInternals.GetReference(pdf.Pages[0]);
array.Elements.Add(iref);
array.Elements.Add(new PdfName("/XYZ"));
array.Elements.Add(new PdfInteger(0));
array.Elements.Add(new PdfInteger(0));
array.Elements.Add(new PdfInteger(1));
pdf.Internals.AddObject(dict);
pdf.Internals.Catalog.Elements["/OpenAction"] = PdfInternals.GetReference(dict);


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Viewer Settings
PostPosted: Sun Dec 31, 2017 10:20 pm 
Offline

Joined: Sun Dec 31, 2017 10:10 pm
Posts: 1
using your final code got me 100% zoom, but page 2 is displayed.
Combining your solution and this example:

http://www.pdfsharp.net/wiki/WorkOnPdfObjects-sample.ashx

I came to this solution:

PdfDictionary dict = new PdfDictionary(pdf);
dict.Elements["/S"] = new PdfName("/GoTo");
PdfArray array = new PdfArray(pdf);
dict.Elements["/D"] = array;
PdfReference iref = PdfInternals.GetReference(pdf.Pages[0]);
array.Elements.Add(iref);
array.Elements.Add(new PdfName("/XYZ"));
array.Elements.Add(new PdfInteger(-32768));
array.Elements.Add(new PdfInteger(-32768));
array.Elements.Add(new PdfInteger(1));
pdf.Internals.AddObject(dict);
pdf.Internals.Catalog.Elements["/OpenAction"] = PdfInternals.GetReference(dict);


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group