How can I generate and download a pdf file in WebDynpro for ABAP? - pdf

I've got a task to create a webdynpro that given some inputs, can generate a pdf file with questions and the user should be able to download it somewhere. My question is, how can i generate a PDF in WDs and how do i prompt the download?

I do not know how to do it with Adobe Forms but I surely have seen that done using SmartForms.
When you execute the function module assigned to a smartform there is an EXPORTING parameter for it job_output_info.
With this parameter you execute then the function module CONVERT_OTF with following parameters.
EXPORTING
format = 'PDF'
IMPORTING
bin_file = e_file_as_xstring
TABLES
otf = job_output_info-otfdata[]
lines = lt_pdf_file_lines
Then if you are using WebDynpro for ABAP use the following method to let the user download the file.
wdr_task=>client_window->client->attach_file_to_response(
i_filename = 'Filename.pdf'
i_content = e_file_as_xstring
i_mime_type = 'pdf/application'
)
Not sure how it might work with Adobe Forms, but if you are able to generate the OTF content you should be able to do it as well. On the other hand maybe you are just able to get the PDF as xstring, then the OTF part will not be needed at all.
Maybe this article will help you to know how convert the Adobe Form to xstring: Getting a PDF in an xstring format in the ABAP environment

Related

How can i generate and download PDFs in Flask without saving them in my Webapp?

im trying to get a PDF with the ReportLab Module which works fine so far. My problem is that im saving the PDF with the .build()-method in my Webapps directory. What i want is that i can send the PDF for downloading without saving it before. That is somehow possible with the wkhtmltopdf module, but i dont want to use any other servers for this.
The process would be like: User presses a button 'download as pdf', a pdf is generated and instant returned as a download without saving it first.
Do you know if this is possible?
You want to create the PDF server side, return it to the client, without saving the PDF (for example, in S3)?
Yes, this is possible, you create the PDF in memory using
buffer = io.BytesIO()
myPDF = canvas.Canvas(buffer, pagesize=letter)
Then after creating your pdf you save it using
myPDF.save()
buffer.seek(0)
Then when you are ready to return the PDF as a reponse you can return it with:
response = HttpResponse(buffer, content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="{}"'.format("myFile.pdf")
return response

Render HTML or GSP as a PDF and save it on server

I have an html template which I need to render as a .PDF and then save that pdf file on server. I'm using "rendering" plugin of grails. I'm able to render file as PDF but I don't understand how to save it on server location and not on user's system. Can anybody please help me ?
The pdfRenderingService provided by the plugin allows you to call render and get back an OutputStream. Using that output stream you can write that to a file on your server. The documentation explains the basics of using the service.
Your code may look something like this:
new File("report.pdf").withOutputStream { outputStream ->
outputStream << pdfRenderingService.render(template: '/report/report', model: [serial: 12345])
}
Well, actually I changed my plugin. Got Wkhtmltopdf plugin of grails more helpful. you can find it here --
https://github.com/quorak/grails-wkhtmltopdf
Also instructions regarding using this plugin you can find on the same link or here --
[https://github.com/quorak/grails-wkhtmltopdf]
Using this you can get "bytes" which you can write to file system.

Saving pdf in the background using html2pdf

Am tryng to automatically generate pdfs using html2pdf class. I got the following code which is working fine, only that someone has to save the pdf manually. However, Whenever a new product is added, I would like to automatically save the pdf to some folder without user intervention, and store this value in a database for future reference.
How do I go about saving the pdf 'silently' i.e. in the background without showing any popups or requiring the user to intervene?
Thanks in advance.
include('pdf_content.php');
$content = ob_get_clean();
// convert to PDF
require_once('html2pdf/html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'en');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
//$html2pdf->Output($file_name.'_'.date("dmY").'.pdf');
$html2pdf->Output($product_id.'_'.$file_name.'_'.date("dmY").'.pdf');
You can try calling this script everytime a new product is added, although then you wouldn't really do it in the "background"...
For more information, please note the question "How can I run a PHP script in the background after a form is submitted?"
EDIT:
If you wish to save the file on the server instead of outputting it to the browser, you can use different parameters. See also the html2pdf-wiki. Be aware that you cannot save the file on the user's computer unnoticed!
$html2pdf->Output('directory/file_xxxx.pdf', 'F');

Photoshop CS4 variable relative path not working

In Adobe Photoshop CS4, I'm trying to use variables and data sets to dynamically replace images listed on a .csv file.
When I tried to use the relative path of the images, the program throws an error "Could not apply data set because the replacement file was not found"
But according to an article in the adobe website, it should work.
Can anyone help?
Most of the time this kind of errors comes from the fact that ExtendScript is struggling with backslashes. Makes sure you escape your paths before using them. Or convert them to forward slashes:
var cleanFilePath = myFilePath.replace(/\\/g, "/");

How to create pdf file from Qt application?

In my Qt application I am conducting some network tests. I have to create a report according to the test output. So I need to create the report in pdf format.
Can anybody please let me know how I can put my test results in a pdf file? My result contains graphs using the Qwt library.
this code outputs pdf from html:
QTextDocument doc;
doc.setHtml("<h1>hello, I'm an head</h1>");
QPrinter printer;
printer.setOutputFileName("c:\\temp\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
doc.print(&printer);
printer.newPage();
I guess you can generate an html wrapper for your img and quickly print your image. Otherwise you might copy the image directly on the printer, since it is a paint device in a similar fashion
QPrinter printer;
QPainter painter(&printer);
printer.setOutputFileName("c:\\temp\\file.pdf");
printer.setOutputFormat(QPrinter::PdfFormat);
painter.drawImage(QRect(0,0,100,100), <QImage loaded from your file>);
printer.newPage();