6

I've found a solution by experiment (with a hat tip to @KeithC, who got me speculating on a productive path), but I don't understand why it works/the direct path doesn't work. I would be happy to accept an answer from anyone who's able to help me understand the principle behind the behavior. I was able to successfully complete the quote generation and ...


6

This is a salesforce native functionality. Just add Create PDF button in Invoice Layout. Added Images for your reference. As you don't mention previously that you want to use it for all object then i think it is URL Hack. https://ap1.salesforce.com/quote/quoteTemplateDataViewer.apexp?id=0Q090000000eeUa&headerHeight=10&footerHeight=10&summlid=...


6

What's your timeline? Winter 16 will allow getcontent from @future: http://docs.releasenotes.salesforce.com/en-us/winter16/release-notes/rn_apex_pagereference_getcontent.htm You can now make calls to the getContent() and getContentAsPdf() methods of the PageReference class from within asynchronous Apex such as Batch Apex, Schedulable and Queueable ...


4

getContentAsPDF actually internally performs a callout back into Salesforce as a new transaction. This means that the actual CPU time used for the primary transaction doesn't account for the time used generating the PDF, and it gets its own governor limits. Proof: Class public class vfWait5 { public vfWait5() { Long start = DateTime.now()....


4

The getContentAsPDF call operates in a separate transaction. So if you make that call from within the transaction that sets up the data, that getContentAsPDF call will not see the data at all as the transaction that sets up the data won't have committed. Making two sequential calls from the Lightning Component - one to setup the data and then after that one ...


4

Since backslashes are the escape character in Apex string literals, if you want a literal backlash, you need to escape it with a backslash. So the right regex to use would be \\{.*\\}


3

You're allowed a single queueable call per database execute method, so this code should technically work: // Must use Database.AllowsCallouts for PDF generation public with sharing class GenerateOnePDF implements Queueable, Database.AllowsCallouts { public void execute(QueueableContext context) { Blob v = Page.myPDFPage.getContentAsPDF(); ...


2

With Winter`16 release it would be resolved. Partners says: In the Winter '16 release, getContent() and getContentAsPDF() can be invoked from within Asynchronous Apex such as Batch Apex, Schedulable and Queueable classes, and @future methods. This provides an alternate solution for any partners impacted by the upcoming Critical Update and allows ...


2

If you add renderas="pdf" to the page, getContent will return a PDF of the page, and appears to still correctly throw an ExecutionException when the page throws an error (including uncatchable exceptions). If you are not able to change this attribute on the page itself, you can create a wrapper page and use apex:include to include your base page: ...


2

Its salesforce native functionality if you are familiar with salesforce CRM than whenever you create an invoice or quote under an opportunity than their is a button called create PDF to genrate invoices without any code


2

This has been answered before but I can't find a good example. The problem is that the getContentAsPdf call does not see the changes made because it runs in a separate transaction and the current transaction only commits at the end of the request which is after that call. The general solution is to move the getContentAsPdf to after the current transaction ...


1

Adjusting the time out won't help you; you're presumably running in to the CPU governor limit if you've gone more than 10 seconds. Your only choice is to optimize your page and/or controller in order to get under the 10 second limit.


1

Have you tried changing the font in the in-line CSS ? "style="font-family: 'Roboto', sans-serif;" Or recompiling the Apex class since that may be a java bug. https://bugs.openjdk.java.net/browse/JDK-8144703


1

To get around LockerService restrictions you can use a VisualForce page and then you can create the components from lightning. See this question for info on how to host lightning components in visualforce. From there as long as you use apex:includeScript (and URLfor if using a zipped static resource) to include jsPdf and html2canvas, you will be able to ...


1

Without seeing the design of your code, it's possible that either the results were not committed to the cache yet, the cache was invalidated for some reason, or the transaction exceeded the per transaction limits for writing to the cache. If the cache missed because it wasn't committed yet, you'll need to probably chain your Queueable until you can confirm ...


1

The reason your images aren't rendering is because they're not being uploaded as static resources. They can't be rendered to a PDF from an insecure link in they way you're attempting to it. Additionally, PageBlockSections are unsafe for rendering in PDF's. The way you're using them clearly isn't causing an issue, but if used in the way they're typically ...


1

As far as I know, rendering a Visualforce page as a PDF is a big pain. Salesforce uses flying saucer as its PDF generator engine and it have very much limitations. Visualforce PDF Rendering Considerations and Limitations lists the consideration and limitations you should keep in mind while trying to show Visualforce pages as PDF. Few points I like to ...


1

If you want to display VF page as pdf format then use renderAs Example.. <!-- Page: --> <apex:page renderAs="pdf"> <style> body { font-family: 'Arial Unicode MS'; } </style> <h1>Congratulations</h1> <p>This is your new PDF</p> </apex:page> // Note that if you have CSS and you want to render ...


1

Try setting the page size in the <style> tag: <style> @page { size: 8.5in 11in; margin:0.0in; /* PDF width, height, margin */ } </style>


1

Based on sfdcfox's idea and code, I've just tried this and it works: public class FireEventsBatchable implements Database.Batchable<Integer>, Database.AllowsCallouts, Database.Stateful { // Entry point public static void execute(String requestId) { if (requestId != null) { Database.executeBatch(new ...


Only top voted, non community-wiki answers of a minimum length are eligible