Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Thu Mar 17, 2016 10:38 am

Hi, I'm using the latest version of Spire.premium and the pdfviewer control does not support paging. Can you advise how to page using that control?
I have tried:
<input type="button" id="btnfirst" value="first" onclick="pdfViewer.FirstPage()" value"first" />

where my control is named 'pdfViewer' and it raises the error on click: " JavaScript runtime error: Object doesn't support property or method 'FirstPage'".

Forensicare
 
Posts: 22
Joined: Fri Aug 02, 2013 3:29 am

Fri Mar 18, 2016 2:33 am

Hi,

Thanks for your posting.
pdfviewer control itself has paging function.
pdfViewerControl.png

Please use pdfdocumentviewer control to add paging buttons.
Code: Select all
<div>
        <input type="button" id="btnFirst" value="first" onclick="pdfdocumentviewer1.FirstPage()" />
        <input type="button" id="btnPrevious" value="Previous" onclick="pdfdocumentviewer1.PreviousPage()" />
        <input type="text" id="PdfDocumentViewer1_PdfViewerCurrentPage" value="1" style="width: 50px;" />
        <span id="PdfDocumentViewer1_PdfViwerCountPage"></span>
        <input type="button" id="btnNext" value="Next" onclick="pdfdocumentviewer1.NextPage()" />
        <input type="button" id="btnLast" value="Last" onclick="pdfdocumentviewer1.LastPage()" />

        <cc1:PdfDocumentViewer id="PdfDocumentViewer1" runat="server" width="800px" Height="300px">
        </cc1:PdfDocumentViewer>
    </div>


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Mar 22, 2016 7:33 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Fri Mar 25, 2016 1:11 am

Hi Amy
The paging buttons and code appear to work only on the first time the page is loaded. If you press the refresh button, all events then fail. Also, and a bigger issue, when using the option to load from stream from a database, although the number of pages is displayed in the labels, only the first page displays in the control (they are blank gray). Lastly, the zoom code does zoom the document
Here is an extract of the code:
'[... code to extract pdf from database... bytecontentimage is an array of bytes from a document class]
dim ms as New System.IO.Memorystream = btyeContentImage()
With PdfDocumentViewer1
.ZoomFactor = 1.0

.LoadFromStream(ms)
End With

Thanks
Chris

Forensicare
 
Posts: 22
Joined: Fri Aug 02, 2013 3:29 am

Fri Mar 25, 2016 2:50 am

Hi,

Thanks for your feedback.
Please try the following solution:
Code: Select all
public partial class Default : System.Web.UI.Page
    {   
        private void CargarPreView()
        { 
           //fileStream is from your database
            byte[] bytes = new byte[fileStream.Length];
            fs.Read(bytes, 0, Convert.ToInt32(fs.Length));
            var ms = new MemoryStream();
            fs.Position = 0;
            fs.CopyTo(ms);
            fs.Close();
            fs.Dispose();
            this.PdfViewer1.CacheInterval = 1200;
            this.PdfViewer1.CacheTime = 1000;
            this.PdfViewer1.LoadFromStream(ms);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["CacheStreamTime"]))
                {
                    this.PdfViewer1.CacheTime = int.Parse(Request["CacheTime"].ToString());//second
                    this.PdfViewer1.CacheInterval = int.Parse(Request["CacheInterval"].ToString());//second
                    this.PdfViewer1.CacheNumberImage = int.Parse(Request["CacheNumberImage"].ToString());
                    this.PdfViewer1.ScrollInterval = int.Parse(Request["ScrollInterval"].ToString());
                    this.PdfViewer1.ZoomFactor = float.Parse(Request["ZoomFactor"].ToString());
                    this.PdfViewer1.CacheNumberStream = int.Parse(Request["CacheNumberStream"].ToString());
                    this.PdfViewer1.CacheStreamTime = int.Parse(Request["CacheStreamTime"].ToString());
                    this.PdfViewer1.CacheStreamInterval = int.Parse(Request["CacheStreamInterval"].ToString());


                    byte[] data = System.IO.File.ReadAllBytes(Server.MapPath("/") + "files\\" + Request["Files"].ToString());
                    System.IO.MemoryStream stream = new System.IO.MemoryStream(data);
                    this.PdfViewer1.LoadFromStream(stream);
                }
                else
                {
                    CargarPreView();
                }
            }
        }
    }


When you first start it up, you should get a link likes "http://localhost:1796/Default.aspx".
Please directly use the url likes "http://localhost:1796/Default.aspx?CacheTime=1000&CacheInterval=1200&CacheNumberImage=1000&CacheStreamTime=1000&CacheStreamInterval=1200&CacheNumberStream=100&ZoomFactor=1&ScrollInterval=300&Files=traducido.pdf" to visit another pdf file.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Mon Mar 28, 2016 8:19 am

Hi,

Did the solution above work on your side?
Thanks for your feedback in advance.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Fri Apr 01, 2016 3:54 am

Hi
No, this still does not work. It only ever shows the first page, even though it reports the correct number of pages: it simply shows blank grey for everything after the first page.
Chris

Forensicare
 
Posts: 22
Joined: Fri Aug 02, 2013 3:29 am

Fri Apr 01, 2016 6:02 am

Hi,

Thanks for your reply.
Please send your project to help us reproduce and investigate your issue, so that we can work out solution to resolve it soon.
You can send it to amy.zhao@e-iceblue.com. Thank you.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Mon May 02, 2016 11:51 am

Hi I can't post my solution as the documents are confidential. One thing I can report is that it always shows the last page as the first page and then no other pages show. Only ever the last page. The same happens with 'Loadfromfile'. Finally, once I install the Office suite, none of the spire.doc conversions work. It seems that you can't have pdf previewing work at the same time that docx is installed with the Office suite. What a waste of money.

Forensicare
 
Posts: 22
Joined: Fri Aug 02, 2013 3:29 am

Tue May 03, 2016 2:40 am

Hi,

Thanks for your feedback. Sorry for the inconvenience caused by the issues.
Is your case that the pdf file is created by Spire.Doc and then viewing it by Spire.PDFViewer for Asp.net?
For the issues as below you methioned, to help us replicate and know them on our side, if possible could you please provide us your document?
One thing I can report is that it always shows the last page as the first page and then no other pages show. Only ever the last page. The same happens with 'Loadfromfile'. Finally, once I install the Office suite, none of the spire.doc conversions work. It seems that you can't have pdf previewing work at the same time that docx is installed with the Office suite.


Thanks you very much for your assistance.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDFViewer