CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Display PDF

by zsleo » 25 Apr 2018 05:43

I am having trouble getting a a PDF to display correctly first time.

My Code:
Code: Select all
    ip_FRM := TiwcgjqfrmPrint.Create(WebApplication);
    ip_FRM.Parent := WebApplication.ActiveForm as TWinControl;
    ip_FRM.Name := ip_Name;
    ip_FRM.Top := ip_Top;
    ip_FRM.Left := ip_Left;
    ip_FRM.iwcgjqdlgx1.JQDialogOptions.Title := lv_Title;

    lv_FN := '\wwwroot\Sites\' + UserSession.gv_Site.SiteID + '\' + UserSession.gv_User.UserNumberStr + '\Temp\RepsOut\' + lv_FN;

    lv_FN := ReplaceText(lowercase(lv_FN), '\wwwroot\', '');
    lv_FN := ReplaceStr(lv_FN, '\', '/');
    lv_FN := ReplaceStr(lv_FN, '{', '%7B');
    lv_FN := ReplaceStr(lv_FN, '}', '%7D');

    ip_FRM.iwcgjqdt1.Text := lv_FN;

    ip_FRM.iwcgjqpdfvwr1.JQPDFViewerOptions.PDFFileName := lv_FN;

    ip_FRM.iwcgjqdlgx1.JQDialogOptions.Modal := False;

    lv_FRM1.iwcgjqdlgx1.AjaxReRender(True, False);



With this code is displays per Image1
Image1.png


When I drag on the dialog grip to resize the the PDF displays correctly per Image2
Image2.png


Please advise how I rectify this.

TIA
You do not have the required permissions to view the files attached to this post.
zsleo
 
Posts: 776
Joined: 03 Feb 2013 03:33

by Jorge Sousa » 25 Apr 2018 15:53

Hi

Please send us a test case, because our support model does not include the part of picking your code and mounting a demo
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by zsleo » 25 Apr 2018 20:24

Wow! Really?

I guess this is payback, hey Jorge.

Can you be a little more professional and at least look as though you are trying to provide support.

I can take the same approach as you with the same emotion outcome: You expect all your customers to pick apart your components because of lack of documentation

CGD has the power. It has a responsibility to wield it carefully.. :roll:
zsleo
 
Posts: 776
Joined: 03 Feb 2013 03:33

by Jorge Sousa » 25 Apr 2018 20:53

Hello

It's not emotional, this is the same practice we always had

About your comment about the other post i don't understand your point, but I understand mine !!!
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by zsleo » 07 May 2018 05:16

Background: I was calling for reports to be created via TCP/IP on another (internal) server. That sever returns a URLs for each of up to 9 reports. I was using a 100 msec iwtimer triggered from the callback to generate the reports.

Jorge advised that I MUST use the following code from the Components.pas of the CGD demo source.

Code: Select all
procedure TIWComponentForm.ShowFrame(AFrameClass: TIWCGFrameClass; AParams: TStringList);
var
  IsAsync: Boolean;
begin

  if not Assigned(AFrameClass) then Exit;

  CGJQTabs.ActiveTab:= IWCGTabDemo;

  IsAsync:= CGIsCallBackProcessing;
  if IsAsync then
  begin
    // SINCE THE FRAME IS GOING TO BE RENDERED BY AJAX, DON'T NEED TO GENERATE AJAX RESPONSE.
    CGCallBackDisableAjaxResponse;
  end;
  try
    CreateNewFrame(AFrameClass);
    FrameComp.ProcessCommand(0,AParams);
  finally
    if IsAsync then
    begin
      CGCallBackEnableAjaxResponse;
      RenderRegionAsync(JQRegContainer,rramOldMethod,True);
    end;

  end;
end;

I restructured my code to exactly implement the code extract and the PDFs are now displaying correctly.

Thank you Jorge.

I do not know why this, as opposed to my original code, works but it does.

Maybe CGD can provide an explanation - please.
zsleo
 
Posts: 776
Joined: 03 Feb 2013 03:33

by Jorge Sousa » 11 May 2018 11:56

Hi Leo

Maybe CGD can provide an explanation - please.


The explanation is either quite simple:

Intraweb doesn't allow the creation of new controls, and destruction on the fly in ajax events.

That's why we introduced the RenderRegionAsync / AjaxReRender method, a long time ago, that serves not only the purposes above, ie,

1-) adding new html and script to the current HTML page, when the controls are created in ajax events
2-) take care of the html removal and javascript objects destruction when the controls are destroyed in ajax events
and
3-) replace the whole html associated to a control, when their properties changes or methods called doesn't generate the javascript to perform the changes in the browser.

Since when we are in ajax mode, all controls are prepared to automatically generate javascript to a queue that will be executed in the browser, when the ajax event backs to it.
But, since we're going to generate the whole html/script, this behavior is not only unnecessary as it can be novice and generate javascript errors.

That's why we highly suggest, including in our demos, to call

CGCallBackDisableAjaxResponse

before any Control creation or destruction

CGCallBackEnableAjaxResponse

to put back the normal stage

and call RenderRegionAsync or SomeCGSomeControl.AjaxReRender = RenderRegionAsync(SomeCGSomeControl,

immediately.

I hope you can understand now, that was the only way we could find to implement this very important feature.
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to JQPrint

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.