• 0 Points
  • Member since 2022

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
  • 2

I would like to avoid blank pages at the beginning and end of my PDF when I render a Visualforce page.

I can share code if needed !


Dear Team ,

Greetings !!!

I am performing REST API UsingWeather Example . M refering this website https://focusonforce.com/integration-and-data-loading/rest-api-using-weather-example/ . On my visual force m experiencing error . Plz have a look on my Code and snapshot .  I enable my API moreover configuration settings also i made . Plz help me to solve this issue .

User-added image
APEX Class :

public with sharing class testopenweather {

	public String city {get;set;}
	public String temp {get;set;}
	public String pressure {get;set;}
	public String humidity {get;set;}
	public String temp_min {get;set;}
	public String temp_max {get;set;}

	public testopenweather(ApexPages.StandardController stdController) {
		Account account = (Account)stdController.getRecord();
		account = [SELECT Id, ShippingCity FROM Account WHERE Id =:account.Id];
		//account = [SELECT Id, ShippingCity FROM Account WHERE Id ='0012v00002pNKoyAAG'];
		String accountCity = account.ShippingCity;
		String apiKey = '0284633ceb975c6164fa90f016d87e02';

		String requestEndpoint = 'http://api.openweather.org/data/2.5/weather';
		requestEndpoint += '?q=' + accountCity;
		requestEndpoint += '&units=metric';
		requestEndpoint += '&APPID=' + apiKey;
		Http http = new Http();
		HttpRequest request = new HttpRequest();
		HttpResponse response = http.send(request);

		// If the request is successful, parse the JSON response.
		if (response.getStatusCode() == 200) {

		   // Deserialize the JSON string into collections of primitive data types.
		  Map<string,object> results=( Map<string,object>)JSON.deserializeUntyped(response.getBody());
           // city=string.valueof(result.get('name'));
           city = String.valueOf(results.get('name')); 
             Map<string,object> mainresults=( Map<string,object>)(results.get('main'));
            temp = string.valueOf(mainresults.get('temp'));
             pressure = string.valueOf(mainresults.get(' pressure'));
             humidity = string.valueOf(mainresults.get('humidity'));
             temp_min = string.valueOf(mainresults.get('temp_min'));
             temp_max = string.valueOf(mainresults.get('temp_max'));
        else {
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Tere was an error');

Visual Force :

<apex:page standardController="Account" extensions="testopenweather" showHeader="false" sidebar="false">
    <apex:pageBlock title="{!city} Weather">


			<apex:outputText label="Temperature" value="{!temp}"/>
			<apex:outputText label="Pressure" value="{!pressure}"/>
			<apex:outputText label="Humidity" value="{!humidity}"/>
			<apex:outputText label="Minimum Temperature" value="{!temp_min}"/>
			<apex:outputText label="Maximum Temperature" value="{!temp_max}"/>

Thanks & Regards
Sachin Bhalerao
<apex:page showHeader="false"  controller="Controller004">
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'/>
h1{font-family: 'Oswald', sans-serif; text-decoration:none;}
<apex:pageBlock >
<apex:pageBlockSection title="Record of avalaible Doctors">
<apex:form >
<apex:pageBlockTable value="{!obj}" var="a">

 <apex:column headerValue="Name">
 <h1><apex:outputField value="{!a.Full_Name__c}" /></h1>
 <apex:column headerValue="Fee">
<h1><apex:outputField value="{!a.Fee__c}"/></h1>
<apex:column headerValue="Schedule">
<h1><apex:outputField value="{!a.schedule__c}"/></h1>
<apex:column >
<apex:image value="{!a.ImageUpload__c}" />
above is code of VF page
and controller of this page is:
global class Controller004{

public List<Doctor__c> obj{get;set;}
public Controller004(){
obj = [select Full_Name__c, Fee__c, schedule__c, ImageUpload__c from Doctor__c];