I am using laravel-snappy to generate pdfs and show them in the browser. I am getting a blank page in return.The code I am using is this.
return PDF::loadView('emails.flightInvoice', $data)->inline();
I used the below code to save the PDF and it is working.
PDF::loadView('emails.flightInvoice', $data')->save('invoice.pdf');
can anyone please help me with this?
The inline() method requires a filename
Try
return PDF::loadView('pdf.invoice', $data)->inline('filename.pdf');
Related
I'm currently trying to send an image through JDA but can't get it to work. The only thing I can find on Google is the addFile (java.io.File) method, which is no longer available in the most recent version of JDA. I am currently struggling to find a solution using the addFiles() method.
This is my current attempt.
byte[] buffer = ((DataBufferByte)(img).getRaster().getDataBuffer()).getData();
FileUpload upload = new FileUpload(new ByteArrayInputStream(buffer));
c.sendMessage("Image:").addFiles(upload).complete();
I am getting this error message in my IDE, but I don't know what to make of it.
thanks guys.
You have to use the factory method FileUpload.fromData:
FileUpload upload = FileUpload.fromData(buffer, "image.png");
Make sure you properly encode the image to something like JPG or PNG, otherwise this will not work.
iam new here and hope someone can help me out.
iam trying to convert a html string to a pdf version in net5. We had it running in net core 2.2 without any problems. Now we are trying to migrate everything to net5. Well the only part which is not working anymore is converting html string to pdf document.
We are using following nuget package: Select.HtmlToPdf.NetCore
As soon we try the convert the html string with "ConvertHtmlString" we get following Exception.
System.ArgumentNullException: 'Value cannot be null. Arg_ParamName_Name'
here is a simple snippet to repdoruce the problem:
var htmlString = "<html><head></head><body>Test me out!</body></html>";
var converter = new HtmlToPdf();
converter.Options.PdfPageSize = PdfPageSize.Letter;
converter.Options.AutoFitWidth = HtmlToPdfPageFitMode.AutoFit;
converter.Options.AutoFitHeight = HtmlToPdfPageFitMode.AutoFit;
converter.Options.PdfPageOrientation = PdfPageOrientation.Landscape;
SelectPdf.PdfDocument doc = converter.ConvertHtmlString(htmlString);
doc.Save("C:\\Temp\\test.pdf");
doc.Close();
Thanks.
Regards Maik
Ok thx for the hint in the comment..
before i posted my question i did some standard stuff i always do before researching deeper..
Clean solution, restarted VisualStudio and so on.. nothing worked.
Ive checked my nuget packages and i had the correct one installed.
I removed the package and reinstalled it again and well it works now. Cant exactly say what the problem was but.. it works now.
I'm running Apex 19.2.
I have a pdf stored as blob file in a table. I'm trying to download the blob in a page process.
The process works fine however, the file doesn't download but gets displayed in the browser instead.
Can anyone help please ? I need the file to download and not show in the browser...
Here is my code :
File Blob; -- Blob content is set somewhere else...
sys.HTP.init;
sys.OWA_UTIL.mime_header(MimeType, FALSE);
sys.HTP.p('Content-Length: ' || DBMS_LOB.getlength(File));
sys.HTP.p('Content-Disposition: filename="report.pdf"');
sys.OWA_UTIL.http_header_close;
sys.WPG_DOCLOAD.download_file(file);
apex_application.stop_apex_engine;
Thanks,
Cheers,
Change this line:
sys.HTP.p('Content-Disposition: filename="report.pdf"');
To this:
sys.HTP.p('Content-Disposition: attachment; filename="report.pdf"');
By default this is an individual browser setting, a preference configurable by end users.
https://www.makeuseof.com/tag/download-pdf-files-chrome/
https://answers.microsoft.com/en-us/edge/forum/all/how-to-change-microsoft-edge-to-download-pdf-files/b24dc4b7-14b5-4fe4-85ac-71e28953635e
https://support.mozilla.org/en-US/questions/985483
It does appear that it can be forced through the link/URL that generates the PDF:
Force to open "Save As..." popup open at text link click for PDF in HTML
I am trying to display a file stored in storage folder using laravel's response helper. Unfortunately, every time it runs, the file is DOWNLOADED, not DISPLAYED. Below is my code:
public function viewDoc($id)
{
$a = pro_doc::findorfail($id);
$path = storage_path('documents/'.$a->file_name);
if ( ! File::exists($path) ) {
abort(404);
}
return response()->file($path);
}
Im sending an id to the controller, which looks up the record and gets the file name, then attempts to open the file in a new window (this is from a link with a blank target). A new window momentarily opens, then the download begins and the window closes.
The documentation (https://laravel.com/docs/5.4/responses#file-responses) seems to say this shouldn't happen
The file method may be used to display a file, such as an image or PDF, directly in the user's browser instead of initiating a download.
Can anyone help me make this work? Again, Im trying to get it to open in the browser window, not download. Thank you!
I'm trying to download the XLS file from this page: http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/ALL1/Hourly/ (click on "Export to XLS" link).
However doing:
page.getAnchorByText("Export to XLS").click().getWebResponse().getContentAsStream();
returns the html of the web page, instead of the expected file.
Do you have any suggestion?
I already tried the 3 points here http://htmlunit.sourceforge.net/faq.html#AJAXDoesNotWork without success.
The following:
webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
fixed my issue.