Sending Image to be Viewed from php App

Discussions about DocuVieware integration in GdPicture.NET.
Post Reply
philip1978
Posts: 13
Joined: Mon Sep 19, 2016 5:45 pm

Sending Image to be Viewed from php App

Post by philip1978 » Mon Sep 19, 2016 5:52 pm

We have a PHP application that I maintain, and we are wanting to add the ability for clients to view images attached to their account via the web app. I have looked at various ways to do this with PHP, but our company recently bought the ultimate package for use with our desktop VB.NET applications we maintain, and I thought I might be able to utilize a DocuVieware web control to accomplish this.

What I had in mind was to set up a separate area of the application for this purpose, and basically just stick a single web page there that would contain the Web Form with the DocuVieware control on it. I would send some level of information about the file to be viewed to the Web Form that would then render it for the client. The viewer itself would be very pared down. All I really want the client to be able to do is basically view, save, and maybe print.

Does this sound like a reasonable solution, and not to time-consuming to implement?

Thanks!

philip1978
Posts: 13
Joined: Mon Sep 19, 2016 5:45 pm

Re: Sending Image to be Viewed from php App

Post by philip1978 » Thu Sep 22, 2016 6:07 pm

Okay, so no one has responded so far. I'll update the progress on this and ask another question.

PROGRESS:

I have my PHP app running happily on IIS, and I have also deployed the blank docuvieware web control, as in the tutorial on the same server, and all seems to be running well.

QUESTION:

Is the source code or original project files for any of the DocuVieware Demos available? I see where the customizable viewer demo allows you to restrict functionality on the toolbar via what looks like JavaScript, but the API documentation is not very clear on how to do this on page load. What I'm wanting to do is to bring up a page with a Docuvieware Web Control on it, with a file preloaded into it, with limited functionality, such as save, print, page through the document, and that's about it. Any advice on where to find specifics on how this can be accomplished?

Thanks!

philip1978
Posts: 13
Joined: Mon Sep 19, 2016 5:45 pm

Re: Sending Image to be Viewed from php App

Post by philip1978 » Thu Sep 22, 2016 6:34 pm

ANOTHER UPDATE:

I was able to locate the source project for the demo page in my install directory. I am in the process of digging through the customizable viewer page. I'm wondering if my best bet is to dig into the JS API, and do all my player manipulation, such as loading the file automatically, and setting the desired UI elements from JavaScript, or if I should be looking more into the Web Form Control side as far as initial setup is concerned.

Any thoughts would be appreciated.

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Sending Image to be Viewed from php App

Post by Cedric » Fri Sep 23, 2016 1:52 pm

Does this sound like a reasonable solution, and not to time-consuming to implement?
Yes it does sound reasonable and easy enough to implement.
Okay, so no one has responded so far. I'll update the progress on this and ask another question.
Technical support through the community forum is provided on non-priority best effort, so if you need quick assistance you can open a ticket on the support platform.
I see where the customizable viewer demo allows you to restrict functionality on the toolbar via what looks like JavaScript, but the API documentation is not very clear on how to do this on page load. What I'm wanting to do is to bring up a page with a Docuvieware Web Control on it, with a file preloaded into it, with limited functionality, such as save, print, page through the document, and that's about it. Any advice on where to find specifics on how this can be accomplished?
The JS API won't help you with that as it needs to be taken care of on control initialization (disabled means that the element is not just hidden but simply not generated within the control), JS API comes after that.
There is a property for each button of the toolbar so you just have to take care of the properties you are interested into and the DocuVieware control toolbar content will reflect those.
Here is the link to the properties documentation: http://www.docuvieware.com/guides/aspne ... rties.html
For instance if you want only the save, print and page navigation buttons you just need to set everything else to false as the default is true.

That should look like something like this:

Code: Select all

<cc1:DocuVieware ID="DocuVieware1" runat="server"
	Height="100%"
	Width="100%"
	SinglePageView="False"
	ForceScrollBars="False"
	AllowedExportFormats="*"
	MaxUploadSize="52428800"
	CollapsedSnapIn="True"
	EnableFileUploadButton="False"
	EnableLoadFromUriButton="False"
	EnableTwainAcquisitionButton="False"
	EnableZoomButtons="False"
	EnableRotateButtons="False"
	EnableFullScreenButton="False"
	EnablePageViewButtons="False"
	EnableMouseModeButtons="False"
	EnableZoom100Button="False"
	EnableFitWidthButton="False"
	EnableFitPageButton="False"
	EnableMarqueeZoomModeButton="False"
	EnableFormFieldsEdition="False" />
I hope this helps

philip1978
Posts: 13
Joined: Mon Sep 19, 2016 5:45 pm

Re: Sending Image to be Viewed from php App

Post by philip1978 » Fri Sep 23, 2016 3:40 pm

Just what I needed. Thanks for the help!

As a secondary question, what would be the best way to pass an image number to the page so I can dynamically grab the image stream from the DB? I have a global function that gets the stream from the DB, like so:

Code: Select all

public static Byte[] getImage(int imageID)
        {
            SqlConnection db = getDBConnection("DBString");
            db.Open();
            String sql = @"
                SELECT IMGVALUE 
                FROM PATIMAGE 
                WHERE (IMGID = @imageid)";
            using (SqlCommand cmd = new SqlCommand(sql, db))
            {
                cmd.Parameters.Add("@imageid", SqlDbType.Int).Value = imageID;
                using (SqlDataReader d = cmd.ExecuteReader())
                {
                    if (d.Read())
                    {
                        byte[] image = (byte[])d["IMGVALUE"];
                        return image;
                    }
                    else
                    {
                        return null;
                    }
                }
            }
        }
Then on page load for my Default.aspx.cs file, I have:

Code: Select all

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using GdPicture12;

namespace DocuViewareDemo
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GdPictureStatus status = DocuVieware1.LoadFromStream(new MemoryStream(Global.getImage(4579788)), true);
        }
    }
}
This works great with an image number hard coded in, but I am wanting to pass one dynamically as a parameter, probably through the URL. I'm VERY new to C# and ASP.NET, so any advice as far as best practices for doing this would be appreciated.

Thanks!

Cedric
Posts: 269
Joined: Sun Sep 02, 2012 7:30 pm

Re: Sending Image to be Viewed from php App

Post by Cedric » Fri Sep 23, 2016 3:59 pm

If you pass something in the URL like this:

Code: Select all

yourpage.aspx?parameter1=123456

I believe you should be able to get it in your Page_Load with this:

Code: Select all

if (Request.QueryString["parameter1"] != null)
{
    int imageId = (int)Request.QueryString["parameter1"];
}
Of course this code assumes it is directly castable as an integer which is a bit dangerous so you might want to properly do it.

philip1978
Posts: 13
Joined: Mon Sep 19, 2016 5:45 pm

Re: Sending Image to be Viewed from php App

Post by philip1978 » Fri Sep 23, 2016 5:00 pm

Thanks. For the record, C# won't directly cast a string to an int, so here's how I handled that situation:

Code: Select all

try
{
     int id = Int32.Parse(Request.QueryString["imageid"]);
     GdPictureStatus status = DocuVieware1.LoadFromStream(new MemoryStream(Global.getImage(id)), true);
}
     catch (FormatException ex)
{
      //Prettify error or redirect for better user experience
     Console.WriteLine(ex.Message);
}
Thanks again!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest