How to insert line breaks into PDF?

Question:Hi this might seem like a weird question. Anyway, I'm generating some PDF file on the fly using PHP and some third party code I found. My problem is I need to insert line breaks in some part of the text that will be inserted in the PDF file. Something like:$pdf->Insert Text('Line one\n\nLine two');So it prints
Line one
Line two
I know \n doesn't work on PDF, but do you guys know any character or something that I can use to insert  line break on VeryPDF?

Answer: When you need to insert line break to PDF from PHP, maybe you can have a free trial of this software VeryPDF PDF Stamp SDK or command line version by which you can insert line breaks in some part of the text that will be inserted in the PDF file.  And by the SDK version and command line version, you can call it from PHP easily. Please check more information of this software on homepage, in the following part, I will show you how to use this software.

Step 1. Free download PDF Stamp COM to your computer.

  • When downloading finishes, there will be a zip file. Please extract it to some folder then you can call it normally like other command line version software.
  • Download SDK version or command line version according to your needs, please choose the right downloading button.

Step 2. Insert Line break

  • When insert line break, please refer to the following information and parameters:
  • -AL:Create a Line Stamp.
    -Cn(default is -C0):Specify the line color, range from 0x000000-0xFFFFFF, in decimal system, .e.g -C255,
    For example,Red Color: -C255 equal: 0x0000FF
                Green Color: -C65280 equal: 0x00FF00
                Blue Color: -C16711680 equal: 0xFF0000
                BGR(E1E1E1) = 225*256*256+225*256+225 = -C14803425
                BGR(128,128,128) = 128*256*256+128*256+128 = -C8421504
                -C option is also support hex format, for example,
                -C#FF0000, -C#00FF00, -C#0000FF
    -Wn/-Hn (default is -W100 (page width)):Specify the line Length.
    -Wn/-Hn parameter is used to increase or decrease the Length of the original line when it is stamped onto the PDF document. original line Length equal page width(-Wn). A scale of 50 will make the page width(-Wn) or height(-Hn) half (50%) its original Length, while scales of 200 (200%) will double it.e.g. -W80
    -LWn(default is -LW1)Line Width..e.g -LW3
    -LineEx (x1,y1,x2,y2):Draw a line from (x1,y1) to (x2,y2), eg, -LINEEX 100,100,200,200
    Other options:
    [-Pn] [-MLRn] [-MTBn] [-Rn] [-L]

  • Here is an example for your reference:
  • pdfstamp.exe -pdf example.pdf -o stamp-line1.pdf -al -lineex 50,100,200,100-LW2 -C#FF0000
    pdfstamp.exe -pdf example.pdf -o stamp-line2.pdf -AL -LW30 -opacity30 -LINEEX 100,100,200,200 -C#00FF00

  • Now check the effect of inserting line break from the following snapshot.

line break

  • When you call it from PHP, please refer to the following code templates:
  • <?php
    $PdfStamp =new COM("PDFStampOCX.CPDFStamp") or die("Cannot start                            
    $id = oTest.veryOpenEx("C:\test.pdf", "C:\out.pdf")
    If ($id > 0)

            $code = PdfStamp.veryAddTextEx($id, 3, "Demo Watermark", 0,                              
                           0, 0, 0, 0, 0, 0, 300, "", 0, 0, "", 0)
            $code = PdfStamp.veryAddTextEx($id, 6, "Copyright                                 
                 , Inc.", RGB(255, 200, 100), 0, 0, 0, 0,                
                           0, 0, 0, "", 0, 0, "", 0)
             $code = PdfStamp.veryAddTextEx($id, 9, "\n                                
                           Demo", 255, 0, 0, 0, -45, 0, 1, 200, "", 48,
                           0, "", 0)
             PdfStamp.veryCloseEx ($id)
             $PdfStamp = null;

During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Random Posts

This entry was posted in PDF Editor Toolkit and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Verify Code   If you cannot see the CheckCode image,please refresh the page again!