Skip to main content

#VfPage0 discussing

Static resources breaks in Visual Force Page rendered as PDF after changing a file inside the zip and re-uploading

 

I downloaded a working Static Resource used by a VF page and change an image, compressed the folder and re-upload again and ended-up with a not working VF page. None of the images were loading and the css not being applied.

 

I compared with other static resources and noticed a difference in the MIME type of file uploaded file.

The type of my re-uploaded zip file shows as "application/zip" vs the others showing as "application/x-zip-compressed". After many, but many posts reading, I realised this is not the root of the problem

 

Solution: When compressing the file, the individual folders inside the zip needs to be selected and compressed; whereas compressing the whole folder adds an extra folder to the path, breaking the link to the static resource from the VF page, eg.:

  • "myStaticResources.zip/myStaticResources/styles/style.css" instead of
  • "myStaticResources.zip/styles/style.css"

So the formula in the VF page: "{!URLFOR($Resource.myStaticResources, '/styles/style.css')}" won't work

 

Static resources breaks in Visual Force Page rendered as PDF after changing a file inside the zip and re-uploading I downloaded a working Static Resource used by a VF page and change an image, compres

 

Screenshot 2024-04-03 at 08.38.59.png

 

#VfPage  #Host Static Resource  #Upload Files  #Download Pdf  #Visualforce  #VisualForce Page  #Zip File

1 comment
  1. Jul 5, 2025, 7:31 PM

    OMG.  THANK YOU. 

    After hours of troubleshooting this, finally found your tip.  I was zipping up the folder also, and getting 404, pulling my hair out.  lol.  finally fixed.

0/9000

Question:-  How can we apply SLDS and custom CSS to a Visualforce page that is rendered as a PDF?

 

Solution:-

 

To use any standard or custom style on the Visualforce page, we need to download the style sheet file and upload it as a static resource. Then we can import the file into the Visualforce page using the <apex:stylesheet > tag.

 

SLDS and custom CSS are uploaded in the static resource.

 

#Salesforce #Salesforce Developer #Communities #VfPage #Visualforce #Pdf Version #VisualForce Page #Pdfview #Short Code

<apex:page renderAs="pdf" docType="html-5.0">

<apex:stylesheet value="{!$Resource.sldsCss}" />

<apex:stylesheet value="{!$Resource.customCSS}" />

</apex:page>

0/9000

Hello Trailblazers,

 

I hope this communication finds you well.

 

Is there any way we can distribute LWC with Login Flows?

 

Thanks in advance.

 

Regards,

Omprasad

 

#Lightning Web Components   #VfPage #Visualforce #Visualforce For Lightning

2 answers
  1. Feb 22, 2024, 1:01 PM

    Yes, we can distribute LWC with Login Flow. This feature allows seamless integration of Lightning Web Components into the login process, enhancing user experience. Whether you're a student looking to study in Canada or an administrator managing login flows, this functionality offers flexibility and efficiency in implementing custom authentication processes.

     

    Regards: study in canada

0/9000