Error while opening PDF attachment sent via mail
Hi,
I am attaching PDF file to PO in me22n and sending the same file as attachment in the mail to the vendor using class CL_BCS.
The mail is sent to the vendor successfully and they are able to successfully open the PDF attachment. But in some cases the mail is successfully received but while opening the attachment it is giving the error as file is corrupted.
Please help me to resolve this issue.
Thanks and regards,
Jayashree
Hi,
I would like to know what font type, you are using in the forms.
Ideally it should be HELVETICA .
If you are using any other font in your style/form,try changing it to HELVETICA & Test.
Also Check the OTF data at the call of gen. FM,before converting it to PDF.
Regds,
AS
Edited by: abheesawant on Oct 12, 2011 7:48 AM
Similar Messages
-
Error while openeing PDF attachment sent thru smartform
Hi,
I have tried all the options and also gone thru all the quries and replies in SDN but could not find answer for this.
I have developed a smart from with some table fetch data from PAYR. Now i have written an ABAP code to sent the output of a smartform as PDF in the email.
Im getting an error "There was an error openeing htis doc and file is damaged and coul dnot be repaired".
Here is my code.
CLEAR WA_BUFFER.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
CLEAR: I_RECORD. REFRESH: I_RECORD.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
I_OBJBIN] = I_RECORD[.
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 1.
I_OBJPACK-BODY_START = 1.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-DOC_SIZE = ( v_lines_bin - 1 ) * 255 + strlen( i_objbin ).
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'smart'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
I_RECLIST-RECEIVER = 'ABC.gmail.com'.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
IF SY-SUBRC 0.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF.
Pls help me in sloving out this.
Thanks.Sounds familiar but not sure. Have you tried using OTF format in stead of PDF and in the file name use document.pdf??
-
Error while Opening PDF attachment from Mail
Hi,
We two Output Types created ZNEU and ZAUF. Two Smartforms are created for the same Output Types. The Issue now is, When ZNEU triggers and send a mail the document is properly decoded and gets opened but for ZAUF it doesn't. It says File damaged.
This is the code we have used for sending mail.
CONSTANTS:
co_pdf(3) TYPE c VALUE 'PDF',
co_raw(3) TYPE c VALUE 'RAW'.
DATA:
it_objbin TYPE STANDARD TABLE OF solisti1,
wa_objbin TYPE solisti1.
DATA:
lv_filesize TYPE i.
DATA:
it_lines TYPE STANDARD TABLE OF tline.
DATA:
wa_mail_body TYPE solisti1,
wa_receipients TYPE somlreci1.
DATA:
document TYPE REF TO cl_document_bcs,
content TYPE solix_tab,
wa_content TYPE solix,
send_request TYPE REF TO cl_bcs,
sender TYPE REF TO if_sender_bcs,
recipient TYPE REF TO if_recipient_bcs,
requested_status TYPE REF TO bcs_rqst,
status_mail TYPE bcs_stml,
bcs_exception TYPE REF TO cx_bcs,
lv_rec TYPE adr6-smtp_addr.
DATA:
wa_attachx TYPE solix,
l_pdf_len TYPE i,
l_con_len TYPE i,
l_pdf_pos TYPE i,
l_con_pos TYPE i.
FIELD-SYMBOLS: <fs_con> TYPE x.
CLASS cl_cam_address_bcs DEFINITION LOAD.
CLASS cl_abap_char_utilities DEFINITION LOAD.
* Get the PDF version of the OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_filesize
TABLES
otf = job_output_info-otfdata
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Convert the PDF format to the table type required for the attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = it_lines
t_target_tab = it_objbin
EXCEPTIONS
convert_not_possible = 1
OTHERS = 2.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Convert the data which is in text to binary
l_con_pos = 0.
DESCRIBE FIELD wa_objbin LENGTH l_pdf_len IN BYTE MODE.
DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
LOOP AT it_objbin INTO wa_objbin.
ASSIGN wa_objbin TO <fs_con> CASTING.
CHECK sy-subrc EQ 0.
DO l_pdf_len TIMES.
l_pdf_pos = sy-index - 1.
IF l_con_pos = l_con_len.
APPEND wa_attachx TO content.
FREE wa_attachx.
l_con_pos = 0.
ENDIF.
MOVE <fs_con>+l_pdf_pos(1) TO wa_attachx-line+l_con_pos(1).
ADD 1 TO l_con_pos.
ENDDO.
ENDLOOP.
IF l_con_pos > 0.
APPEND wa_attachx TO content.
ENDIF.
TRY .
* -------- create persistent send request ------------------------
send_request = cl_bcs=>create_persistent( ).
* -------- create and set document with attachment ---------------
* create document from internal table with text
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = mail_body_tab
i_subject = email_subject ).
* add attachment to document
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = attachment_name
i_att_content_hex = content.
* add document to send request
CALL METHOD send_request->set_document( document ).
* Set sender
sender = cl_cam_address_bcs=>create_internet_address( sender_id ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
* Receipients
LOOP AT receipients_tab INTO wa_receipients .
lv_rec = wa_receipients-receiver.
recipient = cl_cam_address_bcs=>create_internet_address( lv_rec ).
* Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient.
ENDLOOP.
* Set that you don't need a Return Status E-mail
status_mail = 'N'.
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = 'N'
i_status_mail = status_mail.
* set send immediately flag
send_request->set_send_immediately( 'X' ).
* Send document
CALL METHOD send_request->send( ).
* COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
RAISE EXCEPTION bcs_exception.
ENDTRY.
This is in a Class which is been used in the print program for both the Output Types.
Can somebody throw light upon this.
Note: I tried using
but it is not working properly.
Thanks,
Prashanth
Edited by: Prashanth KR on Jan 5, 2010 6:20 AMHi,
Please paste the part of code where you are getting error.
And if you are not clear about where the error is, try searching sdn or google with the error message that you are getting as this issue has been discussed many times earlier.
Check this link.
Error while opening PDF in mail attachment
Hope it helps.
Regards,
Raj -
Error in opening PDF attachment sent using SO_DOCUMENT_SEND_API1
Hi all,
I am converting script to PDF using FM 'SX_OBJECT_CONVERT_OTF_PDF'. Using this table i am trying to send it as a attachment to mail id. I am able to send the attachment successfully, but not able to open the attachment.
It is giving error as 'Adobe Reader could not open file because it is either not supported file type or because the file has been damaged'.
I tried seaching on SDN, but did not get useful answer.
Can you please help me in resolving this error?
Thanks,
ArchanaGood day Archana,
This is the same problem we have encountered, this has started after adding a patch.
After doing so much R & D we could not do it. We have written a mail to SAP and they
have instructed the basis consultant to follow certain procedure and finally the issue is
solved.
I suggest you to consult basis consultants.
Regards and Best wishes. -
Error while opening the ADOBE FORM via mail
Hi to all,
I have created a program to attached ADOBE FORM to mail.
When I execute the program, it sends ADOBE FORM to my mail ID successfully.
But when I open my mail and try to open attached ADOBE FORM, it gives error
ADOBE READER COULD NOT OPEN u2018PDF FORM (1). PDFu2019 because it is either not a supported file type or because the file has been damaged ( for example, it was sent as an email attached and wasnu2019t correctly decoded).
Please can any tell me, what the problem is and what the solution is for that?
I shall be thankful to you for this.
Regards
Pavneet Rana
Edited by: pavneet rana on Aug 1, 2011 2:22 PMThanks for reply,
below is the code.
data:
l_fm_name TYPE rs38l_fnam,
l_formname TYPE fpname VALUE 'ZTESTF1' ,
fp_docparams TYPE sfpdocparams,
FP_FORMOUTPUT TYPE FPFORMOUTPUT,
fp_outputparams TYPE sfpoutputparams.
data: I_ATT_CONTENT_HEX type SOLIX_TAB.
START-OF-SELECTION.
data: st TYPE ZTABFM11.
data: it type table of sflight.
data: wa like LINE OF it.
data: wa_st like LINE OF ST.
fp_docparams-langu = 'E'.
fp_docparams-country = 'US'.
fp_docparams-fillable = 'X'.
fp_outputparams-nodialog = 'X'.
fp_outputparams-preview = 'X'.
fp_outputparams-device = 'LP01'.
fp_outputparams-getpdf = 'X' .
fp_outputparams-dest = 'LP01'.
fp_outputparams-reqimm = 'X'.
fp_outputparams-reqdel = 'X' .
fp_outputparams-xfpoutdev = 'LP01'.
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = l_formname
IMPORTING
e_funcname = l_fm_name.
E_INTERFACE_TYPE =
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = fp_outputparams
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
select * from sflight into TABLE it.
loop at it into wa.
wa_st-CARRID = wa-CARRID.
wa_st-CONNID = wa-CONNID.
wa_st-FLDATE = wa-FLDATE .
wa_st-PLANETYPE = wa-PLANETYPE.
append wa_st to st.
endloop.
CALL FUNCTION l_fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
st = st
IMPORTING
/1BCDWB/FORMOUTPUT = FP_FORMOUTPUT
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4
CALL FUNCTION 'FP_JOB_CLOSE'
IMPORTING
E_RESULT = result
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = FP_FORMOUTPUT-PDF
APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH =
TABLES
BINARY_TAB = I_ATT_CONTENT_HEX .
CLASS cl_bcs DEFINITION LOAD.
DATA:
lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
lo_send_request = cl_bcs=>create_persistent( ).
Message body and subject
DATA:
lt_message_body TYPE bcsy_text VALUE IS INITIAL,
lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
APPEND 'Dear,' TO lt_message_body.
append ' ' to lt_message_body.
APPEND 'Fill the details.'
TO lt_message_body.
append ' ' to lt_message_body.
APPEND 'Thank You,' TO lt_message_body.
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_message_body
i_subject = 'flight details' ).
DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
TRY.
lo_document->add_attachment(
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'flight details'
I_ATTACHMENT_SIZE =
I_ATTACHMENT_LANGUAGE = SPACE
I_ATT_CONTENT_TEXT =
I_ATTACHMENT_HEADER =
I_ATT_CONTENT_HEX = I_ATT_CONTENT_HEX ).
CATCH cx_document_bcs INTO lx_document_bcs.
ENDTRY.
Add attachment
Pass the document to send request
lo_send_request->set_document( lo_document ).
Create sender
DATA:
lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
l_send type ADR6-SMTP_ADDR value 'mail id '.
lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
lo_sender = cl_sapuser_bcs=>create( sy-uname ).
Set sender
lo_send_request->set_sender(
EXPORTING
i_sender = lo_sender ).
Create recipient
DATA:
lo_recipient TYPE REF TO if_recipient_bcs VALUE IS INITIAL.
lo_recipient = cl_sapuser_bcs=>create( sy-uname ).
lo_recipient = cl_cam_address_bcs=>create_internet_address( l_send ).
Set recipient
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient
i_express = 'X' ).
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient
i_express = 'X' ).
Send email
DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
lo_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = lv_sent_to_all ).
COMMIT WORK.
message 'Form sucessfuly send to person' type 'I'.
plesase can any one, provide the soultion.
i shall be thankful toy you for this.
regards
pavneet rana -
I cannot open PDF filkes sent via email. I used too. nHow do I fix.
Cannot open PDF files sent via email. The open via Word in encripted jinerish. This has not happend until now.
CiroI had the same problem. My version of RoboHelp is pretty old (x5) and the problem was with pdfs made up in version 9. Some pdfs would open and some would not. It depended on the version used to make the pdf. Got error messages and corrupted file messages.
I solved the problem by using the full version of Acrobat and using the pdf Optimizer to make compatible with version 5( just to make sure).
Another option is to "print" to the pdf printer when the file is open.
Both then can be imported into RoboHelp without a problem
Hope this helps. It ruined many days at work for me while I tried to figure out what on earth I was going to do.
Holly -
After Downloading, Error while opening PDF : PDF has no pages
After Downloading, Error while opening PDF : PDF has no pages
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = L_SPOOLNO
NO_DIALOG = SPACE
DST_DEVICE = MSTR_PRINT_PARMS-PDEST
IMPORTING
PDF_BYTECOUNT = MI_BYTECOUNT
TABLES
PDF = MTAB_PDF
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
Thanks in advance
Monika
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11
OTHERS = 12.
Transfer the 132-long strings to 255-long strings
LOOP AT MTAB_PDF.
TRANSLATE MTAB_PDF USING '~'.
CONCATENATE WA_BUFFER MTAB_PDF INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
it_attach = WA_BUFFER.
APPEND it_attach.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
****GET THE FILE NAME TO STORE....................
v_path = 'C:\PD Form\' .
CONCATENATE v_path p_pernr-low '.pdf' into v_name.
create object v_guiobj.
call method v_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = v_name
file_filter = v_filter
CHANGING
filename = v_name
path = v_path
fullpath = v_fullpath
user_action = v_uact.
if v_uact = v_guiobj->action_cancel.
leave to current transaction.
endif.
..................................DOWNLOAD AS FILE....................
move v_fullpath to v_filename.
call function 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = MI_BYTECOUNT
filename = v_filename
filetype = 'BIN'
TABLES
data_tab = it_ATTACH
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.My Generated Spool request is PDF Spool. It contains Adobe Forms data. To Download Adobe form
Spool (PDF Spool) into PDF format,
First,
A) Read PDF Spool data by using u2018FPCOMP_CREATE_PDF_FROM_SPOOLu2019 Function module.
B) Assign the Output Data to XSTRING format
C) Convert that XSTRING data to Binary Format using 'SCMS_XSTRING_TO_BINARY' Function module.
D) Save File on Application server using OPEN DATASET , TRANSFER , CLOSE DATASET.You can see your
downloaded file in Transaction AL11 in specified directory.
You can save your file on Presentation server also using GUI_DOWNLOAD.
First three steps are necessary if your spool is PDF Spool.
Basically we need this when we are downloading Adodbe forms ( which is not a SAPScript or smartforms)
Example :
DATA :
e_pdf1 TYPE fpcontent,
e_renderpagecount1 TYPE i.
CALL FUNCTION 'FPCOMP_CREATE_PDF_FROM_SPOOL'
EXPORTING
i_spoolid = l_spoolno
i_partnum = '1'
IMPORTING
e_pdf = e_pdf1
e_renderpagecount = e_renderpagecount1
* E_PDF_FILE = E_PDF_FILE1
* EXCEPTIONS
* ADS_ERROR = 1
* USAGE_ERROR = 2
* SYSTEM_ERROR = 3
* INTERNAL_ERROR = 4
* OTHERS = 5
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DATA : buffer TYPE xstring,
append_to_table TYPE c.
DATA : output_length TYPE i.
TYPES : BEGIN OF ty_binary,
binary_field(1000) TYPE c,
END OF ty_binary.
DATA : lt_binary TYPE TABLE OF ty_binary WITH HEADER LINE.
DATA : lv_xstring TYPE xstring.
lv_xstring = e_pdf1.
* Convert xstring to binary.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xstring
append_to_table = ' '
* IMPORTING
* OUTPUT_LENGTH =
TABLES
binary_tab = lt_binary.
DATA : wa_binary LIKE lt_binary.
DATA: BEGIN OF itab OCCURS 0,
field(256),
END OF itab.
DATA: dsn(50000) VALUE '/usr/sap/tmp/',
length LIKE sy-tabix,
lengthn LIKE sy-tabix.
CONCATENATE '/usr/sap/tmp/' lv_pernr '.pdf' INTO dsn.
******* Save file on Application server
OPEN DATASET dsn FOR OUTPUT IN BINARY MODE.
LOOP AT lt_binary.
TRANSFER lt_binary-binary_field TO dsn.
ENDLOOP.
CLOSE DATASET dsn.
CLEAR lt_binary.
REFRESH lt_binary.
cheers -
Error while opening PDF in mail attachment
Hi All,
In smartform i am sending a mail with attachemnt as PDF file,there is one more option like preview of smartform .
issue is like i am able to see the preview of the same record but when it is sent in mail attachement,and while opening PDF its showing error that file can not be open it is corrupted.
Please help.
Mona Singh.Dear Sandra
That was my problem: binary data was incorrectly converted (often because of Unicode systems).
I returned
bin_filesize = v_len_in
bin_file = l_binfile
from the function module CONVERT_OTF, then converted the xstring data (l_binfile) into an internal table (t_objbin) to send to the mail send function with the following function module:
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = l_binfile
IMPORTING
output_length = v_lines_bin
TABLES
binary_tab = t_objbin.
Many thanks for your help.
Best regards
Patricia -
Cannot open PDF attachment in webmail sent from Outlook, says I need to save first; how do I save the link?
Looks like another user asked similar question with over 600 views and no replies ... hmmm. When I click on the attachment, it says I must save it to my disk; with one button mouse just click once and save? I've tried dragging and saving the attachment to word doc but opened up with a page of garbled words/symbols,etc. Any ideas are welcome.
-
Getting error while opening pdf on server
Dear All,
I am working on jdeveloper 11.1.1.4.0.
I have a use case where on click of link , generating a dynamic pdf. The pdf i am arranging with the help of itext through backing bean. It is generating as well downloading the pdf.I have used filedownloadlistner to call the generate and download pdf methods.
On integrated weblogic server the pdf is working fine, but when i deploy on server while opening pdf getting error :
*"Adobe Reader could not open 'test.pdf' beacause it is either not a supported file type*
*or because the file has been damaged (for example, it was sent as an email attachment and*
*wasn't correctly decoded)."*
I am not able to get the root cause for the problem. The sample code to generate and download pdf is :
// Generate PDF
private void generatePDFFile(FacesContext facesContext,
java.io.OutputStream outputStream) {
try {
System.out.println("In Generate PDF................");
Document document = new Document(PageSize.A4);
PdfWriter.getInstance(document, new FileOutputStream(FILE));
document.open();
addMetaData(document);
addTitlePage(document);
document.close();
System.out.println("End of PDF......................");
facesContext = facesContext.getCurrentInstance();
ServletContext context = (ServletContext)facesContext.getExternalContext().getContext();
System.out.println(context.getRealPath("/"));
String FILE = "test.pdf";
File file = new File(FILE);
FileInputStream fdownload;
//BufferedInputStream bis;
byte[] b;
System.out.println(file.getCanonicalPath());
System.out.println(file.getAbsolutePath());
fdownload = new FileInputStream(file);
int n;
while ((n = fdownload.available()) > 0) {
b = new byte[n];
int result = fdownload.read(b);
outputStream.write(b, 0, b.length);
if (result == -1)
break;
outputStream.flush();
} catch (Exception e) {
e.printStackTrace();
Download PDF
private void downloadPDF(FacesContext facesContext, java.io.OutputStream outputStream) {
try {
facesContext = facesContext.getCurrentInstance();
ServletContext context = (ServletContext)facesContext.getExternalContext().getContext();
ExternalContext ctx = facesContext.getExternalContext();
HttpServletResponse res = (HttpServletResponse)ctx.getResponse();
res.setContentType("application/pdf");
outputStream = res.getOutputStream();
System.out.println(context.getRealPath("/"));
File file = new File(FILE); // FILE = 'test.pdf'
FileInputStream fdownload;
// BufferedInputStream bis;
byte[] b;
fdownload = new FileInputStream(file);
//bis = new BufferedInputStream (new FileInputStream(file));
int n;
while ((n = fdownload.available()) > 0) {
b = new byte[n];
int result = fdownload.read(b);
//outputStream.write(b, 0, b.length);
outputStream.write(b, 0, b.length);
if (result == -1)
break;
outputStream.flush();
outputStream.close();
fdownload.close();
} catch (Exception e) {
e.printStackTrace();
Any help will be appreciated.
Thanks
KanikaIf the pdf file don't open on the server where you created them, they won't open on the client side either.
The code you are using should be refactored to use different file names for the generated files. In a multi user environment (which every web application is) you overwrite the file generated with each new request, even before the file is loaded by a client. This will corrupt the file a client is loading and you get the error you see.
Next I would look into org.apache.commons.io package (http://commons.apache.org/io/) which has utility classes which allows easy handling of streams without looping over the data.
Timo -
Error while opening .PDF files in document library sharepoint 2013
Hi
I am getting an error while opening a .pdf file,
Please help me find the solution.
Thanks
ParuLaunch IE -> Click on Gear (settings) -> Manage Add-ons -> Show: All Add-ons ->
There are 2 Adobe Add-ons:
Adobe PDF Reader & Adobe Acrobat Sharepoint Open Document
Double-click both and be sure to click the button "ALLOW ON ALL SITES"
(An * will appear in the field)
http://crowdsupport.telstra.com.au/t5/T-Suite-Applications/There-was-an-error-opening-this-document-The-filename-directory/td-p/197425
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/ae2eea40-9fa6-46be-bca1-ac5eb5597d5e/sharepoint-2010-adobe-reader-error-opening-pdf-files?forum=sharepointgeneralprevious
http://community.office365.com/en-us/f/154/t/46204.aspx?PageIndex=2
disable the Mcafee Firewall Plug In. This is after of course I ran superantispyware to remove some malware. uninstalled and reinstalled the Adobe Reade
https://forums.adobe.com/message/1776202?tstart=0 -
Problem while opening PDF attachment in Inbox
Hi all,
I am sending PDF attachment through email to inbox.
When am trying to open PDF attachment i am getting error-
'There was an eror opening this document.The fuile changed and couldnt be open'
When i click on attachment some bytes are getting transfere essage is displayed in lower toolbar.
Please guide to resolve this problem.No reply.
-
Unable to open pdf file sent thro' mail - error in file
Hi,
I am sending the RFQ smartform print as pdf attachment to inbox.
I am facing the a problem when i am trying to open the pdf which i have recieved in my inbox.
Error as below:
"Either not supported file type or file is damaged (it was sent as an attachment and was not decoded properly)"!!!
Can someone please help me to solve the issue.
Regards,
Chitra.P.Sfind my code below:-
START-OF-SELECTION .
* FORM ENTRY_NEU
FORM ENTRY_NEU USING RETURN_CODE US_SCREEN.
perform select_record.
DATA: LF_RETCODE TYPE SY-SUBRC.
PERFORM PROCESSING USING US_SCREEN
CHANGING LF_RETCODE.
IF LF_RETCODE NE 0.
RETURN_CODE = 1.
ELSE.
RETURN_CODE = 0.
ENDIF.
ENDFORM.
convert pdf to xstring string
LOOP AT I_TLINE INTO LS_PDF.
ASSIGN LS_PDF TO <FS_X> CASTING.
CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE.
ENDLOOP.
* Convert xstring to binary table to pass
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = LV_CONTENT
IMPORTING
output_length = v_lines_bin
TABLES
BINARY_TAB = LT_DATA.
DATA:
w_fmodule TYPE rs38l_fnam,
*w_cparam TYPE ssfctrlop,
*w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
To display File SAVE dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
tables
data_tab = T_pdf_tab.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
* Create Message Body Title and Description
I_OBJTXT = 'RFQ print!'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'RFQ smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'RFQ smartform'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
Main Text
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
Attachment (pdf-Attachment)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'RFQ'.
I_OBJPACK-OBJ_DESCR = 'RFQ print'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = wa_SMTP_ADDR.
I_RECLIST-REC_TYPE = 'U'.
*I_RECLIST-com_type = 'INT'.
APPEND I_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN "changed on 03/09/2010
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF. -
Error While Opening PDF File in SAP Inbox
Hello Experts,
I am facing a weird error in SAP Inbox while opening a PDF files (both created by custom ABAP programs as well as the one attached to a new SAP Inbox message from my desktop & sent to my Inbox as a test).
The error states that "This file does not have a program associated with it for performing this action. Please install program or, if one is already installed, create an association in the Default Programs control panel.".
I checked TCode DC30 also & found an appropriate program is already maintained for PDF.
I couldn't make out more out of this error message. Any inputs in this regard will be highly appreciable.
Regards,
ShauryaHi,
Find out the FM that's generating the actual error through de-bug and analyze the same by looking in OSS and or SDN.
Regards
Narasimhan -
Error while Opening an attachment in the process.
Hi All,
I am facing an Issue here, I get an task assigned to me either to approve or reject, but when I try to open the attachment in the request, It tries to opens in the new IE browser, and I get an Error message displyed, as Page cannot open in the new browser.
I also can notice 500 error notice in the browser.
Also,I can able to open attachments of other request comming to my TO Do list, but has a problem with the one mentioned.
Since I am new to workbench server, not sure of the location of Log files and Temp files.
Request you to let me know the reason of this error and need to fix it too.
Kindly answer my questions at the earliest or suggest with any link.
Thanks,
Satish.Possibly the attached might got deleted while in transit. Any information from the server log?
Nith
Maybe you are looking for
-
Macbook Pro w/Retina: Processors nearing 100ºC?!
As part of my school's technology requirements, I purchased a Macbook Pro recently. It is the 2012 Retina Display model. All in all, it's a great computer, and most of the time, it runs quite cool or a little warm. However, when I stress the computer
-
Hello, do you know how to save all my applications with Desktop Manager 6 if I want to change my phone or the OS one day ? thanks for yours anwsers. Solved! Go to Solution.
-
Missing songs iphone downloaded and sync to back up.
I purchase my music from iTunes directly on the iPhone. Periodically I will sync to my HP laptop (running Vista). Recently I purchased several albums and some individual songs, as well as a few apps. A couple of days ago I tried to sync to my laptop
-
what do you do when you try to purchase an item for a game on ipad, and it says transaction failed, though you were billed for two of the lower level items?
-
Hi Guru, Any one can send the BDC program for F-02.plssss its urgent PLZ I NEED IT VERY URGENT UR HELP MAKES MORE COMFORT TO ME THANK Q U ALL 10 POINTS ASSURED