PDF attachment getting cut off

Hello Experts,
I'm trying to send a PDF attachment using a PL/SQL procedure. In this procedure Im picking up the PDF file from server and sending it via email attachment. The procedure works fine and sends the PDF but it cuts off the data in the PDF. When I open the PDF file I can only see half of page the rest is just blank. I cant figure out why this is happening, can someone please check the procedure and let me know where im going wrong.
CREATE OR REPLACE PROCEDURE send_email AS
v_file_handle UTL_FILE.FILE_TYPE;
v_email_server VARCHAR2(100) := 'xxxx'; -- replace with SMTP server
v_conn UTL_SMTP.CONNECTION;
v_port NUMBER := 25;
v_reply UTL_SMTP.REPLY;
v_msg VARCHAR2(32767);
v_line VARCHAR2(2000);
v_message VARCHAR2(2000) ;
b_connected BOOLEAN := FALSE;
v_sender VARCHAR2(50) := '[email protected]'; -- Sender email address
CRLF VARCHAR2(2):= CHR(13) || CHR(10);
RECPT VARCHAR2(255) := '[email protected]'; -- Receptiant email address
p_stat NUMBER;
SLP PLS_INTEGER := 300;
pdirpath VARCHAR2(50) := 'TEST'; -- directory on the server
pfilename VARCHAR2(50) := 'test01.pdf'; -- pdf file on the server
BEGIN
p_stat := 0;
/***** Check if the file exists ****/
BEGIN
v_file_handle := UTL_FILE.FOPEN(pDirPath, pFileName, 'R');
EXCEPTION
WHEN UTL_FILE.INVALID_PATH THEN
p_stat := 01;
DBMS_OUTPUT.PUT_LINE(SQLERRM ||' '|| p_stat);
WHEN OTHERS THEN
p_stat := 02;
DBMS_OUTPUT.PUT_LINE(SQLERRM ||' '|| p_stat);
END;
/***** Try to connect for three times, do sleep in between for 5 minutes *****/
FOR i IN 1..3 LOOP
BEGIN
--open the connection with the smtp server and DO THE handshake
v_conn:= UTL_SMTP.OPEN_CONNECTION(v_email_server, v_port);
v_reply :=UTL_SMTP.HELO( v_conn, v_email_server);
IF 250 = v_reply.code THEN
b_connected := TRUE;
EXIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_LOCK.SLEEP (SLP);
END;
END LOOP;
IF b_connected = FALSE THEN
p_stat := 03;
DBMS_OUTPUT.PUT_LINE(SQLERRM ||' '|| p_stat);
END IF;
v_reply := UTL_SMTP.MAIL(v_conn, v_sender);
IF 250 != v_reply.code THEN
p_stat := 04;
DBMS_OUTPUT.PUT_LINE(SQLERRM ||' '|| p_stat);
END IF;
v_reply := UTL_SMTP.RCPT(v_conn, RECPT);
IF 250 != v_reply.code THEN
p_stat := 05;
DBMS_OUTPUT.PUT_LINE(SQLERRM ||' '|| p_stat);
END IF;
UTL_SMTP.OPEN_DATA ( v_conn);
v_message := 'Sample Email This is an auto generated mail. Please DO NOT reply TO this mail.'||CHR(10);
v_msg := 'Date: '|| TO_CHAR( SYSDATE, 'Mon DD yy hh24:mi:ss' )
|| CRLF || 'From: ' || v_sender
|| CRLF || 'Subject: ' || 'Sample file'
|| CRLF || 'To: ' || RECPT
|| CRLF || 'Mime-Version: 1.0'
|| CRLF || 'Content-Type: multipart/mixed; boundary="DMW.Boundary.605592468"' || CRLF ||''
|| CRLF || v_message
|| CRLF ||''
|| CRLF ||'--DMW.Boundary.605592468'
|| CRLF ||'Content-Type: text/plain; NAME="v_message.txt"; charset=US-ASCII'
|| CRLF ||'Content-Disposition: inline; filename="v_message.txt"'
|| CRLF ||'Content-Transfer-Encoding: 7bit' || CRLF || ''
|| CRLF || v_message || CRLF || CRLF || CRLF;
UTL_SMTP.WRITE_DATA(v_conn,v_msg);
/***** Prepare the attachment to be sent *****/
v_Msg := CRLF || '--DMW.Boundary.605592468'
|| CRLF || 'Content-Type: application/octet-stream; NAME="' || pFileName || '"'
|| CRLF || 'Content-Disposition: attachment; filename="' || pFileName || '"'
|| CRLF || 'Content-Transfer-Encoding: 7bit' || CRLF || CRLF;
UTL_SMTP.WRITE_DATA (v_conn, v_msg);
LOOP
BEGIN
UTL_FILE.GET_LINE(v_file_handle, v_line);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
v_msg := '*** truncated ***' || CRLF;
v_msg := v_line || CRLF;
UTL_SMTP.WRITE_DATA ( v_conn, v_msg );
END LOOP;
UTL_FILE.FCLOSE(v_file_handle);
v_msg := CRLF;
UTL_SMTP.WRITE_DATA ( v_conn, v_msg );
v_msg := CRLF || '--DMW.Boundary.605592468--' || CRLF;
UTL_SMTP.WRITE_DATA ( v_conn, v_msg );
UTL_SMTP.CLOSE_DATA( v_conn );
UTL_SMTP.QUIT( v_conn );
EXCEPTION
WHEN OTHERS THEN
p_stat := 06;
END;
I'm not sure why my PDF is getting cut off towards the end, any help would be much appreciated.
Thank you very much.

Hi,
I managed to make it work, I changed the attach_base64 as per your recommendations but made my own slight change :-
PROCEDURE attach_base64_fromfile
(conn IN OUT NOCOPY utl_smtp.connection,
                    filename IN VARCHAR2,
floc IN VARCHAR2,
               mime_type IN VARCHAR2 DEFAULT 'application/octet',
                    inline IN BOOLEAN DEFAULT TRUE,
                    last IN BOOLEAN DEFAULT FALSE) IS
i PLS_INTEGER;
len PLS_INTEGER;
fh Utl_File.File_Type;
buf raw(32767);
BEGIN
begin_attachment(conn, mime_type, inline, filename, 'base64');
fh := Utl_File.Fopen (
location => floc,
filename => filename,
open_mode => 'r');
BEGIN
Utl_File.Get_Raw (
file => fh,
buffer => buf);
i := 1;
len := utl_raw.LENGTH(buf);
WHILE (i < len) LOOP
IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
utl_smtp.write_raw_data(conn, utl_encode.base64_encode(buf));
utl_smtp.write_data(conn, utl_tcp.CRLF);
END IF;
i := i + MAX_BASE64_LINE_WIDTH;
END LOOP;
EXCEPTION
WHEN no_data_found THEN NULL;
END;
Utl_File.Fclose ( file => fh );
end_attachment(conn, LAST);
END;
and created another procedure to call send_mail.attach_base64_fromfile :-
CREATE OR REPLACE PROCEDURE send_email_attachment IS
conn utl_smtp.connection;
BEGIN
conn := Send_Mail.begin_mail(
sender => '[email protected]', -- sender email address
recipients => '[email protected]', -- recipient email address
subject => 'Attachment Test',
mime_type => Send_Mail.MULTIPART_MIME_TYPE);
send_mail_vv.attach_base64_fromfile(
conn => conn,
filename => 'test.pdf', -- file name
floc => 'TEST', -- file location
mime_type => 'application/octet',
inline => TRUE);
Send_Mail.end_attachment( conn => conn );
Send_Mail.end_mail( conn => conn );
END;
Thanks for all your help.

