function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Semih Yıldız 7Semih Yıldız 7 

zero margin

Hello Everyone,

I am trying to create pdf file in salesforce. But I have image and need to put this image with zero margin in the left side . 

 @page {
            margin-left:  0cm;
            margin-right: 2.54cm;
}

I wrote this css style , it doesn't work.

Thank you .
Best Answer chosen by Semih Yıldız 7
Lokesh KumarLokesh Kumar
Hi,

Kindly use the below updated code However you can add your controller.
 
<apex:page showHeader="false" renderAs="pdf" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
    <html>
        <head>
            <style>
                @page {
      					margin-top: -0.3in;
                		margin-left: -0.3in;
                }
                 </style>
         </head>
         <body>
             
        
    <div class="header">
        <apex:image value="{!URLFOR($Resource.logo)}"  width="50%" height="50%"  />
        <br/>
        <br/>
    </div> 
           
        </body>  
    </html>
</apex:page>

Output :

User-added image

-Lokesh

All Answers

Lokesh KumarLokesh Kumar
Hi Semih,

Kindly check this link http://www.antennahouse.com/CSSInfo/CSS-Page-Tutorial-en.pdf and get appropriate styling as per your requirement and do let me know if you have any concern.

-Lokesh

 
Semih Yıldız 7Semih Yıldız 7
Hi Lokesh , 

I looked this document before your answer. Unfortunately , I couldn't find anything. There is always a margin in pdf.
Semih Yıldız 7Semih Yıldız 7
@Lokesh
Yes, I checked . As you see , <p> doesn't have a margin but in the picture , p has a margin. I don't want this margin.
Lokesh KumarLokesh Kumar
Can you paste your code so that I can debug more? 
Semih Yıldız 7Semih Yıldız 7
<apex:page standardController="XtEklSpotQuotation__c" showHeader="false" renderAs="pdf"  extensions="XtEklSpotQuoteVfc"  standardStylesheets="false" docType="html-5.0" applyHtmlTag="false" applyBodyTag="false"> 
    <head>
        <style>
           
            @page {
            /* Landscape orientation */
            /*size:landscape;*/
            //margin-top: 100px;
            //margin-bottom:80px;
            size:portrait;
            margin-left:  2.54cm;
            margin-right: 2.54cm;
            /*margin-top: 2.54cm;*/
            margin-top: 3.20cm;
            /*margin-bottom: 2.54cm;*/
            margin-bottom: 3.00cm;
            /* Put page numbers in the top right corner of each
            page in the pdf document. */
            @bottom-right {
            content: "Page " counter(page) " of " counter(pages);
            }
            @top-center {
            content: element(header);
            }
            @bottom-left {
            content: element(footer);
            }
            }
            
            
            
            
        </style>
        
    </head>
    
    <div class="header">
        <apex:image value="{!URLFOR($Resource.newlogo4)}"  width="50%" height="50%"  />
        <br/>
        <br/>
    </div> 

</apex:page>


This is my code.
Lokesh KumarLokesh Kumar
Hi,

Kindly use the below updated code However you can add your controller.
 
<apex:page showHeader="false" renderAs="pdf" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false">
    <html>
        <head>
            <style>
                @page {
      					margin-top: -0.3in;
                		margin-left: -0.3in;
                }
                 </style>
         </head>
         <body>
             
        
    <div class="header">
        <apex:image value="{!URLFOR($Resource.logo)}"  width="50%" height="50%"  />
        <br/>
        <br/>
    </div> 
           
        </body>  
    </html>
</apex:page>

Output :

User-added image

-Lokesh
This was selected as the best answer
Semih Yıldız 7Semih Yıldız 7
Thanks Lokesh , I didn't think negative values :) It works
Lokesh KumarLokesh Kumar
cheers !!