Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rendering veiwport with parameters other than scale

2,137 views
Skip to first unread message

kiran.na...@gmail.com

unread,
Jan 27, 2013, 10:15:46 AM1/27/13
to
Hi,
I was wondering if there is any way of specifying any other parameter (width) etc for the viewport instead of giving scale?

var viewport = page.getViewport(scale);

The use case that I am seeing is - We have multiple PDF's and using the same scale for all of them doesn't work .. some of them are smaller, some are larger as we have to make sure the PDF doesn't flow out of the page..
If there is the way of mentioning either the desired max-width so that the scale is calculated automatically making sure the rendering PDF doesn't distort the overall layout.

Julian Viereck

unread,
Jan 28, 2013, 1:06:17 AM1/28/13
to kiran.na...@gmail.com, dev-p...@lists.mozilla.org
Hi Kiran,

> I was wondering if there is any way of specifying any other parameter (width) etc for the viewport instead of giving scale?

I don't think so. In your case, could you do:

var desiredWidth = ...;
var viewport = page.getViewport(1.0);
viewport = page.getViewport(desiredWidth/viewport.width);

Hope this helps. Don't hesitate to write back in case you have more
questions!

Very best,

Julian
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-pdf-js

Kiran Narasareddy

unread,
Jan 28, 2013, 4:31:26 AM1/28/13
to Julian Viereck, dev-p...@lists.mozilla.org
duh!! That was obvious. Thanks Julian!!

Regards,
Kiran Narasareddy
www.amuratech.com | @knarasareddy <http://twitter.com/knarasareddy>
Mb: +91-9881146184


On Mon, Jan 28, 2013 at 11:36 AM, Julian Viereck <
jviere...@googlemail.com> wrote:

> Hi Kiran,
>
> I was wondering if there is any way of specifying any other parameter
>> (width) etc for the viewport instead of giving scale?
>>
>
> I don't think so. In your case, could you do:
>
> var desiredWidth = ...;
> var viewport = page.getViewport(1.0);
> viewport = page.getViewport(desiredWidth/**viewport.width);
>
> Hope this helps. Don't hesitate to write back in case you have more
> questions!
>
> Very best,
>
> Julian
>
> On Sun Jan 27 16:15:46 2013, kiran.na...@gmail.com wrote:
>
>> ______________________________**_________________
>> dev-pdf-js mailing list
>> dev-p...@lists.mozilla.org
>> https://lists.mozilla.org/**listinfo/dev-pdf-js<https://lists.mozilla.org/listinfo/dev-pdf-js>
>>
>

Kiran Narasareddy

unread,
Feb 6, 2013, 2:25:16 PM2/6/13
to Julian Viereck, dev-p...@lists.mozilla.org
Julian,
I am facing a weird issue.. the js is loading up fine on one of the
computers and the pdf is displaying normally, but on other computer the
same setup doesn't display pdf.
Error on console shown is -
*(while reading XRef) : TypeError: Cannot call method 'get' of undefined -
pdf.js: 4801*
*
*
sometimes the error shown is
*(while reading XRef) : TypeError: dict is undefined -
pdf.js: 4808*
*
*
The strange thing is - the same setup is working fine at other locations.

Would appreciate any pointers
*
*
*
*

Regards,
Kiran Narasareddy
www.amuratech.com | @knarasareddy <http://twitter.com/knarasareddy>
Mb: +91-9881146184


On Mon, Jan 28, 2013 at 11:36 AM, Julian Viereck <
jviere...@googlemail.com> wrote:

> Hi Kiran,
>
> I was wondering if there is any way of specifying any other parameter
>> (width) etc for the viewport instead of giving scale?
>>
>
> I don't think so. In your case, could you do:
>
> var desiredWidth = ...;
> var viewport = page.getViewport(1.0);
> viewport = page.getViewport(desiredWidth/**viewport.width);
>
> Hope this helps. Don't hesitate to write back in case you have more
> questions!
>
> Very best,
>
> Julian
>
> On Sun Jan 27 16:15:46 2013, kiran.na...@gmail.com wrote:
>

Kiran Narasareddy

unread,
Feb 6, 2013, 2:27:20 PM2/6/13
to Julian Viereck, dev-p...@lists.mozilla.org
sorry the line number for the error is *4081 *and* not 4801*

Regards,
Kiran Narasareddy
www.amuratech.com | @knarasareddy <http://twitter.com/knarasareddy>
Mb: +91-9881146184


>> I was wondering if there is any way of specifying any other parameter
>>> (width) etc for the viewport instead of giving scale?
>>>
>>
>> I don't think so. In your case, could you do:
>>
>> var desiredWidth = ...;
>> var viewport = page.getViewport(1.0);
>> viewport = page.getViewport(desiredWidth/**viewport.width);
>>
>> Hope this helps. Don't hesitate to write back in case you have more
>> questions!
>>
>> Very best,
>>
>> Julian
>>
>> On Sun Jan 27 16:15:46 2013, kiran.na...@gmail.com wrote:
>>

Julian Viereck

unread,
Feb 6, 2013, 2:55:07 PM2/6/13
to Kiran Narasareddy, dev-p...@lists.mozilla.org
Do you use the same browser on both machines, same PDF?

Best,

Julian

On 2/6/13 8:25 PM, Kiran Narasareddy wrote:
> Julian,
> I am facing a weird issue.. the js is loading up fine on one of the
> computers and the pdf is displaying normally, but on other computer
> the same setup doesn't display pdf.
> Error on console shown is -
> *(while reading XRef) : TypeError: Cannot call method 'get' of
> undefined - pdf.js: 4801*
> *
> *
> sometimes the error shown is
> *(while reading XRef) : TypeError: dict is undefined -
> pdf.js: 4808*
> *
> *
> The strange thing is - the same setup is working fine at other locations.
>
> Would appreciate any pointers
> *
> *
> *
> *
>
> Regards,
> Kiran Narasareddy
> www.amuratech.com <http://www.amuratech.com> | @knarasareddy
> <http://twitter.com/knarasareddy>
> Mb: +91-9881146184
>
>
> On Mon, Jan 28, 2013 at 11:36 AM, Julian Viereck
> <jviere...@googlemail.com <mailto:jviere...@googlemail.com>> wrote:
>
> Hi Kiran,
>
> I was wondering if there is any way of specifying any other
> parameter (width) etc for the viewport instead of giving scale?
>
>
> I don't think so. In your case, could you do:
>
> var desiredWidth = ...;
> var viewport = page.getViewport(1.0);
> viewport = page.getViewport(desiredWidth/viewport.width);
>
> Hope this helps. Don't hesitate to write back in case you have
> more questions!
>
> Very best,
>
> Julian
>
> On Sun Jan 27 16:15:46 2013, kiran.na...@gmail.com
> _______________________________________________
> dev-pdf-js mailing list
> dev-p...@lists.mozilla.org <mailto:dev-p...@lists.mozilla.org>
> https://lists.mozilla.org/listinfo/dev-pdf-js
>
>

Kiran Narasareddy

unread,
Feb 6, 2013, 10:34:08 PM2/6/13
to Julian Viereck, dev-p...@lists.mozilla.org
Same browser (Chrome & Firefox).. it works on windows, Linux.. issue is
with OSX

kn

Sent from my HTC
On 07-Feb-2013 1:25 AM, "Julian Viereck" <jviere...@googlemail.com>
wrote:
> www.amuratech.com | @knarasareddy <http://twitter.com/knarasareddy>
> Mb: +91-9881146184
>
>
> On Mon, Jan 28, 2013 at 11:36 AM, Julian Viereck <
> jviere...@googlemail.com> wrote:
>
>> Hi Kiran,
>>
>> I was wondering if there is any way of specifying any other parameter
>>> (width) etc for the viewport instead of giving scale?
>>>
>>
>> I don't think so. In your case, could you do:
>>
>> var desiredWidth = ...;
>> var viewport = page.getViewport(1.0);
>> viewport = page.getViewport(desiredWidth/viewport.width);
>>
>> Hope this helps. Don't hesitate to write back in case you have more
>> questions!
>>
>> Very best,
>>
>> Julian
>>
>>> _______________________________________________
>>> dev-pdf-js mailing list
>>> dev-p...@lists.mozilla.org
>>> https://lists.mozilla.org/listinfo/dev-pdf-js
>>>
>>
>
>
0 new messages