Similar Messages

  • When converting word doc to pdf with Acrobat words getting cut off?

    Hi all,
    As you can see from this example:
    When converting from word document the words on the pages in the final PDF are getting cut off on the edge of the page?
    I've adjusted the margins in page layout in MS Word to Normal, Moderate & Wide etc, etc
    Never ever had this problem before...does anybody have any idea why or what I could do?
    Thanks in advance.

    As a quick check, set the printer to the Adobe PDF printer in WORD and then check for the proper operation. Also be sure the paper dimensions and orientation of your document and the printer properties match up (I have had some problems with the orientation when I have auto-rotate on). You may have to play some to get something to work. I have done that before and settled on a process that works for me, but I can't claim it all makes perfect sense. To many things are going on in some sense.

  • Text getting cut off when printing to PDF from Excel

    Hello,
         I've seen a lot related to this subject but nothing that shows a real solution.
         Using Excel 2003-sp3 and Adobe Acrobat v.9 Standard, the right half of the last character in the string gets cut off. It prints from excel fine.
         It's not always the text that is the right-most on the page either. An affected PDF file is attached - note the cut off "S" on the last line (NET ASSETS OF GOVERNMENTAL ACTIVITIES).
         Any assistance is appreciated.
    Thanks,
    Kevin Murphy

    please delete me from your mailing list.  tks.
    Date: Wed, 10 Feb 2010 11:20:28 -0700
    From: [email protected]
    To: [email protected]
    Subject: Text getting cut off when printing to PDF from Excel
    Hello,
         I've seen a lot related to this subject but nothing that shows a real solution.
         Using Excel 2003-sp3 and Adobe Acrobat v.9 Standard, the right half of the last character in the string gets cut off. It prints from excel fine.
         It's not always the text that is the right-most on the page either. An affected PDF file is attached - note the cut off "S" on the last line (NET ASSETS OF GOVERNMENTAL ACTIVITIES).
         Any assistance is appreciated.
    Thanks,
    Kevin Murphy
    >

  • I filled in a fillable pdf form and when i print it, the text in the fillable section gets cut off.

    I filled in a fillable pdf form and when i print it, the text in the fillable section gets cut off. What do I need to do to get the entire text to be printed. Any help is appreciated.
    Thanks

    What has this to do with Pages? You probably did this in Preview.
    Peter

  • JPG image shows up fine in layout but a section gets cut off a little at the bottom in exported PDF

    I've got a JPG inserted at the top of the page and there are text boxes below it.  In the layout everything looks fine, nothing is overlapping or getting cut off.  But when I export the image (best quality) as a PDF, a few of the letters in the JPG look cut off at the bottom.  The image looks like it's aligned straight so I'm not sure why it's only showing some of the letters in the middle section look like the bottoms have been chopped.  Any ideas what the problem is and how to fix it?  Thanks!

    urghhh not working still. all of my child folders are in the root folder...sorry for the confusion. the only files in the Template folder are the parent templates. i really don't know what's causing this. i've checked my css file..it's properly linked to the main templates. everything appears perfectly in FF so i'm assuming that if it were a general prob, the pages shouldn't have shown in FF at all. the index pages previews fine in IE and the old pages do as well, except for a few distortions bc i've changed the css rules. but now i also realize that the html file from which created the template isn't showing in IE as well but only in FF so the prob might have started from there but why?? i've checked everything...at least so i think.

  • Text gets cut off when exported to PDF

    When I export my report to PDF some of my text gets cut off where it would meet the right edge of the text box by 1 or 2 letters.
    This only happens when I export to PDF through my web application or when I export it throught the Report Manager URL
    If I export it on my local copy of SSRS then it shows up fine without the text getting cut off

    Hi,
    You can set the Cangrow property of the textbox to true which allows to grow your textbox and is default for any text box unless you have changed it.
    Please mark this post as Answered if this post helps to solve your query.

  • Text in fillable text form gets cut off and appears only in the lower half of the text form?

    I'm trying to create a text-fillable PDF form. However, when I add a text form, the text I test in it gets cut off and appears only in the lower half of the text form by default (see 2nd photo below). How do I correct this and make the text take up ALL the space in the form like the 1st photo?

    Have you set the text field properties options to multiline? Is so, please attach a screen shot of that dialog box so we can see how it is set.

  • Why do my margins get cut off when I right click print, but not when I open my document and print?

    When I right click print (without opening the document) my margins get cut off, but if I actally open my pdf document and click print, it will print just fine.  This only happens when the document has print that is close to the edge.
    I am using Adobe 10.1.2 with Windows 7.
    Thank you in advance for your thoughts and help

    As for your comment on this being my first Mac, and the program issue, you misunderstood. Yes the eMac is in fact my first, personally owned, Mac computer other than the original Apple II series floppy fed PC, in which me and my father owned. The only other Apple/Macintosh computer I had experience on was my father's 13" MacBook Pro, and 20" iMac (both ran OSX Tiger 10.4.11, just as the one I have know runs). The iMac was upgraded to Snow Leopard due to our need for better picture/video/audio editing software such as that of Adobe, and the Macbook Pro was sold because of a business that was started being siphoned out of money. I purchased the eMac from a small business based off of eBay. It had the majority of OSX Tiger software, only missing minor programs like Photobooth. Other than that, it had no wireless software like BlueTooth, Wi-Fi capabilities, wireless sync, ect... But alas, when you buy a Apple/Mac computer, you must take a few cutbacks when purchasing it (even refurb.) for around $120.00 including taxing, shipping, handling, ect... I purchased nearly all of my software from co-workers and friends who had an extra key, or I would receive the software disc from them, and buy a key. The only "illegal" thing I had on the computer was music I had downloaded from LimeWire. I have never, and will never, trust any software coming from a torrent download site.

  • Printing in Adobe Reader after exporting from InDesign gets cut-off

    I have exported a few documents form InDesign to PDF. When I print the documents, some parts get cut off (top section or bottom section) but there is still room on the paper. I'ts like the printer decides not to print those sections. I am printing on 5x7inch paper and all my documents show their sizes as 5x7inches.

    Turns out the issue was with Acrobat.
    See resolution here.
    http://forums.adobe.com/message/4496809#4496809

  • PDF printing margins cut off

    Hi,
    every time I try to print a PDF directly from Safari 7.0.2, the edges get cut off.
    If I download the PDF and print it using Preview or Acrobat, everything is fine. Chrome can print perfectly, so it is not a browser thing.
    There are tons of threads about safari cutting edges, wrong margins, etc. I tried a few of workarounds, some dark magic plist editing, nothing helps.
    It is not only me, all users of my webapp are reporting the same problem.
    Must I disable Safari for my users and ask them to switch to firefox or chrome?
    Please help

    Hey Apple, I thought you wanted to place Safari as a competitive browser!
    Still the same issue on Safari 7.0.3, the margins simply cut off parts of any pdf. It looks like it is a margins issue, but I am not sure.
    I am moving all my users to Chrome or Firefox!
    PLEASE FIX!!!

  • I'm running Adobe 9 pro on snow leopard and when I save or print from word for mac 14 the bottom gets cuts off

    I'm running Adobe 9 pro on snow leopard and when I save or print from word for mac 14 the bottom gets cuts off. Can someone help?

    Ah! You're creating a PDF out of Word through Acrobat. The cutoff is most likely being affected by the printer chosen.
    When you call up the print dialogue in Word, check to see what printer is being used. If it's a typical inkjet printer, Acrobat is using the print margins of that printer as the cutoff area. Since most such printers can't print to the last inch and half or so of the paper, that's where it would be cut off.
    Near the bottom, under the preview of the document, click on the Page Setup button. It doesn't really matter which printer you select here. Under Paper Size, choose Manage Custom Sizes. Under the Non-Printable Area heading, choose the same printer and set the paper size you're using.
    Note that the unprintable margins for that printer will be filled in automatically. That's what's being cut off. Click the + button to create a modified version. The default will be "Untitled". Give it a new name if you want. Then set all of the margins to zero. Click OK. Now you'll have that as a choice under Paper Size. Doesn't matter that the actual printer can't use this setting since you're going to a PDF. Click OK to get back to the main Word print dialogue.
    Now choose Save as Adobe PDF. It should give you an exact duplicate of what's on screen in Word since as far as Acrobat is concerned, your "printer" has no unprintable margins.

  • Text in Dynamic Textfield gets cut off

    Hi
    I have a dynamic text field which is just one line of text.
    For some reason letters like g or p that go below the regular
    line of text get cut off.
    I have made the field bigger, and also played around with the
    _height Property but it doesn't make a difference.
    I have imported the font into the Library. When I embed it
    the font doesn't cut off but looks very different. And if I change
    the field to a static field it doesn't cut off either, but the font
    looks a little different as well.
    Any ideas?

    Why should I start a new thread if this one was never resolved and I am still having the same problem?
    ANYWAY,
    I was able to fix this by finding an answer on a different forum.
    Simply increase the text leading using the text format option, like so:
    var format:TextFormat = new TextFormat();
    format.leading = 2;
    field_txt.defaultTextFormat=format;

  • HT1918 When I try to download a free app after log in the iTunes gets cut off with a msg update security question where do I do this?? I can't download anything

    When I try to download a free app after log in the iTunes gets cut off with a msg update security question where do I do this?? I can't download anything

    If you have a credit card on file on top of your gift card then it is asking you to confirm the security code for the card, which for a Visa or MasterCard is 3 digits located on the back, or AMEX has 4 digits on the front.  This happens just to ensure that you are the account holder, and would happen from time to time whether it was a free or paid app, even if you have a credit through your gift card.  This doesn't mean that your credit card will be charged.

  • What size should my movies be to not get cut off?

    I am making a tutorial DVD. I used Snapz Pro to record a bunch of screen capture movies and then edited them together in FCP and exported them as 1024x768 animation movies and they look great. Now I want to burn them to DVD. When I take them as they are and put them on a DVD the top and bottom of the screen get cut off. Can I just resize the movies in QT pro to a different size so they won't cut off? If so what size? Is there a better way?

    Scott,
    A mix of this QuickTime Pro: How to Make Picture-in-Picture at http://docs.info.apple.com/article.html?artnum=42633 and the following procedure I put together a couple of years ago to use the small movies produced by still digital cameras in iMovie/iDVD:
    1. Create a 640 x 480 black mask with a slightly lighter black 320 x 240 center in Photoshop. Save it as a JPG file.
    2. Open your DiMage X movie in QuickTime Pro. Open the saved mask in another QuickTime Pro player (at 15 fps).
    3. Select the mask clip and edit->select all and then edit->copy
    4. Select the DiMage X clip and then edit -> add scaled the mask
    5. Next, select movie -> get movie properties
    6. Select video 2 on the left box and layers on the right box. Set the layers to 1 (that moves the mask to the back).
    7. Select video one on the left box and size on the right box. Click on adjust. Red hack marks appear around the video. Click on the picture (not the mark) and center the video on the lightened 320 x 240 box.
    8. The video may not completely cover the lighter box, but the hack marks should line up. When you view the movie, if you used a "slightly lighter" black for the center area, you won't a notice a lighter area when played in iDVD.
    9. Export it as a DV stream. Bring it into iDVD.
    will give you an idea on how to proceed. Obviously, you will need to come up with your own mask and cut-out size - 640x480 ISN'T what YOU want.

  • Tops of Signatures get cut off...

    Can anyone tell me why or, better yet, how to fix the following issue I keep having?
    When using Adobe Reader and the "Sign>I Need To Sign>Place Signature" function with "Signature Style 4" the top of some of the letters of signatures gets cut off (see screenshot below). 
    I cannot find a way to rejustify the text nor am I able to enlarge only the box that the text is located in.  The single enlarging feature for the box is a diagonal enlargement tool which inherently also enlarges the text when it is used.  So it defeats the purpose of what I'm trying to fix and only makes the issue into a larger size.
    Any assistance in correcting this issue is greatly appreciated!
    --CR4

    There are several situations where this could happen.
    1) If you have 4:3 footage (standard def) in a 16:9 project (widescreen) and select CROP in the Rotate, Crop, Ken Burns Tool, then it will cut off the top and bottom of your clips to make them fill the screen. If you select FIT instead of CROP, it will letterbox (add black bars) so you see the whole clip.
    2) This can also happen when you automatically apply image stabilization. Stabilization works by zooming in. You can turn off stabilization in the Clip Inspector.
    3) If you have iPhone clips and the iPhone was held vertically, then this will be an issue for you, because iMovie always sets the aspect ratio to match a TV screen, so the horizontal dimension will always be the longest. For best results, shoot all movies in landscape mode on your iPhone. If you have already shot in Portrait Mode, I suggest using FIT rather than CROP so you do not cut off the heads.

Maybe you are looking for

  • How can I capture motion video of my iPhone screen?

    I would like to capture my iPhone screen in action for purposes of demonstrating its usage to others (e.g. How do I create and send a text?). I want to be able to use this in a FinalCut video.

  • How do I restore a folder after hard drive replacement?

    At the end of November, I bought Panther, primarily for the Time Machine application. I installed the OS and set up Time Machine to back up my Users folder (not the entire hard drive) to an external hard drive. Last week, my internal hard disk crashe

  • When saving documents in PDF format a .txt document is also created and saved

    When saving documents in PDF format to the my documents folder on a PC a .txt document is also created and saved, does anybody know the where the setting is that allows this functionality (duplicate document in txt format) to be switched off thanks.

  • All files in 70gb+ library have broken link after 7.3 upgrade. oh man.

    I was fine and dandy with 7.2 running on my MBP. Life was good. I upgraded to OS 10.4.10 and iTunes 7.3 on the same day to get it talkin' nice with my iPhone and then BAM!! -- all of the tracks in iTunes were stricken with the hideous ! enclosed in a

  • Accessing iTunes Store automatically

    Everytime I open up iTunes it comes up "Accessing iTunes Store" and it takes around 30 - 1 hour to go away. Even if I push cancel it stays cancelling for over 10 minutes. I don't have good internet connection right now and I don't know why it's doing